mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-07 18:04:46 +00:00
Bug 1733308 - Forbid sources files with the same base name. r=firefox-build-system-reviewers,andi
While the build system could be improved to actually support those cases, because of all the legacy things involved, it would be a lot more work for a low reward. Instead, we forbid them, which allows to remove the non-unified builds exception in xpcom/rust/gtest. Differential Revision: https://phabricator.services.mozilla.com/D127035
This commit is contained in:
parent
7ddd9de745
commit
ae874d3dfc
@ -621,7 +621,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
dependencies,
|
||||
features,
|
||||
is_gkrust,
|
||||
**static_args
|
||||
**static_args,
|
||||
)
|
||||
|
||||
def _handle_gn_dirs(self, context):
|
||||
@ -989,6 +989,22 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
wasm_linkables.append(lib)
|
||||
self._wasm_compile_dirs.add(context.objdir)
|
||||
|
||||
seen = {}
|
||||
for symbol in ("SOURCES", "UNIFIED_SOURCES"):
|
||||
for src in context.get(symbol, []):
|
||||
basename = os.path.splitext(os.path.basename(src))[0]
|
||||
if basename in seen:
|
||||
other_src, where = seen[basename]
|
||||
extra = ""
|
||||
if "UNIFIED_SOURCES" in (symbol, where):
|
||||
extra = " in non-unified builds"
|
||||
raise SandboxValidationError(
|
||||
f"{src} from {symbol} would have the same object name "
|
||||
f"as {other_src} from {where}{extra}.",
|
||||
context,
|
||||
)
|
||||
seen[basename] = (src, symbol)
|
||||
|
||||
# Only emit sources if we have linkables defined in the same context.
|
||||
# Note the linkables are not emitted in this function, but much later,
|
||||
# after aggregation (because of e.g. USE_LIBS processing).
|
||||
|
@ -11,4 +11,4 @@ def Library(name):
|
||||
|
||||
Library("dummy")
|
||||
|
||||
SOURCES = ["bar.c", "bar.cpp", "foo.c", "foo.cpp"]
|
||||
SOURCES = ["bar.c", "baz.cpp", "foo.c", "qux.cpp"]
|
||||
|
@ -14,13 +14,13 @@ Library("dummy")
|
||||
SOURCES += ["bar.s", "foo.asm"]
|
||||
|
||||
HOST_SOURCES += ["bar.cpp", "foo.cpp"]
|
||||
HOST_SOURCES += ["bar.c", "foo.c"]
|
||||
HOST_SOURCES += ["baz.c", "qux.c"]
|
||||
|
||||
SOURCES += ["bar.c", "foo.c"]
|
||||
SOURCES += ["baz.c", "qux.c"]
|
||||
|
||||
SOURCES += ["bar.mm", "foo.mm"]
|
||||
SOURCES += ["fuga.mm", "hoge.mm"]
|
||||
|
||||
SOURCES += ["baz.S", "foo.S"]
|
||||
SOURCES += ["titi.S", "toto.S"]
|
||||
|
||||
WASM_SOURCES += ["bar.cpp"]
|
||||
WASM_SOURCES += ["bar.c"]
|
||||
WASM_SOURCES += ["baz.c"]
|
||||
|
@ -42,17 +42,17 @@ class TestCompileDBBackends(BackendTester):
|
||||
},
|
||||
{
|
||||
"directory": topobjdir,
|
||||
"command": "clang++ -o /dev/null -c -ferror-limit=0 {}/bar.cpp".format(
|
||||
"command": "clang++ -o /dev/null -c -ferror-limit=0 {}/baz.cpp".format(
|
||||
topsrcdir
|
||||
),
|
||||
"file": "{}/bar.cpp".format(topsrcdir),
|
||||
"file": "{}/baz.cpp".format(topsrcdir),
|
||||
},
|
||||
{
|
||||
"directory": topobjdir,
|
||||
"command": "clang++ -o /dev/null -c -ferror-limit=0 {}/foo.cpp".format(
|
||||
"command": "clang++ -o /dev/null -c -ferror-limit=0 {}/qux.cpp".format(
|
||||
topsrcdir
|
||||
),
|
||||
"file": "{}/foo.cpp".format(topsrcdir),
|
||||
"file": "{}/qux.cpp".format(topsrcdir),
|
||||
},
|
||||
]
|
||||
|
||||
|
@ -376,18 +376,18 @@ class TestRecursiveMakeBackend(BackendTester):
|
||||
|
||||
expected = {
|
||||
"ASFILES": ["ASFILES += $(srcdir)/bar.s", "ASFILES += $(srcdir)/foo.asm"],
|
||||
"CMMSRCS": ["CMMSRCS += $(srcdir)/bar.mm", "CMMSRCS += $(srcdir)/foo.mm"],
|
||||
"CSRCS": ["CSRCS += $(srcdir)/bar.c", "CSRCS += $(srcdir)/foo.c"],
|
||||
"CMMSRCS": ["CMMSRCS += $(srcdir)/fuga.mm", "CMMSRCS += $(srcdir)/hoge.mm"],
|
||||
"CSRCS": ["CSRCS += $(srcdir)/baz.c", "CSRCS += $(srcdir)/qux.c"],
|
||||
"HOST_CPPSRCS": [
|
||||
"HOST_CPPSRCS += $(srcdir)/bar.cpp",
|
||||
"HOST_CPPSRCS += $(srcdir)/foo.cpp",
|
||||
],
|
||||
"HOST_CSRCS": [
|
||||
"HOST_CSRCS += $(srcdir)/bar.c",
|
||||
"HOST_CSRCS += $(srcdir)/foo.c",
|
||||
"HOST_CSRCS += $(srcdir)/baz.c",
|
||||
"HOST_CSRCS += $(srcdir)/qux.c",
|
||||
],
|
||||
"SSRCS": ["SSRCS += $(srcdir)/baz.S", "SSRCS += $(srcdir)/foo.S"],
|
||||
"WASM_CSRCS": ["WASM_CSRCS += $(srcdir)/bar.c"],
|
||||
"SSRCS": ["SSRCS += $(srcdir)/titi.S", "SSRCS += $(srcdir)/toto.S"],
|
||||
"WASM_CSRCS": ["WASM_CSRCS += $(srcdir)/baz.c"],
|
||||
"WASM_CPPSRCS": ["WASM_CPPSRCS += $(srcdir)/bar.cpp"],
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,6 @@ def Library(name):
|
||||
|
||||
Library("dummy")
|
||||
|
||||
SOURCES += ["test1.c", "test1.S"]
|
||||
SOURCES += ["test1.c", "test2.S"]
|
||||
|
||||
ASFLAGS += ["-no-integrated-as"]
|
||||
|
@ -0,0 +1,4 @@
|
||||
SOURCES += [
|
||||
"Test.c",
|
||||
"Test.cpp",
|
||||
]
|
@ -0,0 +1,4 @@
|
||||
SOURCES += [
|
||||
"subdir/Test.cpp",
|
||||
"Test.cpp",
|
||||
]
|
@ -0,0 +1,7 @@
|
||||
SOURCES += [
|
||||
"Test.c",
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
"Test.cpp",
|
||||
]
|
@ -0,0 +1,4 @@
|
||||
UNIFIED_SOURCES += [
|
||||
"Test.c",
|
||||
"Test.cpp",
|
||||
]
|
@ -1514,6 +1514,40 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
)
|
||||
self.assertFalse(sources.have_unified_mapping)
|
||||
|
||||
def test_object_conflicts(self):
|
||||
"""Test that object name conflicts are detected."""
|
||||
reader = self.reader("object-conflicts/1")
|
||||
with self.assertRaisesRegex(
|
||||
SandboxValidationError,
|
||||
"Test.cpp from SOURCES would have the same object name as"
|
||||
" Test.c from SOURCES\.",
|
||||
):
|
||||
self.read_topsrcdir(reader)
|
||||
|
||||
reader = self.reader("object-conflicts/2")
|
||||
with self.assertRaisesRegex(
|
||||
SandboxValidationError,
|
||||
"Test.cpp from SOURCES would have the same object name as"
|
||||
" subdir/Test.cpp from SOURCES\.",
|
||||
):
|
||||
self.read_topsrcdir(reader)
|
||||
|
||||
reader = self.reader("object-conflicts/3")
|
||||
with self.assertRaisesRegex(
|
||||
SandboxValidationError,
|
||||
"Test.cpp from UNIFIED_SOURCES would have the same object name as"
|
||||
" Test.c from SOURCES in non-unified builds\.",
|
||||
):
|
||||
self.read_topsrcdir(reader)
|
||||
|
||||
reader = self.reader("object-conflicts/4")
|
||||
with self.assertRaisesRegex(
|
||||
SandboxValidationError,
|
||||
"Test.cpp from UNIFIED_SOURCES would have the same object name as"
|
||||
" Test.c from UNIFIED_SOURCES in non-unified builds\.",
|
||||
):
|
||||
self.read_topsrcdir(reader)
|
||||
|
||||
def test_final_target_pp_files(self):
|
||||
"""Test that FINAL_TARGET_PP_FILES works properly."""
|
||||
reader = self.reader("dist-files")
|
||||
|
@ -6,11 +6,9 @@
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
"bench-collections/Bench.cpp",
|
||||
"moz_task/Test.cpp",
|
||||
"nsstring/Test.cpp",
|
||||
"xpcom/Test.cpp",
|
||||
"moz_task/TestMozTask.cpp",
|
||||
"nsstring/TestnsString.cpp",
|
||||
"xpcom/TestXpcom.cpp",
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = "xul-gtest"
|
||||
|
||||
REQUIRES_UNIFIED_BUILD = True
|
||||
|
Loading…
Reference in New Issue
Block a user