Skip to content

Commit 2b0d2c4

Browse files
committed
fix cross compilation in rust-related Makefile parts
1 parent cce176f commit 2b0d2c4

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

configure.ac

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,32 @@ AC_PROG_INSTALL
4848
AC_PROG_RANLIB
4949
AM_PROG_AR
5050
AC_PROG_LN_S
51+
AC_PROG_GREP
5152
AC_PROG_MAKE_SET
5253

5354
AC_PATH_PROG(BASH, [bash])
5455
AC_PATH_PROG(CARGO_CMD, [cargo])
56+
AC_PATH_PROG(RUSTC_CMD, [rustc])
57+
if test x"$RUSTC_CMD" == x""; then
58+
RUSTC_PLATFORM=no
59+
else
60+
# for example, rustc expects x86_64-unknown-linux-gnu instead of x86_64-pc-linux-gnu
61+
# and armv7-unknown-linux-gnueabihf instead of armv7l-unknown-linux-gnueabihf
62+
AC_MSG_CHECKING([rustc --target argument])
63+
if "$RUSTC_CMD" --print target-list | $GREP "$host" > /dev/null; then
64+
RUSTC_PLATFORM="$host"
65+
else
66+
candidate=`echo "$host_cpu"-unknown-"$host_os" | sed -e 's/armv\(.\)l-/armv\1-/'`
67+
if "$RUSTC_CMD" --print target-list | $GREP "$candidate" > /dev/null; then
68+
RUSTC_PLATFORM="$candidate"
69+
else
70+
AC_MSG_ERROR("$RUSTC_CMD knows neither $host nor $candidate")
71+
fi
72+
AC_MSG_RESULT(["$RUSTC_PLATFORM"])
73+
fi
74+
fi
75+
AC_SUBST(RUSTC_PLATFORM)
76+
5577
AC_PATH_PROG(BZIP2_CMD, [bzip2])
5678
AC_PATH_PROG(RE2C_CMD, [re2c])
5779
AM_CONDITIONAL(HAVE_RE2C, test x"$RE2C_CMD" != x"")

src/Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ AM_CXXFLAGS = $(CODE_COVERAGE_CXXFLAGS) $(USER_CXXFLAGS)
125125
if HAVE_CARGO
126126
RUST_DEPS_CPPFLAGS = -DHAVE_RUST_DEPS=1
127127
PRQLC_DIR = third-party/prqlc-c/target
128-
RUST_DEPS_LIBS = $(PRQLC_DIR)/release/libprqlc_c.a
128+
RUST_DEPS_LIBS = $(PRQLC_DIR)/$(RUSTC_PLATFORM)/release/libprqlc_c.a
129129

130130
$(RUST_DEPS_LIBS): $(srcdir)/third-party/prqlc-c/src/lib.rs $(srcdir)/third-party/prqlc-c/Cargo.toml
131131
mkdir -p $(PRQLC_DIR)
132-
env CARGO_TARGET_DIR=third-party/prqlc-c/target $(CARGO_CMD) build --manifest-path \
132+
env CARGO_TARGET_DIR=third-party/prqlc-c/target $(CARGO_CMD) build --target $(RUSTC_PLATFORM) --manifest-path \
133133
$(srcdir)/third-party/prqlc-c/Cargo.toml --package prqlc-c --release
134134

135135
else

0 commit comments

Comments
 (0)