mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1854047 - Enable relrhack in local builds when possible. r=firefox-build-system-reviewers,andi
Differential Revision: https://phabricator.services.mozilla.com/D188677
This commit is contained in:
parent
554f9dda0a
commit
0420c204c2
@ -170,11 +170,33 @@ class TestToolkitMozConfigure(BaseConfigureTest):
|
||||
)
|
||||
|
||||
PACK = ["-Wl,-z,pack-relative-relocs"]
|
||||
# The typical case with a bootstrap build: linker supports pack-relative-relocs,
|
||||
# but glibc is old and doesn't.
|
||||
mockcc = MockCC(True, False)
|
||||
readelf = ReadElf(True)
|
||||
self.assertEqual(get_values(mockcc, readelf), ("lld", None, "relr"))
|
||||
self.assertEqual(
|
||||
get_values(mockcc, readelf, ["--enable-release"]), ("lld", None, "relr")
|
||||
)
|
||||
self.assertEqual(
|
||||
get_values(mockcc, readelf, ["--enable-elf-hack"]), ("lld", None, "relr")
|
||||
)
|
||||
self.assertEqual(
|
||||
get_values(mockcc, readelf, ["--enable-elf-hack=relr"]),
|
||||
("lld", None, "relr"),
|
||||
)
|
||||
# LLD is picked by default and enabling elfhack fails because of that.
|
||||
with self.assertRaises(SystemExit):
|
||||
get_values(mockcc, readelf, ["--enable-elf-hack=legacy"])
|
||||
# If we force to use BFD ld, it works.
|
||||
self.assertEqual(
|
||||
get_values(
|
||||
mockcc, readelf, ["--enable-elf-hack=legacy", "--enable-linker=bfd"]
|
||||
),
|
||||
("bfd", None, "legacy"),
|
||||
)
|
||||
|
||||
for mockcc, readelf in (
|
||||
# The typical case with a bootstrap build: linker supports pack-relative-relocs,
|
||||
# but glibc is old and doesn't. We won't use pack-relative-relocs, and will use
|
||||
# elfhack on release builds, or when explicitly enabled.
|
||||
(MockCC(True, False), ReadElf(True)),
|
||||
# Linker doesn't support pack-relative-relocs. Glibc is old.
|
||||
(MockCC(False, False), ReadElf(False)),
|
||||
# Linker doesn't support pack-relative-relocs. Glibc is new.
|
||||
@ -189,21 +211,13 @@ class TestToolkitMozConfigure(BaseConfigureTest):
|
||||
get_values(mockcc, readelf, ["--enable-release"]),
|
||||
("lld", None, None),
|
||||
)
|
||||
# LLD is picked by default and enabling elfhack fails because of that.
|
||||
with self.assertRaises(SystemExit):
|
||||
get_values(mockcc, readelf, ["--enable-elf-hack"])
|
||||
with self.assertRaises(SystemExit):
|
||||
get_values(mockcc, readelf, ["--enable-elf-hack=relr"])
|
||||
# LLD is picked by default and enabling elfhack fails because of that.
|
||||
with self.assertRaises(SystemExit):
|
||||
get_values(mockcc, readelf, ["--enable-elf-hack=legacy"])
|
||||
if readelf.with_relr:
|
||||
# Explicitly enabling relrhack works because pack-relative-relocs are supported.
|
||||
self.assertEqual(
|
||||
get_values(mockcc, readelf, ["--enable-elf-hack=relr"]),
|
||||
("lld", None, "relr"),
|
||||
)
|
||||
else:
|
||||
# relrhack doesn't work without pack-relative-relocs support.
|
||||
with self.assertRaises(SystemExit):
|
||||
get_values(mockcc, readelf, ["--enable-elf-hack=relr"])
|
||||
# If we force to use BFD ld, it works.
|
||||
self.assertEqual(
|
||||
get_values(
|
||||
@ -226,15 +240,21 @@ class TestToolkitMozConfigure(BaseConfigureTest):
|
||||
self.assertEqual(
|
||||
get_values(mockcc, readelf, ["--enable-release"]), ("lld", PACK, None)
|
||||
)
|
||||
self.assertEqual(
|
||||
get_values(mockcc, readelf, ["--enable-elf-hack"]),
|
||||
("lld", None, "relr"),
|
||||
)
|
||||
self.assertEqual(
|
||||
get_values(mockcc, readelf, ["--enable-elf-hack=relr"]),
|
||||
("lld", None, "relr"),
|
||||
)
|
||||
# LLD is picked by default and enabling elfhack fails because of that.
|
||||
with self.assertRaises(SystemExit):
|
||||
get_values(mockcc, readelf, ["--enable-elf-hack"])
|
||||
with self.assertRaises(SystemExit):
|
||||
get_values(mockcc, readelf, ["--enable-elf-hack=legacy"])
|
||||
# If we force to use BFD ld, it works.
|
||||
self.assertEqual(
|
||||
get_values(mockcc, readelf, ["--enable-elf-hack", "--enable-linker=bfd"]),
|
||||
("bfd", None, "legacy"),
|
||||
("bfd", None, "relr"),
|
||||
)
|
||||
self.assertEqual(
|
||||
get_values(
|
||||
@ -242,11 +262,6 @@ class TestToolkitMozConfigure(BaseConfigureTest):
|
||||
),
|
||||
("bfd", None, "legacy"),
|
||||
)
|
||||
# Explicitly enabling relrhack works because pack-relative-relocs are supported.
|
||||
self.assertEqual(
|
||||
get_values(mockcc, readelf, ["--enable-elf-hack=relr"]),
|
||||
("lld", None, "relr"),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -1498,14 +1498,9 @@ with only_when("--enable-compile-environment"):
|
||||
if enable and enable != ("relr",):
|
||||
return enable
|
||||
|
||||
@depends("--enable-elf-hack", "MOZ_AUTOMATION", when=has_elfhack)
|
||||
def may_enable_relrhack(enable, automation):
|
||||
# For now, only enable relrhack when explicitly given with
|
||||
# --enable-elf-hack=relr. On automation, we automatically
|
||||
# enable it when possible.
|
||||
if automation and enable and enable != ("legacy",):
|
||||
return enable
|
||||
if enable == ("relr",):
|
||||
@depends("--enable-elf-hack", when=has_elfhack)
|
||||
def may_enable_relrhack(enable):
|
||||
if enable and enable != ("legacy",):
|
||||
return enable
|
||||
|
||||
@depends(
|
||||
|
Loading…
Reference in New Issue
Block a user