bug 1417646 - Pass `-Z run-dsymutil=no` to rustc for mac cross-compiles. r?build
When rustc links a mac binary it attempts to run `dsymutil` afterwards and
expects to find it in PATH. Our mac cross-compile builds do not have that
binary (we use llvm-dsymutil and it's not in PATH) but rustc doesn't have
any way to override the tool path. It does provide `-Z run-dsymutil=no` to
opt out of running dsymutil, so we'll use that in this scenario. We don't
currently hit this issue because we don't link any binaries with rustc in
cross-mac builds, but this will unblock building geckodriver there.
We additionally need to set `RUSTC_BOOTSTRAP` in this case because this is
an unstable option, so this patch extends the existing case for that (for
`MOZ_RUST_SIMD`).
MozReview-Commit-ID: KNBQkHb2M5d
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -1479,18 +1479,18 @@ imply_option('RUSTC_OPT_LEVEL', '2', whe
@depends('RUSTC_OPT_LEVEL', moz_optimize)
def rustc_opt_level(opt_level_option, moz_optimize):
if opt_level_option:
return opt_level_option[0]
else:
return '1' if moz_optimize.optimize else '0'
-@depends(rustc_opt_level, debug_rust, '--enable-debug-symbols')
-def rust_compiler_flags(opt_level, debug_rust, debug_symbols):
+@depends(rustc_opt_level, debug_rust, '--enable-debug-symbols', cross_compiling, target)
+def rust_compiler_flags(opt_level, debug_rust, debug_symbols, cross_compiling, target):
# Cargo currently supports only two interesting profiles for building:
# development and release. Those map (roughly) to --enable-debug and
# --disable-debug in Gecko, respectively.
#
# But we'd also like to support an additional axis of control for
# optimization level. Since Cargo only supports 2 profiles, we're in
# a bit of a bind.
#
@@ -1518,16 +1518,21 @@ def rust_compiler_flags(opt_level, debug
('yes' if debug_assertions else 'no'))
if debug_info is not None:
opts.append('debuginfo=%s' % debug_info)
flags = []
for opt in opts:
flags.extend(['-C', opt])
+ # When cross-compiling for mac, rustc will try to run dsymutil after linking binaries,
+ # and we don't have that in PATH.
+ if target.os == 'OSX' and cross_compiling:
+ flags.extend(('-Z', 'run-dsymutil=no'))
+
return flags
set_config('MOZ_RUST_DEFAULT_FLAGS', rust_compiler_flags)
# Rust incremental compilation
# ==============================================================
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -881,17 +881,17 @@ environment_cleaner = -u VCINSTALLDIR PA
# The servo build needs to know where python is, and we're removing the PATH
# so we tell it explicitly via the PYTHON env var.
environment_cleaner += PYTHON='$(shell which $(PYTHON))'
else
environment_cleaner =
endif
rust_unlock_unstable =
-ifdef MOZ_RUST_SIMD
+ifdef MOZ_RUSTC_BOOSTRAP
rust_unlock_unstable += RUSTC_BOOTSTRAP=1
endif
ifdef MOZ_USING_SCCACHE
sccache_wrap := RUSTC_WRAPPER='$(CCACHE)'
endif
ifneq (WINNT,$(OS_ARCH))
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -850,16 +850,26 @@ def rust_simd(value, target):
# As of 2018-06-05, the simd crate only works on aarch64,
# armv7, x86 and x86_64.
if target.cpu in ('aarch64', 'arm', 'x86', 'x86_64') and value:
return True
set_config('MOZ_RUST_SIMD', rust_simd)
set_define('MOZ_RUST_SIMD', rust_simd)
+
+@depends(cross_compiling, target, rust_simd)
+def rustc_bootstrap(cross_compiling, target, rust_simd):
+ # We need to unlock unstable rustc features if we're using simd or
+ # cross-compiling a mac build.
+ if rust_simd or (target.os == 'OSX' and cross_compiling):
+ return True
+
+set_config('MOZ_RUSTC_BOOSTRAP', rustc_bootstrap)
+
# Printing
# ==============================================================
@depends(target)
def ios_disable_printing(target):
if target.os == 'iOS':
return False
imply_option('--enable-printing', ios_disable_printing, reason='--target')