Skip to content

Commit 64d62bf

Browse files
authored
Merge pull request #1360 from symphorien/fix_cross_rust
fix cross compilation in rust-related Makefile parts
2 parents ab6c740 + 2b0d2c4 commit 64d62bf

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
@@ -126,11 +126,11 @@ AM_CXXFLAGS = $(CODE_COVERAGE_CXXFLAGS) $(USER_CXXFLAGS)
126126
if HAVE_CARGO
127127
RUST_DEPS_CPPFLAGS = -DHAVE_RUST_DEPS=1
128128
PRQLC_DIR = third-party/prqlc-c/target
129-
RUST_DEPS_LIBS = $(PRQLC_DIR)/release/libprqlc_c.a
129+
RUST_DEPS_LIBS = $(PRQLC_DIR)/$(RUSTC_PLATFORM)/release/libprqlc_c.a
130130

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

136136
else

0 commit comments

Comments
 (0)