Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkgs/development/compilers/llvm/3.8/clang/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ let
mv clang-tools-extra-* $sourceRoot/tools/extra
'';

buildInputs = [ cmake libxml2 llvm python ];
nativeBuildInputs = [ cmake ];
buildInputs = [ libxml2 llvm python ];

cmakeFlags = [
"-DCMAKE_CXX_FLAGS=-std=c++11"
Expand All @@ -27,6 +28,8 @@ let
postPatch = ''
sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp
sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp
'' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/Tools.cpp
'';

outputs = [ "out" "lib" "python" ];
Expand Down
13 changes: 10 additions & 3 deletions pkgs/development/compilers/llvm/3.8/libc++/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,22 @@ stdenv.mkDerivation rec {
patches = [
# glibc 2.26 fix
../../3.9/libc++/xlocale-glibc-2.26.patch
] ++ lib.optional stdenv.isDarwin ./darwin.patch;
]
++ lib.optional stdenv.isDarwin ./darwin.patch
++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
../../libcxx-0001-musl-hacks.patch
../../libcxx-max_align_t.patch
];

nativeBuildInputs = [ cmake ];

buildInputs = [ cmake libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;

cmakeFlags = [
"-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
"-DLIBCXX_LIBCPPABI_VERSION=2"
"-DLIBCXX_CXX_ABI=libcxxabi"
];
] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1";

enableParallelBuilding = true;

Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/3.8/libc++abi.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ stdenv.mkDerivation {
export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_INCLUDES=$PWD/$(ls -d libcxx-*)/include"
'' + stdenv.lib.optionalString stdenv.isDarwin ''
export TRIPLE=x86_64-apple-darwin
'' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch}
patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-max_align_t.patch}
'';

installPhase = if stdenv.isDarwin
Expand Down
18 changes: 15 additions & 3 deletions pkgs/development/compilers/llvm/3.8/llvm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ in stdenv.mkDerivation rec {

# Fix a segfault in llc
# See http://lists.llvm.org/pipermail/llvm-dev/2016-October/106500.html
patches = [ ./D17533-1.patch ] ++
stdenv.lib.optionals (!stdenv.isDarwin) [./fix-llvm-config.patch];
patches = [ ./D17533-1.patch ]
++ stdenv.lib.optional (!stdenv.isDarwin) ./fix-llvm-config.patch
++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
../TLI-musl.patch
../dynamiclibrary-musl.patch
];

