From e876e97ef0dc0b198d8767b8ed999ca37ec5ec00 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Mon, 19 Feb 2018 19:17:34 -0600 Subject: llvm6: musl compat --- pkgs/development/compilers/llvm/6/clang/default.nix | 2 ++ pkgs/development/compilers/llvm/6/libc++/default.nix | 15 +++++++++++---- pkgs/development/compilers/llvm/6/libc++abi.nix | 2 ++ pkgs/development/compilers/llvm/6/llvm.nix | 13 +++++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) (limited to 'pkgs/development/compilers/llvm') diff --git a/pkgs/development/compilers/llvm/6/clang/default.nix b/pkgs/development/compilers/llvm/6/clang/default.nix index a5e639cde6d..2cf5cdb974d 100644 --- a/pkgs/development/compilers/llvm/6/clang/default.nix +++ b/pkgs/development/compilers/llvm/6/clang/default.nix @@ -47,6 +47,8 @@ let # Patch for standalone doc building sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp ''; outputs = [ "out" "lib" "python" ]; diff --git a/pkgs/development/compilers/llvm/6/libc++/default.nix b/pkgs/development/compilers/llvm/6/libc++/default.nix index cd9a7c548fc..5093c268786 100644 --- a/pkgs/development/compilers/llvm/6/libc++/default.nix +++ b/pkgs/development/compilers/llvm/6/libc++/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetch, cmake, llvm, libcxxabi, fixDarwinDylibNames, version }: +{ lib, stdenv, fetch, cmake, python, llvm, libcxxabi, fixDarwinDylibNames, version }: stdenv.mkDerivation rec { name = "libc++-${version}"; @@ -10,6 +10,12 @@ stdenv.mkDerivation rec { export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include" ''; + # on next rebuild, this can be replaced with optionals; for now set to null to avoid + # patches = stdenv.lib.optionals stdenv.hostPlatform.isMusl [ + patches = if stdenv.hostPlatform.isMusl then [ + ../../libcxx-0001-musl-hacks.patch + ] else null; + prePatch = '' substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++" ''; @@ -17,9 +23,10 @@ stdenv.mkDerivation rec { preConfigure = '' # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LIBCXXABI_INCLUDE_DIR") + '' + lib.optionalString stdenv.hostPlatform.isMusl '' + patchShebangs utils/cat_files.py ''; - - nativeBuildInputs = [ cmake ]; + nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python; buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; @@ -27,7 +34,7 @@ stdenv.mkDerivation rec { "-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; diff --git a/pkgs/development/compilers/llvm/6/libc++abi.nix b/pkgs/development/compilers/llvm/6/libc++abi.nix index 0a32e1e33b5..62b6bf58627 100644 --- a/pkgs/development/compilers/llvm/6/libc++abi.nix +++ b/pkgs/development/compilers/llvm/6/libc++abi.nix @@ -14,6 +14,8 @@ stdenv.mkDerivation { export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)" '' + 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} ''; installPhase = if stdenv.isDarwin diff --git a/pkgs/development/compilers/llvm/6/llvm.nix b/pkgs/development/compilers/llvm/6/llvm.nix index 75d096416c1..3fe8d932d04 100644 --- a/pkgs/development/compilers/llvm/6/llvm.nix +++ b/pkgs/development/compilers/llvm/6/llvm.nix @@ -74,6 +74,11 @@ in stdenv.mkDerivation (rec { # Revert compiler-rt commit that makes codesign mandatory patch -p1 -i ${./compiler-rt-codesign.patch} -d projects/compiler-rt + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + patch -p1 -i ${../TLI-musl.patch} + substituteInPlace unittests/Support/CMakeLists.txt \ + --replace "add_subdirectory(DynamicLibrary)" "" + rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp ''; # hacky fix: created binaries need to be run before installation @@ -104,6 +109,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}" + "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}" + "-DTARGET_TRIPLE=${stdenv.targetPlatform.config}" + + "-DCOMPILER_RT_BUILD_SANITIZERS=OFF" + "-DCOMPILER_RT_BUILD_XRAY=OFF" ]; postBuild = '' -- cgit 1.4.1