git.iko.soy/typeable/nixpkgs
on master help sign in
llvm6: musl compat
commite876e97ef0dc0b198d8767b8ed999ca37ec5ec00 authorWill Dietz <w@wdtz.org> dateMon 19 Feb 2018, 19:17 (9 years ago) parentab0a72a
4 files changed+28−4
pkgs/development/compilers/llvm/6/clang/default.nix+2 pkgs/development/compilers/llvm/6/libc++/default.nix+11−4 pkgs/development/compilers/llvm/6/libc++abi.nix+2 pkgs/development/compilers/llvm/6/llvm.nix+13
pkgs/development/compilers/llvm/6/clang/default.nix+2
@@ -47,6 +47,8 @@ let
4747
4848 # Patch for standalone doc building
4949 sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt
50+ '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
51+ sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
5052 '';
5153
5254 outputs = [ "out" "lib" "python" ];
pkgs/development/compilers/llvm/6/libc++/default.nix+11−4
@@ -1,4 +1,4 @@
1−{ lib, stdenv, fetch, cmake, llvm, libcxxabi, fixDarwinDylibNames, version }:
1+{ lib, stdenv, fetch, cmake, python, llvm, libcxxabi, fixDarwinDylibNames, version }:
22
33stdenv.mkDerivation rec {
44 name = "libc++-${version}";
@@ -10,6 +10,12 @@ stdenv.mkDerivation rec {
1010 export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include"
1111 '';
1212
13+ # on next rebuild, this can be replaced with optionals; for now set to null to avoid
14+ # patches = stdenv.lib.optionals stdenv.hostPlatform.isMusl [
15+ patches = if stdenv.hostPlatform.isMusl then [
16+ ../../libcxx-0001-musl-hacks.patch
17+ ] else null;
18+
1319 prePatch = ''
1420 substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++"
1521 '';
@@ -17,9 +23,10 @@ stdenv.mkDerivation rec {
1723 preConfigure = ''
1824 # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package
1925 cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LIBCXXABI_INCLUDE_DIR")
26+ '' + lib.optionalString stdenv.hostPlatform.isMusl ''
27+ patchShebangs utils/cat_files.py
2028 '';
21−
22− nativeBuildInputs = [ cmake ];
29+ nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python;
2330
2431 buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
2532
@@ -27,7 +34,7 @@ stdenv.mkDerivation rec {
2734 "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
2835 "-DLIBCXX_LIBCPPABI_VERSION=2"
2936 "-DLIBCXX_CXX_ABI=libcxxabi"
30− ];
37+ ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1";
3138
3239 enableParallelBuilding = true;
3340
pkgs/development/compilers/llvm/6/libc++abi.nix+2
@@ -14,6 +14,8 @@ stdenv.mkDerivation {
1414 export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)"
1515 '' + stdenv.lib.optionalString stdenv.isDarwin ''
1616 export TRIPLE=x86_64-apple-darwin
17+ '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
18+ patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch}
1719 '';
1820
1921 installPhase = if stdenv.isDarwin
pkgs/development/compilers/llvm/6/llvm.nix+13
@@ -74,6 +74,11 @@ in stdenv.mkDerivation (rec {
7474
7575 # Revert compiler-rt commit that makes codesign mandatory
7676 patch -p1 -i ${./compiler-rt-codesign.patch} -d projects/compiler-rt
77+ '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
78+ patch -p1 -i ${../TLI-musl.patch}
79+ substituteInPlace unittests/Support/CMakeLists.txt \
80+ --replace "add_subdirectory(DynamicLibrary)" ""
81+ rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
7782 '';
7883
7984 # hacky fix: created binaries need to be run before installation
@@ -104,6 +109,14 @@ in stdenv.mkDerivation (rec {
104109 ++ stdenv.lib.optionals (isDarwin) [
105110 "-DLLVM_ENABLE_LIBCXX=ON"
106111 "-DCAN_TARGET_i386=false"
112+ ]
113+ ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
114+ "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
115+ "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}"
116+ "-DTARGET_TRIPLE=${stdenv.targetPlatform.config}"
117+
118+ "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
119+ "-DCOMPILER_RT_BUILD_XRAY=OFF"
107120 ];
108121
109122 postBuild = ''