Skip to content

Commit

Permalink
llvmPackages_{15,16,17,git}.libcxx: fix darwin link flags
Browse files Browse the repository at this point in the history
This change applies the upstream PR
llvm/llvm-project#77218 so the same link flags
on darwin are used as when LIBCXX_CXX_ABI=libcxxabi. Specifically, this
adds
"-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp"
which prevents libcxx from segfaulting on darwin
  • Loading branch information
annalee committed Jan 12, 2024
1 parent f94b761 commit 7b62547
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
8 changes: 8 additions & 0 deletions pkgs/development/compilers/llvm/15/libcxx/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ stdenv.mkDerivation rec {
hash = "sha256-AaM9A6tQ4YAw7uDqCIV4VaiUyLZv+unwcOqbakwW9/k=";
relative = "libcxx";
})
# fix for https://github.com/NixOS/nixpkgs/issues/269548
# https://github.com/llvm/llvm-project/pull/77218
(fetchpatch {
name = "darwin-system-libcxxabi-link-flags.patch";
url = "https://github.com/llvm/llvm-project/commit/c5b89b29ee6e3c444a355fd1cf733ce7ab2e316a.patch";
hash = "sha256-LNoPg1KCoP8RWxU/AzHR52f4Dww24I9BGQJedMhFxyQ=";
relative = "libcxx";
})
] ++ lib.optionals stdenv.hostPlatform.isMusl [
../../libcxx-0001-musl-hacks.patch
];
Expand Down
10 changes: 9 additions & 1 deletion pkgs/development/compilers/llvm/16/libcxx/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ lib, stdenv, llvm_meta
, monorepoSrc, runCommand
, monorepoSrc, runCommand, fetchpatch
, cmake, ninja, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
, libcxxabi, libcxxrt, libunwind
Expand Down Expand Up @@ -47,6 +47,14 @@ stdenv.mkDerivation rec {

patches = [
./gnu-install-dirs.patch
# fix for https://github.com/NixOS/nixpkgs/issues/269548
# https://github.com/llvm/llvm-project/pull/77218
(fetchpatch {
name = "darwin-system-libcxxabi-link-flags.patch";
url = "https://github.com/llvm/llvm-project/commit/c5b89b29ee6e3c444a355fd1cf733ce7ab2e316a.patch";
hash = "sha256-LNoPg1KCoP8RWxU/AzHR52f4Dww24I9BGQJedMhFxyQ=";
relative = "libcxx";
})
];

postPatch = ''
Expand Down
13 changes: 12 additions & 1 deletion pkgs/development/compilers/llvm/17/libcxx/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ lib, stdenv, llvm_meta
, monorepoSrc, runCommand
, monorepoSrc, runCommand, fetchpatch
, cmake, ninja, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
, libcxxabi, libcxxrt, libunwind
Expand Down Expand Up @@ -45,6 +45,17 @@ stdenv.mkDerivation rec {
chmod -R u+w .
'';

patches = [
# fix for https://github.com/NixOS/nixpkgs/issues/269548
# https://github.com/llvm/llvm-project/pull/77218
(fetchpatch {
name = "darwin-system-libcxxabi-link-flags.patch";
url = "https://github.com/llvm/llvm-project/commit/c5b89b29ee6e3c444a355fd1cf733ce7ab2e316a.patch";
hash = "sha256-LNoPg1KCoP8RWxU/AzHR52f4Dww24I9BGQJedMhFxyQ=";
relative = "libcxx";
})
];

postPatch = ''
cd ../runtimes
'';
Expand Down
13 changes: 12 additions & 1 deletion pkgs/development/compilers/llvm/git/libcxx/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ lib, stdenv, llvm_meta
, monorepoSrc, runCommand
, monorepoSrc, runCommand, fetchpatch
, cmake, ninja, python3, fixDarwinDylibNames, version
, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi
, libcxxabi, libcxxrt, libunwind
Expand Down Expand Up @@ -45,6 +45,17 @@ stdenv.mkDerivation rec {
chmod -R u+w .
'';

patches = [
# fix for https://github.com/NixOS/nixpkgs/issues/269548
# https://github.com/llvm/llvm-project/pull/77218
(fetchpatch {
name = "darwin-system-libcxxabi-link-flags.patch";
url = "https://github.com/llvm/llvm-project/commit/c5b89b29ee6e3c444a355fd1cf733ce7ab2e316a.patch";
hash = "sha256-LNoPg1KCoP8RWxU/AzHR52f4Dww24I9BGQJedMhFxyQ=";
relative = "libcxx";
})
];

postPatch = ''
cd ../runtimes
'';
Expand Down

0 comments on commit 7b62547

Please sign in to comment.