Skip to content

Commit 19c7c1d

Browse files
authored
fix(build): Support cross-compilation of Rust binaries (#2178)
1 parent 960c748 commit 19c7c1d

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ CARGO_FEATURE_ARGS += --features variations
179179
endif
180180

181181
rusile.so: $(rusile_so_SOURCES) $(bin_PROGRAMS)
182-
$(CARGO_ENV) $(CARGO) build $(CARGO_VERBOSE) $(RUSILE_FEATURE_ARG) $(CARGO_RELEASE_ARGS) -p rusile
182+
$(CARGO_ENV) $(CARGO) build $(CARGO_VERBOSE) --target $(CARGO_TARGET_TRIPLE) $(RUSILE_FEATURE_ARG) $(CARGO_RELEASE_ARGS) -p rusile
183183
$(INSTALL) @builddir@/target/@RUST_TARGET_SUBDIR@/lib$@ $@
184184

185185
DEPDIR := .deps

build-aux/que_rust_boilerplate.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ $(COMPLETIONS_OUT_DIR)/_$(TRANSFORMED_PACKAGE_NAME): $(CARGO_BIN) | $(COMPLETION
5757
$(_RUST_OUT) $(CARGO_BIN): $(@PACKAGE_VAR@_SOURCES) $(nodist_@PACKAGE_VAR@_SOURCES) $(EXTRA_@PACKAGE_VAR@_SOURCES)
5858
set -e
5959
export AUTOTOOLS_DEPENDENCIES="$^"
60-
$(CARGO_ENV) $(CARGO) build $(CARGO_VERBOSE) $(CARGO_FEATURE_ARGS) $(CARGO_RELEASE_ARGS)
61-
$(CARGO_ENV) $(CARGO) build --quiet --message-format=json $(CARGO_FEATURE_ARGS) $(CARGO_RELEASE_ARGS) | \
60+
$(CARGO_ENV) $(CARGO) build $(CARGO_VERBOSE) --target $(CARGO_TARGET_TRIPLE) $(CARGO_FEATURE_ARGS) $(CARGO_RELEASE_ARGS)
61+
$(CARGO_ENV) $(CARGO) build --target $(CARGO_TARGET_TRIPLE) --quiet --message-format=json $(CARGO_FEATURE_ARGS) $(CARGO_RELEASE_ARGS) | \
6262
$(JQ) -sr 'map(select(.reason == "build-script-executed")) | last | .out_dir' > $(_RUST_OUT)
6363

6464
RUST_DEVELOPER_TARGETS = cargo-test clippy rustfmt

build-aux/que_rust_boilerplate.m4

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ AC_DEFUN_ONCE([QUE_RUST_BOILERPLATE], [
2222
QUE_PROGVAR([rustfmt])
2323
])
2424
25+
AC_ARG_VAR(CARGO_TARGET_TRIPLE, "Target triple for Rust compilations")
26+
if test -z "$CARGO_TARGET_TRIPLE"; then
27+
CARGO_TARGET_TRIPLE="$($RUSTC -vV | $SED -n 's/host: //p')"
28+
fi
2529
AC_MSG_CHECKING([whether to build Rust code with debugging information])
2630
AM_COND_IF([DEBUG_RELEASE], [
2731
AC_MSG_RESULT(yes)
28-
RUST_TARGET_SUBDIR=debug
32+
RUST_TARGET_SUBDIR=$CARGO_TARGET_TRIPLE/debug
2933
], [
3034
AC_MSG_RESULT(no)
31-
RUST_TARGET_SUBDIR=release
35+
RUST_TARGET_SUBDIR=$CARGO_TARGET_TRIPLE/release
3236
])
3337
AC_SUBST([RUST_TARGET_SUBDIR])
3438

0 commit comments

Comments
 (0)