# hacky fix: New LLVM releases require a newer macOS SDK than
# 10.9. This is a temporary measure until nixpkgs darwin support is
Expand All @@ -49,7 +53,7 @@ in stdenv.mkDerivation rec {
--replace 'set(CMAKE_INSTALL_NAME_DIR "@rpath")' "set(CMAKE_INSTALL_NAME_DIR "$out/lib")" \
--replace 'set(CMAKE_INSTALL_RPATH "@executable_path/../lib")' ""
''
+ stdenv.lib.optionalString (stdenv ? glibc) ''
+ ''
(
cd projects/compiler-rt
patch -p1 < ${
Expand Down Expand Up @@ -81,6 +85,14 @@ in stdenv.mkDerivation rec {
++ stdenv.lib.optionals ( isDarwin) [
"-DLLVM_ENABLE_LIBCXX=ON"
"-DCAN_TARGET_i386=false"
] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
"-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we handle these without the condition? I guess that could break things but I would much prefer to have these 3 flags be unconditional.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would too -- but previously was asked to keep them musl-only for now so I was following along here. How about I make a new PR doing this across LLVM versions containing this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay that's definitely fine to make it musl-only. I just want to minimize conditionals in Nixpkgs as much as possible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume since the nativeBuildInput stuff is done in here, doing that too wouldn't make it a mass rebuild, right? I'd ping whoever asked before, either in this PR, or a 3rd master PR (not the 4 5 6 one).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make a new PR if that's alright with you-- rather keep unrelated things separate even if it looks like we have 3 PR's on that subject now but oh well :).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(since that PR will conflict with this one if not based on top, I'll wait to put that together until this is merged since I think there's little controversial/risky here, esp in comparison :))

"-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}"
"-DTARGET_TRIPLE=${stdenv.targetPlatform.config}"
# Not yet supported
"-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
"-DCOMPILER_RT_BUILD_XRAY=OFF"

];

postBuild = ''
Expand Down
2 changes: 2 additions & 0 deletions pkgs/development/compilers/llvm/3.9/clang/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ let
postPatch = ''
sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp
sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp
'' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/Tools.cpp
'';

outputs = [ "out" "lib" "python" ];
Expand Down
18 changes: 12 additions & 6 deletions pkgs/development/compilers/llvm/3.9/libc++/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@ stdenv.mkDerivation rec {
patches = [
# glibc 2.26 fix
./xlocale-glibc-2.26.patch
] ++ lib.optional stdenv.isDarwin ./darwin.patch;
]
++ lib.optional stdenv.isDarwin ./darwin.patch
++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
../../libcxx-0001-musl-hacks.patch
../../libcxx-max_align_t.patch
];

buildInputs = [ cmake libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
nativeBuildInputs = [ cmake ];
buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;

cmakeFlags = [
"-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
"-DLIBCXX_LIBCPPABI_VERSION=2"
"-DLIBCXX_CXX_ABI=libcxxabi"
];
"-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
"-DLIBCXX_LIBCPPABI_VERSION=2"
"-DLIBCXX_CXX_ABI=libcxxabi"
] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1";

enableParallelBuilding = true;

Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/compilers/llvm/3.9/libc++abi.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ stdenv.mkDerivation {
export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_INCLUDES=$PWD/$(ls -d libcxx-*)/include"
'' + stdenv.lib.optionalString stdenv.isDarwin ''
export TRIPLE=x86_64-apple-darwin
'' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch}
patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-max_align_t.patch}
'';

installPhase = if stdenv.isDarwin
Expand Down
15 changes: 13 additions & 2 deletions pkgs/development/compilers/llvm/3.9/llvm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ in stdenv.mkDerivation rec {
url = https://github.com/llvm-mirror/llvm/commit/5340b5b3d970069aebf3dde49d8964583742e01a.patch;
sha256 = "095f8knplwqbc2p7rad1kq8633i34qynni9jna93an7kyc80wdxl";
})
];
] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
../TLI-musl.patch
../dynamiclibrary-musl.patch
];

postPatch = ""
+ ''
Expand Down Expand Up @@ -91,7 +94,7 @@ in stdenv.mkDerivation rec {
substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib
patch -p1 < ./llvm-outputs.patch
''
+ stdenv.lib.optionalString (stdenv ? glibc) ''
+ ''
(
cd projects/compiler-rt
patch -p1 < ${
Expand Down Expand Up @@ -129,6 +132,14 @@ in stdenv.mkDerivation rec {
] ++ stdenv.lib.optionals (buildPlatform != hostPlatform) [
"-DCMAKE_CROSSCOMPILING=True"
"-DLLVM_TABLEGEN=${buildPackages.llvmPackages_39.llvm}/bin/llvm-tblgen"
] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
"-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
"-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}"
"-DTARGET_TRIPLE=${stdenv.targetPlatform.config}"
# Not yet supported
"-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
"-DCOMPILER_RT_BUILD_XRAY=OFF"

];

postBuild = ''
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/llvm/4/libc++/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
./xlocale-glibc-2.26.patch
] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
../../libcxx-0001-musl-hacks.patch
./max_align_t.patch
../../libcxx-max_align_t.patch
];

prePatch = ''
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/llvm/4/libc++abi.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ stdenv.mkDerivation {
export TRIPLE=x86_64-apple-darwin
'' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch}
patch -p1 -d $(ls -d libcxx-*) -i ${./libc++/max_align_t.patch}
patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-max_align_t.patch}
'';

installPhase = if stdenv.isDarwin
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/llvm/4/llvm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ in stdenv.mkDerivation (rec {
patch -p0 < ${../aarch64.patch}
'' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
patch -p1 -i ${../TLI-musl.patch}
patch -p1 -i ${./dynamiclibrary-musl.patch}
patch -p1 -i ${../dynamiclibrary-musl.patch}
patch -p1 -i ${./sanitizers-nongnu.patch} -d projects/compiler-rt
'';

Expand Down