Merge pull request #246577 from pwaller/pkgsLLVM-16

authored by Ryan Lahfa and committed by GitHub 30ebda75 fa798818

+119 -17
+16 -4
pkgs/development/compilers/llvm/15/libcxx/default.nix
··· 2 2 , monorepoSrc, runCommand 3 3 , cmake, ninja, python3, fixDarwinDylibNames, version 4 4 , cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi 5 - , libcxxabi, libcxxrt 5 + , libcxxabi, libcxxrt, libunwind 6 6 , enableShared ? !stdenv.hostPlatform.isStatic 7 7 8 8 # If headersOnly is true, the resulting package would only include the headers. ··· 62 62 nativeBuildInputs = [ cmake ninja python3 ] 63 63 ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; 64 64 65 - buildInputs = lib.optionals (!headersOnly) [ cxxabi ]; 65 + buildInputs = 66 + lib.optionals (!headersOnly) [ cxxabi ] 67 + ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ libunwind ]; 66 68 67 69 cmakeFlags = let 68 70 # See: https://libcxx.llvm.org/BuildingLibcxx.html#cmdoption-arg-libcxx-cxx-abi-string ··· 75 77 "-DLIBCXX_CXX_ABI=${if headersOnly then "none" else libcxx_cxx_abi_opt}" 76 78 ] ++ lib.optional (!headersOnly && cxxabi.libName == "c++abi") "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi.dev}/include/c++/v1" 77 79 ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" 78 - ++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON" 79 - ++ lib.optionals stdenv.hostPlatform.isWasm [ 80 + ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ 81 + "-DLIBCXX_USE_COMPILER_RT=ON" 82 + # (Backport fix from 16, which has LIBCXX_ADDITIONAL_LIBRARIES, but 15 83 + # does not appear to) 84 + # There's precedent for this in llvm-project/libcxx/cmake/caches. 85 + # In a monorepo build you might do the following in the libcxxabi build: 86 + # -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwind 87 + # -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On 88 + # libcxx appears to require unwind and doesn't pull it in via other means. 89 + # "-DLIBCXX_ADDITIONAL_LIBRARIES=unwind" 90 + "-DCMAKE_SHARED_LINKER_FLAGS=-lunwind" 91 + ] ++ lib.optionals stdenv.hostPlatform.isWasm [ 80 92 "-DLIBCXX_ENABLE_THREADS=OFF" 81 93 "-DLIBCXX_ENABLE_FILESYSTEM=OFF" 82 94 "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
+7
pkgs/development/compilers/llvm/15/libcxxabi/default.nix
··· 68 68 ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ 69 69 "-DLLVM_ENABLE_LIBCXX=ON" 70 70 "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" 71 + ] ++ lib.optionals ((stdenv.hostPlatform.useLLVM or false) || 72 + (stdenv.hostPlatform.isDarwin && enableShared)) [ 73 + # libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib, 74 + # but that does not appear to be the case for example when building 75 + # pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc). 76 + "-DCMAKE_EXE_LINKER_FLAGS=-nostdlib" 77 + "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib" 71 78 ] ++ lib.optionals stdenv.hostPlatform.isWasm [ 72 79 "-DLIBCXXABI_ENABLE_THREADS=OFF" 73 80 "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
+5
pkgs/development/compilers/llvm/15/libunwind/default.nix
··· 40 40 cd ../runtimes 41 41 ''; 42 42 43 + postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) '' 44 + # libcxxabi wants to link to libunwind_shared.so (?). 45 + ln -s $out/lib/libunwind.so $out/lib/libunwind_shared.so 46 + ''; 47 + 43 48 outputs = [ "out" "dev" ]; 44 49 45 50 nativeBuildInputs = [ cmake ninja python3 ];
+16 -3
pkgs/development/compilers/llvm/16/compiler-rt/default.nix
··· 32 32 ++ lib.optional stdenv.isDarwin xcbuild.xcrun; 33 33 buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; 34 34 35 - env.NIX_CFLAGS_COMPILE = toString [ 35 + env.NIX_CFLAGS_COMPILE = toString ([ 36 36 "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0" 37 - ]; 37 + ] ++ lib.optionals (!haveLibc) [ 38 + # The compiler got stricter about this, and there is a usellvm patch below 39 + # which patches out the assert include causing an implicit definition of 40 + # assert. It would be nicer to understand why compiler-rt thinks it should 41 + # be able to #include <assert.h> in the first place; perhaps it's in the 42 + # wrong, or perhaps there is a way to provide an assert.h. 43 + "-Wno-error=implicit-function-declaration" 44 + ]); 38 45 39 46 cmakeFlags = [ 40 47 "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON" ··· 102 109 '' + lib.optionalString stdenv.isDarwin '' 103 110 substituteInPlace cmake/config-ix.cmake \ 104 111 --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' 105 - '' + lib.optionalString (useLLVM) '' 112 + '' + lib.optionalString (useLLVM && !haveLibc) '' 106 113 substituteInPlace lib/builtins/int_util.c \ 107 114 --replace "#include <stdlib.h>" "" 108 115 substituteInPlace lib/builtins/clear_cache.c \ ··· 117 124 '' + lib.optionalString (useLLVM) '' 118 125 ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o 119 126 ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o 127 + # Note the history of crt{begin,end}S in previous versions of llvm in nixpkg: 128 + # The presence of crtbegin_shared has been added and removed; it's possible 129 + # people have added/removed it to get it working on their platforms. 130 + # Try each in turn for now. 131 + ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbeginS.o 132 + ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtendS.o 120 133 ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o 121 134 ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o 122 135 '' + lib.optionalString doFakeLibgcc ''
+8
pkgs/development/compilers/llvm/16/default.nix
··· 254 254 [ "-rtlib=compiler-rt" 255 255 "-Wno-unused-command-line-argument" 256 256 "-B${targetLlvmLibraries.compiler-rt}/lib" 257 + 258 + # Combat "__cxxabi_config.h not found". Maybe this could be fixed by 259 + # copying these headers into libcxx? Note that building libcxx 260 + # outside of monorepo isn't supported anymore, might be related to 261 + # https://github.com/llvm/llvm-project/issues/55632 262 + # ("16.0.3 libcxx, libcxxabi: circular build dependencies") 263 + # Looks like the machinery changed in https://reviews.llvm.org/D120727. 264 + "-I${lib.getDev targetLlvmLibraries.libcxx.cxxabi}/include/c++/v1" 257 265 ] 258 266 ++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind" 259 267 ++ lib.optional
+13 -6
pkgs/development/compilers/llvm/16/libcxx/default.nix
··· 2 2 , monorepoSrc, runCommand 3 3 , cmake, ninja, python3, fixDarwinDylibNames, version 4 4 , cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi 5 - , libcxxabi, libcxxrt 5 + , libcxxabi, libcxxrt, libunwind 6 6 , enableShared ? !stdenv.hostPlatform.isStatic 7 7 8 8 # If headersOnly is true, the resulting package would only include the headers. ··· 47 47 48 48 patches = [ 49 49 ./gnu-install-dirs.patch 50 - ] ++ lib.optionals stdenv.hostPlatform.isMusl [ 51 - ../../libcxx-0001-musl-hacks.patch 52 50 ]; 53 51 54 52 postPatch = '' ··· 62 60 nativeBuildInputs = [ cmake ninja python3 ] 63 61 ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; 64 62 65 - buildInputs = lib.optionals (!headersOnly) [ cxxabi ]; 63 + buildInputs = 64 + lib.optionals (!headersOnly) [ cxxabi ] 65 + ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ libunwind ]; 66 66 67 67 cmakeFlags = let 68 68 # See: https://libcxx.llvm.org/BuildingLibcxx.html#cmdoption-arg-libcxx-cxx-abi-string ··· 75 75 "-DLIBCXX_CXX_ABI=${if headersOnly then "none" else libcxx_cxx_abi_opt}" 76 76 ] ++ lib.optional (!headersOnly && cxxabi.libName == "c++abi") "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi.dev}/include/c++/v1" 77 77 ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" 78 - ++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON" 79 - ++ lib.optionals stdenv.hostPlatform.isWasm [ 78 + ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ 79 + "-DLIBCXX_USE_COMPILER_RT=ON" 80 + # There's precedent for this in llvm-project/libcxx/cmake/caches. 81 + # In a monorepo build you might do the following in the libcxxabi build: 82 + # -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder 83 + # -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On 84 + # libcxx appears to require unwind and doesn't pull it in via other means. 85 + "-DLIBCXX_ADDITIONAL_LIBRARIES=unwind" 86 + ] ++ lib.optionals stdenv.hostPlatform.isWasm [ 80 87 "-DLIBCXX_ENABLE_THREADS=OFF" 81 88 "-DLIBCXX_ENABLE_FILESYSTEM=OFF" 82 89 "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
+7
pkgs/development/compilers/llvm/16/libcxxabi/default.nix
··· 68 68 ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ 69 69 "-DLLVM_ENABLE_LIBCXX=ON" 70 70 "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" 71 + ] ++ lib.optionals ((stdenv.hostPlatform.useLLVM or false) || 72 + (stdenv.hostPlatform.isDarwin && enableShared)) [ 73 + # libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib, 74 + # but that does not appear to be the case for example when building 75 + # pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc). 76 + "-DCMAKE_EXE_LINKER_FLAGS=-nostdlib" 77 + "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib" 71 78 ] ++ lib.optionals stdenv.hostPlatform.isWasm [ 72 79 "-DLIBCXXABI_ENABLE_THREADS=OFF" 73 80 "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
+5
pkgs/development/compilers/llvm/16/libunwind/default.nix
··· 40 40 cd ../runtimes 41 41 ''; 42 42 43 + postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) '' 44 + # libcxxabi wants to link to libunwind_shared.so (?). 45 + ln -s $out/lib/libunwind.so $out/lib/libunwind_shared.so 46 + ''; 47 + 43 48 outputs = [ "out" "dev" ]; 44 49 45 50 nativeBuildInputs = [ cmake ninja python3 ];
+13
pkgs/development/compilers/llvm/git/default.nix
··· 313 313 # what stdenv we use here, as long as CMake is happy. 314 314 cxx-headers = callPackage ./libcxx { 315 315 inherit llvm_meta; 316 + # Note that if we use the regular stdenv here we'll get cycle errors 317 + # when attempting to use this compiler in the stdenv. 318 + # 319 + # The final stdenv pulls `cxx-headers` from the package set where 320 + # hostPlatform *is* the target platform which means that `stdenv` at 321 + # that point attempts to use this toolchain. 322 + # 323 + # So, we use `stdenv_` (the stdenv containing `clang` from this package 324 + # set, defined below) to sidestep this issue. 325 + # 326 + # Because we only use `cxx-headers` in `libcxxabi` (which depends on the 327 + # clang stdenv _anyways_), this is okay. 328 + stdenv = stdenv_; 316 329 headersOnly = true; 317 330 }; 318 331
+17 -4
pkgs/development/compilers/llvm/git/libcxx/default.nix
··· 2 2 , monorepoSrc, runCommand 3 3 , cmake, ninja, python3, fixDarwinDylibNames, version 4 4 , cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi 5 - , libcxxabi, libcxxrt 5 + , libcxxabi, libcxxrt, libunwind 6 6 , enableShared ? !stdenv.hostPlatform.isStatic 7 7 8 8 # If headersOnly is true, the resulting package would only include the headers. ··· 62 62 nativeBuildInputs = [ cmake ninja python3 ] 63 63 ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; 64 64 65 - buildInputs = lib.optionals (!headersOnly) [ cxxabi ]; 65 + buildInputs = 66 + lib.optionals (!headersOnly) [ cxxabi ] 67 + ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ libunwind ]; 68 + 66 69 67 70 cmakeFlags = let 68 71 # See: https://libcxx.llvm.org/BuildingLibcxx.html#cmdoption-arg-libcxx-cxx-abi-string ··· 75 78 "-DLIBCXX_CXX_ABI=${if headersOnly then "none" else libcxx_cxx_abi_opt}" 76 79 ] ++ lib.optional (!headersOnly && cxxabi.libName == "c++abi") "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi.dev}/include/c++/v1" 77 80 ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" 78 - ++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON" 79 - ++ lib.optionals stdenv.hostPlatform.isWasm [ 81 + ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ 82 + "-DLIBCXX_USE_COMPILER_RT=ON" 83 + # (Backport fix from 16, which has LIBCXX_ADDITIONAL_LIBRARIES, but 15 84 + # does not appear to) 85 + # There's precedent for this in llvm-project/libcxx/cmake/caches. 86 + # In a monorepo build you might do the following in the libcxxabi build: 87 + # -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder 88 + # -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On 89 + # libcxx appears to require unwind and doesn't pull it in via other means. 90 + # "-DLIBCXX_ADDITIONAL_LIBRARIES=unwind" 91 + "-DCMAKE_SHARED_LINKER_FLAGS=-lunwind" 92 + ] ++ lib.optionals stdenv.hostPlatform.isWasm [ 80 93 "-DLIBCXX_ENABLE_THREADS=OFF" 81 94 "-DLIBCXX_ENABLE_FILESYSTEM=OFF" 82 95 "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
+7
pkgs/development/compilers/llvm/git/libcxxabi/default.nix
··· 68 68 ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ 69 69 "-DLLVM_ENABLE_LIBCXX=ON" 70 70 "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" 71 + ] ++ lib.optionals ((stdenv.hostPlatform.useLLVM or false) || 72 + (stdenv.hostPlatform.isDarwin && enableShared)) [ 73 + # libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib, 74 + # but that does not appear to be the case for example when building 75 + # pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc). 76 + "-DCMAKE_EXE_LINKER_FLAGS=-nostdlib" 77 + "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib" 71 78 ] ++ lib.optionals stdenv.hostPlatform.isWasm [ 72 79 "-DLIBCXXABI_ENABLE_THREADS=OFF" 73 80 "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
+5
pkgs/development/compilers/llvm/git/libunwind/default.nix
··· 40 40 cd ../runtimes 41 41 ''; 42 42 43 + postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) '' 44 + # libcxxabi wants to link to libunwind_shared.so (?). 45 + ln -s $out/lib/libunwind.so $out/lib/libunwind_shared.so 46 + ''; 47 + 43 48 outputs = [ "out" "dev" ]; 44 49 45 50 nativeBuildInputs = [ cmake ninja python3 ];