diff --git a/pkgs/applications/networking/browsers/firefox/build-fix-RELRHACK_LINKER-setting-when-linker-name-i.patch b/pkgs/applications/networking/browsers/firefox/build-fix-RELRHACK_LINKER-setting-when-linker-name-i.patch new file mode 100644 index 000000000000..58107b6b9320 --- /dev/null +++ b/pkgs/applications/networking/browsers/firefox/build-fix-RELRHACK_LINKER-setting-when-linker-name-i.patch @@ -0,0 +1,57 @@ +From 45d40b3eeb393051bd3a49feebcefe39dc6e4e93 Mon Sep 17 00:00:00 2001 +From: Peter Collingbourne +Date: Wed, 23 Apr 2025 21:13:38 -0700 +Subject: [PATCH] build: fix RELRHACK_LINKER setting when linker name is target + triple prefixed + +RELRHACK_LINKER is used as the name of a binary installed in a +directory specified with -B to override the linker. Both Clang and +GCC will only look for a binary named "ld" (or "ld.$fuse_ld_setting" +if -fuse-ld= is specified) in the -B directories, which means that +if the linker name does not follow this pattern, for example if it +is named $target_triple-ld", the relrhack linker will not be found, +the compiler will use the normal linker and the link will fail. To fix +this problem, use the correct pattern to name the relrhack executable. +--- + toolkit/moz.configure | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/toolkit/moz.configure b/toolkit/moz.configure +index 6c47287a5b..1a9c368e5e 100644 +--- a/toolkit/moz.configure ++++ b/toolkit/moz.configure +@@ -1843,23 +1843,23 @@ with only_when("--enable-compile-environment"): + use_relrhack = depends(which_elf_hack)(lambda x: x == "relr") + set_config("RELRHACK", True, when=use_relrhack) + +- @depends(c_compiler, linker_ldflags, when=use_relrhack) +- def relrhack_real_linker(c_compiler, linker_ldflags): ++ @depends(linker_ldflags, when=use_relrhack) ++ def relrhack_linker(linker_ldflags): + ld = "ld" + for flag in linker_ldflags: + if flag.startswith("-fuse-ld="): + ld = "ld." + flag[len("-fuse-ld=") :] ++ return ld ++ ++ set_config("RELRHACK_LINKER", relrhack_linker) ++ ++ @depends(c_compiler, relrhack_linker, when=use_relrhack) ++ def relrhack_real_linker(c_compiler, ld): + ld = check_cmd_output( + c_compiler.compiler, f"--print-prog-name={ld}", *c_compiler.flags + ) + return ld.rstrip() + +- @depends(relrhack_real_linker, when=use_relrhack) +- def relrhack_linker(ld): +- return os.path.basename(ld) +- +- set_config("RELRHACK_LINKER", relrhack_linker) +- + std_filesystem = host_cxx_compiler.try_run( + header="#include ", + body='auto foo = std::filesystem::absolute("");', +-- +2.49.0.805.g082f7c87e0-goog + diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index f2692a647c97..70d811c73ee1 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -357,6 +357,10 @@ buildStdenv.mkDerivation { # Fix for missing vector header on macOS # https://bugzilla.mozilla.org/show_bug.cgi?id=1939405 ./firefox-mac-missing-vector-header.patch + + # https://bugzilla.mozilla.org/show_bug.cgi?id=1962497 + # https://phabricator.services.mozilla.com/D246545 + ./build-fix-RELRHACK_LINKER-setting-when-linker-name-i.patch ] ++ extraPatches;