diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure index 22fba57be75b..26a4442c802f 100755 --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -918,20 +918,27 @@ def provided_program(env_var, when=None): @template -def sysroot_path(host_or_target): +def sysroot_path(host_or_target, target_sysroot=None): + assert target_sysroot or host_or_target is target + bootstrap_target_when = target_is_linux if host_or_target is host: host_or_target_str = "host" opt = "--with-host-sysroot" env = "HOST_SYSROOT" when = depends(host)(lambda h: h.kernel == "Linux") - bootstrap_when = when + # Only bootstrap a host sysroot when using a bootstrapped target sysroot + # or when the target doesn't use a bootstrapped sysroot in the first place. + @depends(when, bootstrap_target_when, target_sysroot.bootstrapped) + def bootstrap_when(when, bootstrap_target_when, bootstrapped): + return when and (bootstrapped or not bootstrap_target_when) + else: assert host_or_target is target host_or_target_str = "target" opt = "--with-sysroot" env = "SYSROOT" when = target_is_linux_or_wasi - bootstrap_when = target_is_linux + bootstrap_when = bootstrap_target_when option( opt, @@ -943,7 +950,10 @@ def sysroot_path(host_or_target): sysroot_input = depends(opt, when=when)(lambda x: x) bootstrap_sysroot = depends(bootstrap_when, sysroot_input)( - lambda bootstrap, input: bootstrap and not input + # Only bootstrap when no flag was explicitly given (either --with or --without) + lambda bootstrap, input: bootstrap + and not input + and input.origin == "default" ) @depends( @@ -983,7 +993,7 @@ def system_lib_option(name, *args, **kwargs): ) -host_sysroot_path = sysroot_path(host).path +host_sysroot_path = sysroot_path(host, target_sysroot_path).path target_sysroot_path = target_sysroot_path.path