Bug 1524396 - Replace RUST_TARGET_ENV_NAME with make substitutions. r=chmanchester
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 22 Mar 2019 11:06:11 +0000
changeset 524444 fca0ca0f03fed6ed7c9630304b7e426d1052de89
parent 524443 deda41129e2fafdf58a213e0b94994fe5f36168e
child 524445 fc6f661f4113fa38c6e44663c404edc7e3ceadec
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1524396 - Replace RUST_TARGET_ENV_NAME with make substitutions. r=chmanchester While the substitution pattern is kind of awful in make, it will allow to more straightforwardly deal with the difference between target and host. Differential Revision: https://phabricator.services.mozilla.com/D24321
--- a/build/moz.configure/rust.configure
+++ b/build/moz.configure/rust.configure
@@ -267,26 +267,16 @@ def validate_rust_host_triple(host, rust
         die("The rust compiler host ({}) is not suitable for the configure host ({})."
             .format(rustc_host, configure_host))
 set_config('RUST_TARGET', rust_target_triple)
 set_config('RUST_HOST_TARGET', rust_host_triple)
-def rust_target_env_name(triple):
-    return triple.upper().replace('-', '_')
-# We need this to form various Cargo environment variables, as there is no
-# uppercase function in make, and we don't want to shell out just for
-# converting a string to uppercase.
-set_config('RUST_TARGET_ENV_NAME', rust_target_env_name)
 # This is used for putting source info into symbol files.
 set_config('RUSTC_COMMIT', depends(rustc_info)(lambda i: i.commit))
 # Rustdoc is required by Rust tests below.
 js_option(env='RUSTDOC', nargs=1, help='Path to the rustdoc program')
 rustdoc = check_prog('RUSTDOC', ['rustdoc'], paths=toolchain_search_path,
                      input='RUSTDOC', allow_missing=True)
--- a/config/makefiles/rust.mk
+++ b/config/makefiles/rust.mk
@@ -132,16 +132,18 @@ TARGET_RECIPES := \
 $(TARGET_RECIPES): RUSTFLAGS:=$(rustflags_override) $(RUSTFLAGS)
   $(foreach a,library program,$(foreach b,build check,force-cargo-host-$(a)-$(b)))
 $(HOST_RECIPES): RUSTFLAGS:=$(rustflags_override)
+cargo_env = $(subst -,_,$(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$1)))))))))))))))))))))))))))
 # We use the + prefix to pass down the jobserver fds to cargo, but we
 # don't use the prefix when make -n is used, so that cargo doesn't run
 # in that case)
 define RUN_CARGO
 $(if $(findstring n,$(filter-out --%, $(MAKEFLAGS))),,+)$(CARGO) $(1) $(cargo_build_flags)
 # This function is intended to be called by:
@@ -154,17 +156,17 @@ endef
 $(call RUN_CARGO,rustc)
 $(call RUN_CARGO,check)
-cargo_linker_env_var := CARGO_TARGET_$(RUST_TARGET_ENV_NAME)_LINKER
+cargo_linker_env_var := CARGO_TARGET_$(call cargo_env,$(RUST_TARGET))_LINKER
 # Don't define a custom linker on Windows, as it's difficult to have a
 # non-binary file that will get executed correctly by Cargo.  We don't
 # have to worry about a cross-compiling (besides x86-64 -> x86, which
 # already works with the current setup) setup on Windows, and we don't
 # have to pass in any special linker options on Windows.
 ifneq (WINNT,$(OS_ARCH))