Commit 83fb89d3 authored by Mike Hommey's avatar Mike Hommey
Browse files

Bug 1723956 - Make --without-sysroot work again. r=firefox-build-system-reviewers,mhentges

Also make it not bootstrap a host sysroot.

Differential Revision: https://phabricator.services.mozilla.com/D121815
parent 9df33a60
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -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