Bug 1725564 - Use the same base checks for WASM_{CC,CXX} as {CC,CXX}/HOST_{CC,CXX}. r=firefox-build-system-reviewers,mhentges

Differential Revision: https://phabricator.services.mozilla.com/D122569
This commit is contained in:
Mike Hommey
2021-08-14 00:53:52 +00:00
parent ae8d6cb972
commit bef4208b9e
2 changed files with 46 additions and 59 deletions

View File

@@ -781,6 +781,11 @@ def using_compiler_wrapper(compiler_wrapper):
set_config("MOZ_USING_COMPILER_WRAPPER", using_compiler_wrapper)
@dependable
def wasm():
return split_triplet("wasm32-wasi", allow_wasi=True)
@template
def default_c_compilers(host_or_target, other_c_compiler=None):
"""Template defining the set of default C compilers for the host and
@@ -789,7 +794,7 @@ def default_c_compilers(host_or_target, other_c_compiler=None):
from init.configure.
`other_c_compiler` is the `target` C compiler when `host_or_target` is `host`.
"""
assert host_or_target in {host, target}
assert host_or_target in {host, target, wasm}
other_c_compiler = () if other_c_compiler is None else (other_c_compiler,)
@@ -802,6 +807,8 @@ def default_c_compilers(host_or_target, other_c_compiler=None):
elif host_or_target.kernel == "Darwin":
types = ("clang",)
supported = ("clang", "gcc")
elif host_or_target.kernel == "WASI":
supported = types = ("clang",)
else:
supported = types = ("clang", "gcc")
@@ -1049,7 +1056,7 @@ def compiler(
`other_c_compiler` is the result of the `compiler` template for the
language 'C' for `target`.
"""
assert host_or_target in {host, target}
assert host_or_target in {host, target, wasm}
assert language in ("C", "C++")
assert language == "C" or c_compiler is not None
assert host_or_target is target or other_compiler is not None
@@ -1058,16 +1065,19 @@ def compiler(
host_or_target_str = {
host: "host",
target: "target",
wasm: "wasm",
}[host_or_target]
sysroot = {
host: host_sysroot,
target: target_sysroot,
wasm: dependable(lambda: namespace(path=None)),
}[host_or_target]
multiarch_dir = {
host: host_multiarch_dir,
target: target_multiarch_dir,
wasm: never,
}[host_or_target]
var = {
@@ -1075,6 +1085,8 @@ def compiler(
("C++", target): "CXX",
("C", host): "HOST_CC",
("C++", host): "HOST_CXX",
("C", wasm): "WASM_CC",
("C++", wasm): "WASM_CXX",
}[language, host_or_target]
default_compilers = {
@@ -1352,19 +1364,21 @@ def compiler(
linker_var = {
target: "LD",
host: "HOST_LD",
}[host_or_target]
}.get(host_or_target)
@deprecated_option(env=linker_var, nargs=1)
def linker(value):
if value:
return value[0]
if linker_var:
@depends(linker)
def unused_linker(linker):
if linker:
log.warning(
"The value of %s is not used by this build system." % linker_var
)
@deprecated_option(env=linker_var, nargs=1)
def linker(value):
if value:
return value[0]
@depends(linker)
def unused_linker(linker):
if linker:
log.warning(
"The value of %s is not used by this build system." % linker_var
)
return valid_compiler

View File

@@ -2121,63 +2121,36 @@ with only_when(requires_wasm_sandboxing & compile_environment):
set_config("WASI_SYSROOT", wasi_sysroot)
def wasm_compiler_with_flags(
wasm_compiler, provided_wasm_compiler, sysroot, compiler_wrapper
):
def wasm_compiler_with_flags(compiler, sysroot):
if not sysroot:
return
if provided_wasm_compiler:
return " ".join(
list(compiler_wrapper or [])
+ provided_wasm_compiler.wrapper
+ [provided_wasm_compiler.program]
+ provided_wasm_compiler.flags
elif compiler:
return (
compiler.wrapper
+ [compiler.compiler]
+ compiler.flags
+ ["--sysroot=%s" % sysroot]
)
elif wasm_compiler:
return " ".join(
list(compiler_wrapper or [])
+ [wasm_compiler]
+ ["--target=wasm32-wasi", "--sysroot=%s" % sysroot]
)
option(env="WASM_CC", nargs=1, help="Path to the C->WASM compiler")
provided_wasm_cc = provided_program("WASM_CC")
wasm_cc = check_prog(
"_WASM_CC",
["clang"],
input=provided_wasm_cc.program,
paths=clang_search_path,
allow_missing=True,
what="the C->WASM compiler",
)
wasm_cc = compiler("C", wasm, other_compiler=c_compiler)
@depends(wasm_cc, provided_wasm_cc, wasi_sysroot, compiler_wrapper)
def wasm_cc_with_flags(wasm_cc, provided_wasm_cc, wasi_sysroot, compiler_wrapper):
return wasm_compiler_with_flags(
wasm_cc, provided_wasm_cc, wasi_sysroot, compiler_wrapper
)
@depends(wasm_cc, wasi_sysroot)
def wasm_cc_with_flags(wasm_cc, wasi_sysroot):
return wasm_compiler_with_flags(wasm_cc, wasi_sysroot)
set_config("WASM_CC", wasm_cc_with_flags)
option(env="WASM_CXX", nargs=1, help="Path to the C++->WASM compiler")
provided_wasm_cxx = provided_program("WASM_CXX")
wasm_cxx = check_prog(
"_WASM_CXX",
["clang++"],
input=provided_wasm_cxx.program,
paths=clang_search_path,
allow_missing=True,
what="the C++->WASM compiler",
wasm_cxx = compiler(
"C++",
wasm,
c_compiler=wasm_cc,
other_compiler=cxx_compiler,
other_c_compiler=c_compiler,
)
@depends(wasm_cxx, provided_wasm_cxx, wasi_sysroot, compiler_wrapper)
def wasm_cxx_with_flags(
wasm_cxx, provided_wasm_cxx, wasi_sysroot, compiler_wrapper
):
return wasm_compiler_with_flags(
wasm_cxx, provided_wasm_cxx, wasi_sysroot, compiler_wrapper
)
@depends(wasm_cxx, wasi_sysroot)
def wasm_cxx_with_flags(wasm_cxx, wasi_sysroot):
return wasm_compiler_with_flags(wasm_cxx, wasi_sysroot)
set_config("WASM_CXX", wasm_cxx_with_flags)