зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1724374 - Use --sysroot on mac builds. r=firefox-build-system-reviewers,andi
We're currently using -isysroot as a preprocessor flag and -Wl,--syslibroot/-Wl,--sysroot as a linker flag, but --sysroot is generalization of both, so we can use that instead. Differential Revision: https://phabricator.services.mozilla.com/D121943
This commit is contained in:
Родитель
d8f6319203
Коммит
d784654760
|
@ -1000,7 +1000,7 @@ def sysroot_flags(host_or_target):
|
|||
@depends(host_or_target, macos_sdk, sysroot_path)
|
||||
def sysroot_flags(host_or_target, macos_sdk, sysroot_path):
|
||||
if macos_sdk and host_or_target.os == "OSX":
|
||||
return ["-isysroot", macos_sdk]
|
||||
return ["--sysroot", macos_sdk]
|
||||
if sysroot_path:
|
||||
return ["--sysroot", sysroot_path]
|
||||
return []
|
||||
|
@ -2259,16 +2259,10 @@ def select_linker(
|
|||
set_config("LINKER_KIND", select_linker.KIND)
|
||||
|
||||
|
||||
@depends_if(select_linker, target, macos_sdk, target_sysroot_path, multiarch_dir)
|
||||
@depends_if(select_linker, target, target_sysroot_path, multiarch_dir)
|
||||
@imports("os")
|
||||
def linker_ldflags(linker, target, macos_sdk, sysroot_path, multiarch_dir):
|
||||
def linker_ldflags(linker, target, sysroot_path, multiarch_dir):
|
||||
flags = list((linker and linker.LINKER_FLAG) or [])
|
||||
if target.kernel == "Darwin":
|
||||
if linker and linker.KIND == "ld64":
|
||||
flags.append("-Wl,-syslibroot,%s" % macos_sdk)
|
||||
else:
|
||||
flags.append("-Wl,--sysroot=%s" % macos_sdk)
|
||||
|
||||
# rpath-link is irrelevant to wasm, see for more info https://github.com/emscripten-core/emscripten/issues/11076.
|
||||
if sysroot_path and multiarch_dir and target.os != "WASI":
|
||||
for d in ("lib", "usr/lib"):
|
||||
|
|
|
@ -887,7 +887,7 @@ class OSXToolchainTest(BaseToolchainTest):
|
|||
SYSROOT_FLAGS = {
|
||||
"flags": PrependFlags(
|
||||
[
|
||||
"-isysroot",
|
||||
"--sysroot",
|
||||
xcrun("", ("--show-sdk-path",))[1],
|
||||
"-mmacosx-version-min=10.12",
|
||||
]
|
||||
|
|
|
@ -13,10 +13,7 @@ import six
|
|||
from six import StringIO
|
||||
from textwrap import dedent
|
||||
|
||||
from mozunit import (
|
||||
main,
|
||||
MockedOpen,
|
||||
)
|
||||
from mozunit import main, MockedOpen
|
||||
|
||||
from mozbuild.preprocessor import Preprocessor
|
||||
from mozbuild.util import ReadOnlyNamespace
|
||||
|
@ -106,10 +103,7 @@ class TestCompilerPreprocessor(unittest.TestCase):
|
|||
|
||||
def test_normalization(self):
|
||||
pp = CompilerPreprocessor(
|
||||
{
|
||||
"__has_attribute(bar)": 1,
|
||||
'__has_warning("-Wc++98-foo")': 1,
|
||||
}
|
||||
{"__has_attribute(bar)": 1, '__has_warning("-Wc++98-foo")': 1}
|
||||
)
|
||||
pp.out = StringIO()
|
||||
input = StringIO(
|
||||
|
@ -142,13 +136,7 @@ class TestCompilerPreprocessor(unittest.TestCase):
|
|||
self.assertEquals(pp.out.getvalue(), "WFOO\nBAR\nNO_FOO\n")
|
||||
|
||||
def test_condition(self):
|
||||
pp = CompilerPreprocessor(
|
||||
{
|
||||
"A": 1,
|
||||
"B": "2",
|
||||
"C": "0L",
|
||||
}
|
||||
)
|
||||
pp = CompilerPreprocessor({"A": 1, "B": "2", "C": "0L"})
|
||||
pp.out = StringIO()
|
||||
input = StringIO(
|
||||
dedent(
|
||||
|
@ -229,8 +217,8 @@ class FakeCompiler(dict):
|
|||
if arg is None:
|
||||
break
|
||||
if arg.startswith("-"):
|
||||
# Ignore -isysroot and the argument that follows it.
|
||||
if arg == "-isysroot":
|
||||
# Ignore --sysroot and the argument that follows it.
|
||||
if arg == "--sysroot":
|
||||
next(args, None)
|
||||
else:
|
||||
flags.append(arg)
|
||||
|
@ -273,39 +261,17 @@ class FakeCompiler(dict):
|
|||
|
||||
class TestFakeCompiler(unittest.TestCase):
|
||||
def test_fake_compiler(self):
|
||||
with MockedOpen(
|
||||
{
|
||||
"file": "A B C",
|
||||
"file.c": "A B C",
|
||||
}
|
||||
):
|
||||
compiler = FakeCompiler(
|
||||
{
|
||||
"A": "1",
|
||||
"B": "2",
|
||||
}
|
||||
)
|
||||
with MockedOpen({"file": "A B C", "file.c": "A B C"}):
|
||||
compiler = FakeCompiler({"A": "1", "B": "2"})
|
||||
self.assertEquals(compiler(None, ["-E", "file"]), (0, "1 2 C", ""))
|
||||
|
||||
compiler = FakeCompiler(
|
||||
{
|
||||
None: {
|
||||
"A": "1",
|
||||
"B": "2",
|
||||
},
|
||||
"-foo": {
|
||||
"C": "foo",
|
||||
},
|
||||
"-bar": {
|
||||
"B": "bar",
|
||||
"C": "bar",
|
||||
},
|
||||
"-qux": {
|
||||
"B": False,
|
||||
},
|
||||
"*.c": {
|
||||
"B": "42",
|
||||
},
|
||||
None: {"A": "1", "B": "2"},
|
||||
"-foo": {"C": "foo"},
|
||||
"-bar": {"B": "bar", "C": "bar"},
|
||||
"-qux": {"B": False},
|
||||
"*.c": {"B": "42"},
|
||||
}
|
||||
)
|
||||
self.assertEquals(compiler(None, ["-E", "file"]), (0, "1 2 C", ""))
|
||||
|
@ -334,111 +300,25 @@ class TestFakeCompiler(unittest.TestCase):
|
|||
)
|
||||
|
||||
def test_multiple_definitions(self):
|
||||
compiler = FakeCompiler({"A": 1, "B": 2}, {"C": 3})
|
||||
|
||||
self.assertEquals(compiler, {None: {"A": 1, "B": 2, "C": 3}})
|
||||
compiler = FakeCompiler({"A": 1, "B": 2}, {"B": 4, "C": 3})
|
||||
|
||||
self.assertEquals(compiler, {None: {"A": 1, "B": 4, "C": 3}})
|
||||
compiler = FakeCompiler(
|
||||
{
|
||||
"A": 1,
|
||||
"B": 2,
|
||||
},
|
||||
{
|
||||
"C": 3,
|
||||
},
|
||||
{"A": 1, "B": 2}, {None: {"B": 4, "C": 3}, "-foo": {"D": 5}}
|
||||
)
|
||||
|
||||
self.assertEquals(compiler, {None: {"A": 1, "B": 4, "C": 3}, "-foo": {"D": 5}})
|
||||
|
||||
compiler = FakeCompiler(
|
||||
{None: {"A": 1, "B": 2}, "-foo": {"D": 5}},
|
||||
{"-foo": {"D": 5}, "-bar": {"E": 6}},
|
||||
)
|
||||
|
||||
self.assertEquals(
|
||||
compiler,
|
||||
{
|
||||
None: {
|
||||
"A": 1,
|
||||
"B": 2,
|
||||
"C": 3,
|
||||
},
|
||||
},
|
||||
)
|
||||
compiler = FakeCompiler(
|
||||
{
|
||||
"A": 1,
|
||||
"B": 2,
|
||||
},
|
||||
{
|
||||
"B": 4,
|
||||
"C": 3,
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEquals(
|
||||
compiler,
|
||||
{
|
||||
None: {
|
||||
"A": 1,
|
||||
"B": 4,
|
||||
"C": 3,
|
||||
},
|
||||
},
|
||||
)
|
||||
compiler = FakeCompiler(
|
||||
{
|
||||
"A": 1,
|
||||
"B": 2,
|
||||
},
|
||||
{
|
||||
None: {
|
||||
"B": 4,
|
||||
"C": 3,
|
||||
},
|
||||
"-foo": {
|
||||
"D": 5,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEquals(
|
||||
compiler,
|
||||
{
|
||||
None: {
|
||||
"A": 1,
|
||||
"B": 4,
|
||||
"C": 3,
|
||||
},
|
||||
"-foo": {
|
||||
"D": 5,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
compiler = FakeCompiler(
|
||||
{
|
||||
None: {
|
||||
"A": 1,
|
||||
"B": 2,
|
||||
},
|
||||
"-foo": {
|
||||
"D": 5,
|
||||
},
|
||||
},
|
||||
{
|
||||
"-foo": {
|
||||
"D": 5,
|
||||
},
|
||||
"-bar": {
|
||||
"E": 6,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEquals(
|
||||
compiler,
|
||||
{
|
||||
None: {
|
||||
"A": 1,
|
||||
"B": 2,
|
||||
},
|
||||
"-foo": {
|
||||
"D": 5,
|
||||
},
|
||||
"-bar": {
|
||||
"E": 6,
|
||||
},
|
||||
},
|
||||
compiler, {None: {"A": 1, "B": 2}, "-foo": {"D": 5}, "-bar": {"E": 6}}
|
||||
)
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче