diff options
Diffstat (limited to 'pkgs/development/compilers')
7 files changed, 63 insertions, 11 deletions
diff --git a/pkgs/development/compilers/gcc/common/platform-flags.nix b/pkgs/development/compilers/gcc/common/platform-flags.nix index ba6d5912fe8..f3cdce41193 100644 --- a/pkgs/development/compilers/gcc/common/platform-flags.nix +++ b/pkgs/development/compilers/gcc/common/platform-flags.nix @@ -4,7 +4,7 @@ let p = targetPlatform.platform.gcc or {} // targetPlatform.parsed.abi; in lib.concatLists [ - (lib.optional (p ? arch) "--with-arch=${p.arch}") + (lib.optional (!targetPlatform.isx86_64 && p ? arch) "--with-arch=${p.arch}") # --with-arch= is unknown flag on x86_64 (lib.optional (p ? cpu) "--with-cpu=${p.cpu}") (lib.optional (p ? abi) "--with-abi=${p.abi}") (lib.optional (p ? fpu) "--with-fpu=${p.fpu}") diff --git a/pkgs/development/compilers/llvm/8/compiler-rt.nix b/pkgs/development/compilers/llvm/8/compiler-rt.nix index 47c8b7bd59f..2b591cc94af 100644 --- a/pkgs/development/compilers/llvm/8/compiler-rt.nix +++ b/pkgs/development/compilers/llvm/8/compiler-rt.nix @@ -19,6 +19,8 @@ stdenv.mkDerivation rec { "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" "-DCOMPILER_RT_BUILD_PROFILE=OFF" "-DCOMPILER_RT_BAREMETAL_BUILD=ON" + #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program + "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY" "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}" ] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [ "-DCOMPILER_RT_BUILD_SANITIZERS=OFF" @@ -53,7 +55,7 @@ stdenv.mkDerivation rec { ''; # Hack around weird upsream RPATH bug - postInstall = stdenv.lib.optionalString stdenv.isDarwin '' + postInstall = stdenv.lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) '' ln -s "$out/lib"/*/* "$out/lib" '' + stdenv.lib.optionalString (stdenv.hostPlatform.useLLVM or false) '' ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o diff --git a/pkgs/development/compilers/llvm/8/default.nix b/pkgs/development/compilers/llvm/8/default.nix index 3503e6b83d2..48cf9e5e589 100644 --- a/pkgs/development/compilers/llvm/8/default.nix +++ b/pkgs/development/compilers/llvm/8/default.nix @@ -97,13 +97,17 @@ let targetLlvmLibraries.libcxx targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt + ] ++ stdenv.lib.optionals (!stdenv.targetPlatform.isWasm) [ targetLlvmLibraries.libunwind ]; extraBuildCommands = '' echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags + '' + stdenv.lib.optionalString (!stdenv.targetPlatform.isWasm) '' echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags + '' + stdenv.lib.optionalString stdenv.targetPlatform.isWasm '' + echo "-fno-exceptions" >> $out/nix-support/cc-cflags '' + mkExtraBuildCommands cc; }; diff --git a/pkgs/development/compilers/llvm/8/libc++/default.nix b/pkgs/development/compilers/llvm/8/libc++/default.nix index d0a5c37c414..3d67c37dcdd 100644 --- a/pkgs/development/compilers/llvm/8/libc++/default.nix +++ b/pkgs/development/compilers/llvm/8/libc++/default.nix @@ -1,4 +1,5 @@ -{ lib, stdenv, fetch, cmake, python, libcxxabi, fixDarwinDylibNames, version }: +{ lib, stdenv, fetch, cmake, python, libcxxabi, fixDarwinDylibNames, version +, enableShared ? true }: stdenv.mkDerivation rec { name = "libc++-${version}"; @@ -22,7 +23,8 @@ stdenv.mkDerivation rec { '' + lib.optionalString stdenv.hostPlatform.isMusl '' patchShebangs utils/cat_files.py ''; - nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python; + nativeBuildInputs = [ cmake ] + ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) python; buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; @@ -30,8 +32,13 @@ 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" - ++ stdenv.lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"; + ] ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" + ++ stdenv.lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON" + ++ stdenv.lib.optional stdenv.hostPlatform.isWasm [ + "-DLIBCXX_ENABLE_THREADS=OFF" + "-DLIBCXX_ENABLE_FILESYSTEM=OFF" + "-DLIBCXX_ENABLE_EXCEPTIONS=OFF" + ] ++ stdenv.lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"; enableParallelBuilding = true; @@ -46,6 +53,6 @@ stdenv.mkDerivation rec { homepage = http://libcxx.llvm.org/; description = "A new implementation of the C++ standard library, targeting C++11"; license = with stdenv.lib.licenses; [ ncsa mit ]; - platforms = stdenv.lib.platforms.unix; + platforms = stdenv.lib.platforms.all; }; } diff --git a/pkgs/development/compilers/llvm/8/libc++abi.nix b/pkgs/development/compilers/llvm/8/libc++abi.nix index 0eb5ebca515..bb5b368267f 100644 --- a/pkgs/development/compilers/llvm/8/libc++abi.nix +++ b/pkgs/development/compilers/llvm/8/libc++abi.nix @@ -1,4 +1,5 @@ -{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }: +{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version +, enableShared ? true }: stdenv.mkDerivation { name = "libc++abi-${version}"; @@ -6,13 +7,20 @@ stdenv.mkDerivation { src = fetch "libcxxabi" "1k875f977ybdkpdnr9105wa6hccy9qvpd9xd42n75h7p56bdxmn2"; nativeBuildInputs = [ cmake ]; - buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind; + buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind; cmakeFlags = stdenv.lib.optionals (stdenv.hostPlatform.useLLVM or false) [ "-DLLVM_ENABLE_LIBCXX=ON" "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" + ] ++ stdenv.lib.optionals stdenv.hostPlatform.isWasm [ + "-DLIBCXXABI_ENABLE_THREADS=OFF" + "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF" + ] ++ stdenv.lib.optionals (!enableShared) [ + "-DLIBCXXABI_ENABLE_SHARED=OFF" ]; + patches = [ ./libcxxabi-no-threads.patch ]; + postUnpack = '' unpackFile ${libcxx.src} unpackFile ${llvm.src} @@ -21,6 +29,8 @@ 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} + '' + stdenv.lib.optionalString stdenv.hostPlatform.isWasm '' + patch -p1 -d $(ls -d llvm-*) -i ${./libcxxabi-wasm.patch} ''; installPhase = if stdenv.isDarwin @@ -39,8 +49,9 @@ stdenv.mkDerivation { else '' install -d -m 755 $out/include $out/lib install -m 644 lib/libc++abi.a $out/lib - install -m 644 lib/libc++abi.so.1.0 $out/lib install -m 644 ../include/cxxabi.h $out/include + '' + stdenv.lib.optionalString enableShared '' + install -m 644 lib/libc++abi.so.1.0 $out/lib ln -s libc++abi.so.1.0 $out/lib/libc++abi.so ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 ''; @@ -50,6 +61,6 @@ stdenv.mkDerivation { description = "A new implementation of low level support for a standard C++ library"; license = with stdenv.lib.licenses; [ ncsa mit ]; maintainers = with stdenv.lib.maintainers; [ vlstill ]; - platforms = stdenv.lib.platforms.unix; + platforms = stdenv.lib.platforms.all; }; } diff --git a/pkgs/development/compilers/llvm/8/libcxxabi-no-threads.patch b/pkgs/development/compilers/llvm/8/libcxxabi-no-threads.patch new file mode 100644 index 00000000000..787f3e16500 --- /dev/null +++ b/pkgs/development/compilers/llvm/8/libcxxabi-no-threads.patch @@ -0,0 +1,12 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4138acf..41b4763 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -362,6 +362,7 @@ if (NOT LIBCXXABI_ENABLE_THREADS) + " is also set to ON.") + endif() + add_definitions(-D_LIBCXXABI_HAS_NO_THREADS) ++ add_definitions(-D_LIBCPP_HAS_NO_THREADS) + endif() + + if (LIBCXXABI_HAS_EXTERNAL_THREAD_API) diff --git a/pkgs/development/compilers/llvm/8/libcxxabi-wasm.patch b/pkgs/development/compilers/llvm/8/libcxxabi-wasm.patch new file mode 100644 index 00000000000..4ebfe46aa81 --- /dev/null +++ b/pkgs/development/compilers/llvm/8/libcxxabi-wasm.patch @@ -0,0 +1,16 @@ +diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake +index 15497d405e0..33f7f18193a 100644 +--- a/cmake/modules/HandleLLVMOptions.cmake ++++ b/cmake/modules/HandleLLVMOptions.cmake +@@ -127,7 +127,10 @@ else(WIN32) + set(LLVM_HAVE_LINK_VERSION_SCRIPT 1) + endif() + else(FUCHSIA OR UNIX) +- MESSAGE(SEND_ERROR "Unable to determine platform") ++ if(${CMAKE_SYSTEM_NAME} MATCHES "Wasi") ++ else() ++ MESSAGE(SEND_ERROR "Unable to determine platform") ++ endif() + endif(FUCHSIA OR UNIX) + endif(WIN32) + |