diff options
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/llvm/git')
23 files changed, 303 insertions, 385 deletions
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/clang/default.nix index 733f5462d320..b193ebba3d6d 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/clang/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/git/clang/default.nix @@ -1,6 +1,6 @@ { lib, stdenv, llvm_meta , monorepoSrc, runCommand -, substituteAll, cmake, ninja, libxml2, libllvm, version, python3 +, cmake, ninja, libxml2, libllvm, version, python3 , buildLlvmTools , fixDarwinDylibNames , enableManpages ? false @@ -30,6 +30,7 @@ let "-DCLANG_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/clang" "-DCLANGD_BUILD_XPC=OFF" "-DLLVM_ENABLE_RTTI=ON" + "-DLLVM_INCLUDE_TESTS=OFF" ] ++ lib.optionals enableManpages [ "-DCLANG_INCLUDE_DOCS=ON" "-DLLVM_ENABLE_SPHINX=ON" @@ -51,10 +52,11 @@ let # https://reviews.llvm.org/D51899 ./gnu-install-dirs.patch ../../common/clang/add-nostdlibinc-flag.patch - (substituteAll { - src = ../../clang-11-12-LLVMgold-path.patch; - libllvmLibdir = "${libllvm.lib}/lib"; - }) + # FIMXE: do we need this patch? + # (substituteAll { + # src = ../../clang-11-12-LLVMgold-path.patch; + # libllvmLibdir = "${libllvm.lib}/lib"; + # }) ]; postPatch = '' @@ -65,15 +67,12 @@ let outputs = [ "out" "lib" "dev" "python" ]; - env = lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { - # The following warning is triggered with (at least) gcc >= - # 12, but appears to occur only for cross compiles. - NIX_CFLAGS_COMPILE = "-Wno-maybe-uninitialized"; - }; - postInstall = '' ln -sv $out/bin/clang $out/bin/cpp + mkdir -p $lib/lib/clang + mv $lib/lib/18 $lib/lib/clang/18 + # Move libclang to 'lib' output moveToOutput "lib/libclang.*" "$lib" moveToOutput "lib/libclang-cpp.*" "$lib" @@ -81,13 +80,12 @@ let --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." - mkdir -p $python/bin $python/share/{clang,scan-view} + mkdir -p $python/bin $python/share/clang/ mv $out/bin/{git-clang-format,scan-view} $python/bin if [ -e $out/bin/set-xcode-analyzer ]; then mv $out/bin/set-xcode-analyzer $python/bin fi mv $out/share/clang/*.py $python/share/clang - mv $out/share/scan-view/*.py $python/share/scan-view rm $out/bin/c-index-test patchShebangs $python/bin diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/clang/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/git/clang/gnu-install-dirs.patch index f767c56836d5..cc8737f35343 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/clang/gnu-install-dirs.patch +++ b/nixpkgs/pkgs/development/compilers/llvm/git/clang/gnu-install-dirs.patch @@ -1,38 +1,32 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index c27beec313d7..480f13e73c9f 100644 +index f7936d72e088..a362fa49b534 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -78,15 +78,17 @@ if(CLANG_BUILT_STANDALONE) - if (NOT LLVM_CONFIG_FOUND) - # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config - # path is removed. -- set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}") +@@ -31,7 +31,21 @@ if(CLANG_BUILT_STANDALONE) + find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}") + list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}") + +- # Turn into CACHE PATHs for overwritting ++ # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets ++ # LLVM_CONFIG. ++ if (NOT LLVM_CONFIG_FOUND) ++ # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config ++ # path is removed. + set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS}) - set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}") - # N.B. this is just a default value, the CACHE PATHs below can be overriden. - set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm") - set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}") - set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}") ++ set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}") ++ # N.B. this is just a default value, the CACHE PATHs below can be overriden. ++ set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm") ++ set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}") ++ set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}") + else() + set(INCLUDE_DIRS "${LLVM_BINARY_DIR}/include" "${MAIN_INCLUDE_DIR}") - endif() - -- set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to llvm/include") -+ set(LLVM_INCLUDE_DIRS ${INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed") - set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree") - set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree") - set(LLVM_TOOLS_BINARY_DIR "${TOOLS_BINARY_DIR}" CACHE PATH "Path to llvm/bin") -@@ -128,7 +130,7 @@ if(CLANG_BUILT_STANDALONE) - set(LLVM_INCLUDE_TESTS ON) - endif() - -- include_directories("${LLVM_BINARY_DIR}/include" "${LLVM_MAIN_INCLUDE_DIR}") -+ include_directories(${LLVM_INCLUDE_DIRS}) - link_directories("${LLVM_LIBRARY_DIR}") - - set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) ++ endif() ++ + set(LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed") + set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}" CACHE PATH "Path to LLVM build tree") + set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path to LLVM source tree") diff --git a/cmake/modules/AddClang.cmake b/cmake/modules/AddClang.cmake -index 21ac332e4f5f..b16c314bd1e2 100644 +index 75b0080f6715..c895b884cd27 100644 --- a/cmake/modules/AddClang.cmake +++ b/cmake/modules/AddClang.cmake @@ -119,8 +119,8 @@ macro(add_clang_library name) @@ -47,23 +41,22 @@ index 21ac332e4f5f..b16c314bd1e2 100644 if (NOT LLVM_ENABLE_IDE) diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt -index 6e2060991b92..b9bc930d26b8 100644 +index f2b0c5cddcbb..52f37fc368ce 100644 --- a/lib/Headers/CMakeLists.txt +++ b/lib/Headers/CMakeLists.txt -@@ -420,7 +420,7 @@ add_header_target("openmp-resource-headers" ${openmp_wrapper_files}) - add_header_target("windows-resource-headers" ${windows_only_files}) +@@ -473,6 +473,7 @@ add_header_target("windows-resource-headers" ${windows_only_files}) add_header_target("utility-resource-headers" ${utility_files}) --set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include) -+set(header_install_dir ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include) + get_clang_resource_dir(header_install_dir SUBDIR include) ++set(header_install_dir ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${CLANG_VERSION_MAJOR}/include) ############################################################# # Install rules for the catch-all clang-resource-headers target diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt -index 8d95d0900e8c..ebc70ff7526d 100644 +index 4f23065a2472..6a0f55991e24 100644 --- a/tools/libclang/CMakeLists.txt +++ b/tools/libclang/CMakeLists.txt -@@ -180,7 +180,7 @@ foreach(PythonVersion ${CLANG_PYTHON_BINDINGS_VERSIONS}) +@@ -234,7 +234,7 @@ foreach(PythonVersion ${CLANG_PYTHON_BINDINGS_VERSIONS}) COMPONENT libclang-python-bindings DESTINATION @@ -73,14 +66,14 @@ index 8d95d0900e8c..ebc70ff7526d 100644 if(NOT LLVM_ENABLE_IDE) add_custom_target(libclang-python-bindings) diff --git a/tools/scan-build-py/CMakeLists.txt b/tools/scan-build-py/CMakeLists.txt -index 061dc7ef4dd9..adc54b2edc32 100644 +index 3aca22c0b0a8..3115353e3fe3 100644 --- a/tools/scan-build-py/CMakeLists.txt +++ b/tools/scan-build-py/CMakeLists.txt @@ -88,7 +88,7 @@ foreach(lib ${LibScanbuild}) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/${lib}) list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libscanbuild/${lib}) - install(PROGRAMS lib/libscanbuild/${lib} -- DESTINATION lib/libscanbuild + install(FILES lib/libscanbuild/${lib} +- DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libscanbuild + DESTINATION "${CMAKE_INSTALL_LIBDIR}/libscanbuild" COMPONENT scan-build-py) endforeach() @@ -88,8 +81,8 @@ index 061dc7ef4dd9..adc54b2edc32 100644 @@ -106,7 +106,7 @@ foreach(resource ${LibScanbuildResources}) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/resources/${resource}) list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libscanbuild/resources/${resource}) - install(PROGRAMS lib/libscanbuild/resources/${resource} -- DESTINATION lib/libscanbuild/resources + install(FILES lib/libscanbuild/resources/${resource} +- DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libscanbuild/resources + DESTINATION "${CMAKE_INSTALL_LIBDIR}/libscanbuild/resources" COMPONENT scan-build-py) endforeach() @@ -97,8 +90,8 @@ index 061dc7ef4dd9..adc54b2edc32 100644 @@ -122,7 +122,7 @@ foreach(lib ${LibEar}) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libear/${lib}) list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libear/${lib}) - install(PROGRAMS lib/libear/${lib} -- DESTINATION lib/libear + install(FILES lib/libear/${lib} +- DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libear + DESTINATION "${CMAKE_INSTALL_LIBDIR}/libear" COMPONENT scan-build-py) endforeach() diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/codesign.patch b/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/codesign.patch deleted file mode 100644 index 065959d14d46..000000000000 --- a/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/codesign.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 3dec5f3475a26aeb4678627795c4b67c6b7b4785 Mon Sep 17 00:00:00 2001 -From: Will Dietz <w@wdtz.org> -Date: Tue, 19 Sep 2017 13:13:06 -0500 -Subject: [PATCH] remove codesign use on Apple, disable ios sim testing that - needs it - ---- - cmake/Modules/AddCompilerRT.cmake | 8 ------ - test/asan/CMakeLists.txt | 52 --------------------------------------- - test/tsan/CMakeLists.txt | 47 ----------------------------------- - 3 files changed, 107 deletions(-) - -diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake -index bc69ec95c419..9f100fdcec2f 100644 ---- a/cmake/Modules/AddCompilerRT.cmake -+++ b/cmake/Modules/AddCompilerRT.cmake -@@ -366,14 +366,6 @@ function(add_compiler_rt_runtime name type) - set_target_properties(${libname} PROPERTIES IMPORT_PREFIX "") - set_target_properties(${libname} PROPERTIES IMPORT_SUFFIX ".lib") - endif() -- if(APPLE) -- # Ad-hoc sign the dylibs -- add_custom_command(TARGET ${libname} -- POST_BUILD -- COMMAND codesign --sign - $<TARGET_FILE:${libname}> -- WORKING_DIRECTORY ${COMPILER_RT_OUTPUT_LIBRARY_DIR} -- ) -- endif() - endif() - - set(parent_target_arg) -2.14.1 - diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/default.nix index b20796ab02ab..7add8fab0f91 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/default.nix @@ -9,6 +9,7 @@ let useLLVM = stdenv.hostPlatform.useLLVM or false; bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none"; haveLibc = stdenv.cc.libc != null; + isDarwinStatic = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isStatic; inherit (stdenv.hostPlatform) isMusl; baseName = "compiler-rt"; @@ -31,9 +32,16 @@ stdenv.mkDerivation { ++ lib.optional stdenv.isDarwin xcbuild.xcrun; buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; - env.NIX_CFLAGS_COMPILE = toString [ + env.NIX_CFLAGS_COMPILE = toString ([ "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0" - ]; + ] ++ lib.optionals (!haveLibc) [ + # The compiler got stricter about this, and there is a usellvm patch below + # which patches out the assert include causing an implicit definition of + # assert. It would be nicer to understand why compiler-rt thinks it should + # be able to #include <assert.h> in the first place; perhaps it's in the + # wrong, or perhaps there is a way to provide an assert.h. + "-Wno-error=implicit-function-declaration" + ]); cmakeFlags = [ "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON" @@ -41,19 +49,22 @@ stdenv.mkDerivation { "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}" ] ++ lib.optionals (haveLibc && stdenv.hostPlatform.libc == "glibc") [ "-DSANITIZER_COMMON_CFLAGS=-I${libxcrypt}/include" - ] ++ lib.optionals (useLLVM || bareMetal || isMusl) [ + ] ++ lib.optionals (useLLVM || bareMetal || isMusl || isDarwinStatic) [ "-DCOMPILER_RT_BUILD_SANITIZERS=OFF" "-DCOMPILER_RT_BUILD_XRAY=OFF" "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" "-DCOMPILER_RT_BUILD_MEMPROF=OFF" "-DCOMPILER_RT_BUILD_ORC=OFF" # may be possible to build with musl if necessary ] ++ lib.optionals (useLLVM || bareMetal) [ - "-DCOMPILER_RT_BUILD_PROFILE=OFF" + "-DCOMPILER_RT_BUILD_PROFILE=OFF" + ] ++ lib.optionals ((useLLVM && !haveLibc) || bareMetal || isDarwinStatic ) [ + "-DCMAKE_CXX_COMPILER_WORKS=ON" ] ++ lib.optionals ((useLLVM && !haveLibc) || bareMetal) [ "-DCMAKE_C_COMPILER_WORKS=ON" - "-DCMAKE_CXX_COMPILER_WORKS=ON" "-DCOMPILER_RT_BAREMETAL_BUILD=ON" "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}" + ] ++ lib.optionals (useLLVM && !haveLibc) [ + "-DCMAKE_C_FLAGS=-nodefaultlibs" ] ++ lib.optionals (useLLVM) [ "-DCOMPILER_RT_BUILD_BUILTINS=ON" #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program @@ -61,18 +72,16 @@ stdenv.mkDerivation { ] ++ lib.optionals (bareMetal) [ "-DCOMPILER_RT_OS_DIR=baremetal" ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [ + "-DCMAKE_LIPO=${lib.getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}lipo" "-DDARWIN_macosx_OVERRIDE_SDK_VERSION=ON" "-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.darwinArch}" "-DDARWIN_osx_BUILTIN_ARCHS=${stdenv.hostPlatform.darwinArch}" + # `COMPILER_RT_DEFAULT_TARGET_ONLY` does not apply to Darwin: # https://github.com/llvm/llvm-project/blob/27ef42bec80b6c010b7b3729ed0528619521a690/compiler-rt/cmake/base-config-ix.cmake#L153 "-DCOMPILER_RT_ENABLE_IOS=OFF" ]; - preConfigure = lib.optionalString (useLLVM && !haveLibc) '' - cmakeFlagsArray+=(-DCMAKE_C_FLAGS="-nodefaultlibs -ffreestanding") - ''; - outputs = [ "out" "dev" ]; patches = [ @@ -86,7 +95,7 @@ stdenv.mkDerivation { # See: https://github.com/NixOS/nixpkgs/pull/186575 ../../common/compiler-rt/darwin-plistbuddy-workaround.patch # See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893 - ../../common/compiler-rt/armv7l-15.patch + # ../../common/compiler-rt/armv7l-15.patch ]; # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks @@ -100,7 +109,7 @@ stdenv.mkDerivation { '' + lib.optionalString stdenv.isDarwin '' substituteInPlace cmake/config-ix.cmake \ --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' - '' + lib.optionalString (useLLVM) '' + '' + lib.optionalString (useLLVM && !haveLibc) '' substituteInPlace lib/builtins/int_util.c \ --replace "#include <stdlib.h>" "" substituteInPlace lib/builtins/clear_cache.c \ @@ -110,15 +119,21 @@ stdenv.mkDerivation { ''; # Hack around weird upsream RPATH bug - postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) '' + postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin) '' ln -s "$out/lib"/*/* "$out/lib" - '' + lib.optionalString (useLLVM) '' + '' + lib.optionalString (useLLVM && stdenv.hostPlatform.isLinux) '' ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o + # Note the history of crt{begin,end}S in previous versions of llvm in nixpkg: + # The presence of crtbegin_shared has been added and removed; it's possible + # people have added/removed it to get it working on their platforms. + # Try each in turn for now. + ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbeginS.o + ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtendS.o ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o '' + lib.optionalString doFakeLibgcc '' - ln -s $out/lib/freebsd/libclang_rt.builtins-*.a $out/lib/libgcc.a + ln -s $out/lib/freebsd/libclang_rt.builtins-*.a $out/lib/libgcc.a ''; meta = llvm_meta // { diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/normalize-var.patch b/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/normalize-var.patch index 135cf625ef78..2b25fd4a0744 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/normalize-var.patch +++ b/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/normalize-var.patch @@ -1,16 +1,16 @@ -diff --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake -index f1f46fb9599c..6f19e69507ba 100644 +diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake +index 4c85551d7766..297d7a47c54b 100644 --- a/cmake/Modules/CompilerRTUtils.cmake +++ b/cmake/Modules/CompilerRTUtils.cmake -@@ -302,8 +302,9 @@ macro(load_llvm_config) - # Get some LLVM variables from LLVMConfig. - include("${LLVM_CMAKE_PATH}/LLVMConfig.cmake") - -- set(LLVM_LIBRARY_OUTPUT_INTDIR -- ${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}) -+ get_filename_component(LLVM_LIBRARY_OUTPUT_INTDIR -+ ${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX} -+ REALPATH) +@@ -328,8 +328,9 @@ macro(load_llvm_config) + endif() endif() - endmacro() +- set(LLVM_LIBRARY_OUTPUT_INTDIR +- ${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}) ++ get_filename_component(LLVM_LIBRARY_OUTPUT_INTDIR ++ ${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX} ++ REALPATH) + + set(LLVM_MAIN_SRC_DIR "${LLVM_MAIN_SRC_DIR_DEFAULT}" CACHE PATH "Path to LLVM source tree") + message(STATUS "LLVM_MAIN_SRC_DIR: \"${LLVM_MAIN_SRC_DIR}\"") diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/default.nix index 0748b97dd598..337809e85e63 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/git/default.nix @@ -1,11 +1,11 @@ -{ lowPrio, newScope, pkgs, lib, stdenv, cmake, ninja -, preLibcCrossHeaders +{ lowPrio, newScope, pkgs, lib, stdenv, stdenvNoCC, cmake, ninja +, gccForLibs, preLibcCrossHeaders , libxml2, python3, fetchFromGitHub, overrideCC, wrapCCWith, wrapBintoolsWith , buildLlvmTools # tools, but from the previous stage, for cross , targetLlvmLibraries # libraries, but from the next stage, for cross , targetLlvm # This is the default binutils, but with *this* version of LLD rather -# than the default LLVM version's, if LLD is the choice. We use these for +# than the default LLVM verion's, if LLD is the choice. We use these for # the `useLLVM` bootstrapping below. , bootBintoolsNoLibc ? if stdenv.targetPlatform.linker == "lld" @@ -17,7 +17,12 @@ else pkgs.bintools , darwin # LLVM release information; specify one of these but not both: -, gitRelease ? null +, gitRelease ? { + version = "18.0.0"; + rev = "6f44f87011cd52367626cac111ddbb2d25784b90"; + rev-version = "18.0.0-unstable-2023-10-04"; + sha256 = "sha256-CqsCDlzg8I2c9BybKP7B5nfHiQWktqgVavrfiYkjkx4="; +} # i.e.: # { # version = /* i.e. "15.0.0" */; @@ -25,7 +30,7 @@ # rev-version = /* human readable version; i.e. "unstable-2022-26-07" */; # sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */; # } -, officialRelease ? { version = "15.0.7"; sha256 = "sha256-wjuZQyXQ/jsmvy6y1aksCcEDXGBjuhpgngF3XQJ/T4s="; } +, officialRelease ? null # i.e.: # { # version = /* i.e. "15.0.0" */; @@ -40,6 +45,7 @@ # specified. , monorepoSrc ? null }: + assert let int = a: if a then 1 else 0; xor = a: b: ((builtins.bitXor (int a) (int b)) == 1); @@ -53,17 +59,19 @@ in let monorepoSrc' = monorepoSrc; in let - # Import releaseInfo separately to avoid infinite recursion inherit (import ../common/common-let.nix { inherit lib gitRelease officialRelease; }) releaseInfo; + inherit (releaseInfo) release_version version; + inherit (import ../common/common-let.nix { inherit lib fetchFromGitHub release_version gitRelease officialRelease monorepoSrc'; }) llvm_meta monorepoSrc; tools = lib.makeExtensible (tools: let callPackage = newScope (tools // { inherit stdenv cmake ninja libxml2 python3 release_version version monorepoSrc buildLlvmTools; }); + major = lib.versions.major release_version; mkExtraBuildCommands0 = cc: '' rsrc="$out/resource-root" mkdir "$rsrc" - ln -s "${cc.lib}/lib/clang/${release_version}/include" "$rsrc" + ln -s "${cc.lib}/lib/clang/${major}/include" "$rsrc" echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags ''; mkExtraBuildCommands = cc: mkExtraBuildCommands0 cc + '' @@ -106,16 +114,14 @@ in let python3 = pkgs.python3; # don't use python-boot }); - # TODO: lldb/docs/index.rst:155:toctree contains reference to nonexisting document 'design/structureddataplugins' - # lldb-manpages = lowPrio (tools.lldb.override { - # enableManpages = true; - # python3 = pkgs.python3; # don't use python-boot - # }); + lldb-manpages = lowPrio (tools.lldb.override { + enableManpages = true; + python3 = pkgs.python3; # don't use python-boot + }); # pick clang appropriate for package set we are targeting clang = - /**/ if stdenv.targetPlatform.libc == null then tools.clangNoLibc - else if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM + /**/ if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang else tools.libcxxClang; @@ -150,20 +156,24 @@ in let cp -r ${monorepoSrc}/lldb "$out" '') { }; patches = - let - resourceDirPatch = callPackage - ({ substituteAll, libclang }: substituteAll - { - src = ./lldb/resource-dir.patch; - clangLibDir = "${libclang.lib}/lib"; - }) - { }; - in [ - ./lldb/procfs.patch # FIXME: do we need this? - resourceDirPatch + # FIXME: do we need this? ./procfs.patch ./lldb/gnu-install-dirs.patch - ]; + ] + # This is a stopgap solution if/until the macOS SDK used for x86_64 is + # updated. + # + # The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h` + # header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use + # of this preprocessor symbol in `lldb` with its expansion. + # + # See here for some context: + # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132 + ++ lib.optional ( + stdenv.targetPlatform.isDarwin + && !stdenv.targetPlatform.isAarch64 + && (lib.versionOlder darwin.apple_sdk.sdk.version "11.0") + ) ./lldb/cpu_subtype_arm64e_replacement.patch; inherit llvm_meta; }; @@ -216,11 +226,13 @@ in let targetLlvmLibraries.compiler-rt ]; extraBuildCommands = mkExtraBuildCommands cc; - nixSupport.cc-cflags = [ - "-rtlib=compiler-rt" - "-B${targetLlvmLibraries.compiler-rt}/lib" - "-nostdlib++" - ]; + nixSupport.cc-cflags = + [ + "-rtlib=compiler-rt" + "-B${targetLlvmLibraries.compiler-rt}/lib" + "-nostdlib++" + ] + ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions"; }; clangNoLibc = wrapCCWith rec { @@ -231,10 +243,12 @@ in let targetLlvmLibraries.compiler-rt ]; extraBuildCommands = mkExtraBuildCommands cc; - nixSupport.cc-cflags = [ - "-rtlib=compiler-rt" - "-B${targetLlvmLibraries.compiler-rt}/lib" - ]; + nixSupport.cc-cflags = + [ + "-rtlib=compiler-rt" + "-B${targetLlvmLibraries.compiler-rt}/lib" + ] + ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions"; }; clangNoCompilerRt = wrapCCWith rec { @@ -243,16 +257,22 @@ in let bintools = bintoolsNoLibc'; extraPackages = [ ]; extraBuildCommands = mkExtraBuildCommands0 cc; - nixSupport.cc-cflags = [ "-nostartfiles" ]; + nixSupport.cc-cflags = + [ + "-nostartfiles" + ] + ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions"; }; - clangNoCompilerRtWithLibc = wrapCCWith rec { + clangNoCompilerRtWithLibc = wrapCCWith (rec { cc = tools.clang-unwrapped; libcxx = null; bintools = bintools'; extraPackages = [ ]; extraBuildCommands = mkExtraBuildCommands0 cc; - }; + } // lib.optionalAttrs stdenv.targetPlatform.isWasm { + nixSupport.cc-cflags = [ "-fno-exceptions" ]; + }); }); @@ -262,7 +282,7 @@ in let compiler-rt-libc = callPackage ./compiler-rt { inherit llvm_meta; - stdenv = if stdenv.hostPlatform.useLLVM or false + stdenv = if stdenv.hostPlatform.useLLVM or false || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isStatic) then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc else stdenv; }; @@ -275,7 +295,7 @@ in let }; # N.B. condition is safe because without useLLVM both are the same. - compiler-rt = if stdenv.hostPlatform.isAndroid + compiler-rt = if stdenv.hostPlatform.isAndroid || stdenv.hostPlatform.isDarwin then libraries.compiler-rt-libc else libraries.compiler-rt-no-libc; diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix index f267b753b24a..7b9996641663 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix @@ -45,12 +45,6 @@ stdenv.mkDerivation rec { chmod -R u+w . ''; - patches = [ - ./gnu-install-dirs.patch - ] ++ lib.optionals stdenv.hostPlatform.isMusl [ - ../../libcxx-0001-musl-hacks.patch - ]; - postPatch = '' cd ../runtimes ''; @@ -64,8 +58,7 @@ stdenv.mkDerivation rec { buildInputs = lib.optionals (!headersOnly) [ cxxabi ] - ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ libunwind ]; - + ++ lib.optionals (stdenv.hostPlatform.useLLVM or false && !stdenv.hostPlatform.isWasm) [ libunwind ]; cmakeFlags = let # See: https://libcxx.llvm.org/BuildingLibcxx.html#cmdoption-arg-libcxx-cxx-abi-string @@ -80,19 +73,17 @@ stdenv.mkDerivation rec { ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ "-DLIBCXX_USE_COMPILER_RT=ON" - # (Backport fix from 16, which has LIBCXX_ADDITIONAL_LIBRARIES, but 15 - # does not appear to) # There's precedent for this in llvm-project/libcxx/cmake/caches. # In a monorepo build you might do the following in the libcxxabi build: # -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder # -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On # libcxx appears to require unwind and doesn't pull it in via other means. - # "-DLIBCXX_ADDITIONAL_LIBRARIES=unwind" - "-DCMAKE_SHARED_LINKER_FLAGS=-lunwind" + "-DLIBCXX_ADDITIONAL_LIBRARIES=unwind" ] ++ lib.optionals stdenv.hostPlatform.isWasm [ "-DLIBCXX_ENABLE_THREADS=OFF" "-DLIBCXX_ENABLE_FILESYSTEM=OFF" "-DLIBCXX_ENABLE_EXCEPTIONS=OFF" + "-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF" # If we're only building the headers we don't actually *need* a functioning # C/C++ compiler: diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/gnu-install-dirs.patch deleted file mode 100644 index daee5bdd0ed3..000000000000 --- a/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/gnu-install-dirs.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 74eff2002fc9..c935d10878bb 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -419,7 +419,7 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) - set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) - set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") - set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1") -- set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH -+ set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH - "Path where built libc++ libraries should be installed.") - set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH - "Path where target-specific libc++ headers should be installed.") -@@ -436,7 +436,7 @@ else() - set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") - endif() - set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}") -- set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH -+ set(LIBCXX_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXX_LIBDIR_SUFFIX} CACHE PATH - "Path where built libc++ libraries should be installed.") - set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH - "Path where target-specific libc++ headers should be installed.") diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/default.nix index 6987e6b0ca3c..0a795da44ae4 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/default.nix @@ -28,8 +28,6 @@ stdenv.mkDerivation rec { postUnpack = lib.optionalString stdenv.isDarwin '' export TRIPLE=x86_64-apple-darwin - '' + lib.optionalString stdenv.hostPlatform.isWasm '' - patch -p1 -d llvm -i ${../../common/libcxxabi/wasm.patch} ''; prePatch = '' @@ -65,7 +63,7 @@ stdenv.mkDerivation rec { # CMake however checks for this anyways; this flag tells it not to. See: # https://github.com/llvm/llvm-project/blob/4bd3f3759259548e159aeba5c76efb9a0864e6fa/llvm/runtimes/CMakeLists.txt#L243 "-DCMAKE_CXX_COMPILER_WORKS=ON" - ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ + ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false && !stdenv.hostPlatform.isWasm) [ "-DLLVM_ENABLE_LIBCXX=ON" "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" # libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib, @@ -74,31 +72,22 @@ stdenv.mkDerivation rec { "-DCMAKE_EXE_LINKER_FLAGS=-nostdlib" "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib" ] ++ lib.optionals stdenv.hostPlatform.isWasm [ + "-DCMAKE_C_COMPILER_WORKS=ON" + "-DCMAKE_CXX_COMPILER_WORKS=ON" "-DLIBCXXABI_ENABLE_THREADS=OFF" "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF" + "-DUNIX=ON" ] ++ lib.optionals (!enableShared) [ "-DLIBCXXABI_ENABLE_SHARED=OFF" ]; preInstall = lib.optionalString stdenv.isDarwin '' for file in lib/*.dylib; do - if [ -L "$file" ]; then continue; fi - - # Fix up the install name. Preserve the basename, just replace the path. - installName="$out/lib/$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))" - # this should be done in CMake, but having trouble figuring out # the magic combination of necessary CMake variables # if you fancy a try, take a look at # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling - ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file - - # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes - # libcxxabi to sometimes link against a different version of itself. - # Here we simply make that second reference point to ourselves. - for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do - ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file - done + install_name_tool -id $out/$file $file done ''; @@ -121,5 +110,8 @@ stdenv.mkDerivation rec { # the UIUC License (a BSD-like license)": license = with lib.licenses; [ mit ncsa ]; maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ]; + # Broken until https://github.com/llvm/llvm-project/issues/64226 is resolved + # We should check if the version is not 10.13 but that is currently broken. + broken = stdenv.isDarwin && stdenv.isx86_64; }; } diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/gnu-install-dirs.patch index fa587612aaf6..51382fcefed2 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/gnu-install-dirs.patch +++ b/nixpkgs/pkgs/development/compilers/llvm/git/libcxxabi/gnu-install-dirs.patch @@ -1,21 +1,21 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index b8326d08d23a..a1e36f713161 100644 +diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt +index f380fe6b6b92..a9656258c38e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -187,7 +187,7 @@ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH +@@ -188,7 +188,7 @@ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR}) set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) -- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH +- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE STRING + set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH "Path where built libc++abi libraries should be installed.") if(LIBCXX_LIBDIR_SUBDIR) string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR}) -@@ -201,7 +201,7 @@ else() +@@ -202,7 +202,7 @@ else() set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR}) set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX}) endif() -- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH +- set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE STRING + set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH "Path where built libc++abi libraries should be installed.") endif() diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/libunwind/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/libunwind/default.nix index 1b677a7a2c0d..a3c8e2594f5a 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/libunwind/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/git/libunwind/default.nix @@ -32,10 +32,6 @@ stdenv.mkDerivation rec { chmod -R u+w . ''; - patches = [ - ./gnu-install-dirs.patch - ]; - postPatch = '' cd ../runtimes ''; diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/libunwind/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/git/libunwind/gnu-install-dirs.patch deleted file mode 100644 index edfb2a8760bd..000000000000 --- a/nixpkgs/pkgs/development/compilers/llvm/git/libunwind/gnu-install-dirs.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 5a06805f05f1..86a50329e6a8 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -117,7 +117,7 @@ set(LIBUNWIND_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH - - if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) - set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) -- set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH -+ set(LIBUNWIND_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH - "Path where built libunwind libraries should be installed.") - if(LIBCXX_LIBDIR_SUBDIR) - string(APPEND LIBUNWIND_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR}) -@@ -129,7 +129,7 @@ else() - else() - set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX}) - endif() -- set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH -+ set(LIBUNWIND_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH - "Path where built libunwind libraries should be installed.") - endif() - diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/lld/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/git/lld/gnu-install-dirs.patch index ea62b2ad50c7..86e76f4a16d8 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/lld/gnu-install-dirs.patch +++ b/nixpkgs/pkgs/development/compilers/llvm/git/lld/gnu-install-dirs.patch @@ -1,34 +1,34 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index dcc649629a4b..58dca54642e4 100644 +index 3d6225646fe6..9b5d0b15af13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -70,13 +70,15 @@ if(LLD_BUILT_STANDALONE) - if (NOT LLVM_CONFIG_FOUND) - # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config - # path is removed. -- set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}") +@@ -33,10 +33,22 @@ if(LLD_BUILT_STANDALONE) + find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}") + list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}") + +- # Turn into CACHE PATHs for overwriting +- set(LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed") +- set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}" CACHE PATH "Path to LLVM build tree") +- set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path to LLVM source tree") ++ # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets ++ # LLVM_CONFIG. ++ if (NOT LLVM_CONFIG_FOUND) ++ # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config ++ # path is removed. + set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS}) - set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}") - # N.B. this is just a default value, the CACHE PATHs below can be overridden. - set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm") ++ set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}") ++ # N.B. this is just a default value, the CACHE PATHs below can be overridden. ++ set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm") + else() + set(INCLUDE_DIRS "${LLVM_BINARY_DIR}/include" "${MAIN_INCLUDE_DIR}") - endif() - -- set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to llvm/include") ++ endif() ++ + set(LLVM_INCLUDE_DIRS ${INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed") - set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree") - set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree") - -@@ -95,7 +97,7 @@ if(LLD_BUILT_STANDALONE) - - set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}") - -- include_directories("${LLVM_BINARY_DIR}/include" ${LLVM_INCLUDE_DIRS}) -+ include_directories(${LLVM_INCLUDE_DIRS}) - link_directories(${LLVM_LIBRARY_DIRS}) ++ set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree") ++ set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree") - if(LLVM_INCLUDE_TESTS) + find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} + NO_DEFAULT_PATH) diff --git a/cmake/modules/AddLLD.cmake b/cmake/modules/AddLLD.cmake index d3924f7243d4..42a7cd62281c 100644 --- a/cmake/modules/AddLLD.cmake diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/lldb/cpu_subtype_arm64e_replacement.patch b/nixpkgs/pkgs/development/compilers/llvm/git/lldb/cpu_subtype_arm64e_replacement.patch new file mode 100644 index 000000000000..20d35c9f3ea9 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/git/lldb/cpu_subtype_arm64e_replacement.patch @@ -0,0 +1,12 @@ +diff --git a/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/source/Host/macosx/objcxx/HostInfoMacOSX.mm +--- a/source/Host/macosx/objcxx/HostInfoMacOSX.mm ++++ b/source/Host/macosx/objcxx/HostInfoMacOSX.mm +@@ -233,7 +233,7 @@ void HostInfoMacOSX::ComputeHostArchitectureSupport(ArchSpec &arch_32, + len = sizeof(is_64_bit_capable); + ::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0); + +- if (cputype == CPU_TYPE_ARM64 && cpusubtype == CPU_SUBTYPE_ARM64E) { ++ if (cputype == CPU_TYPE_ARM64 && cpusubtype == ((cpu_subtype_t) 2)) { // CPU_SUBTYPE_ARM64E is not available in the macOS 10.12 headers + // The arm64e architecture is a preview. Pretend the host architecture + // is arm64. + cpusubtype = CPU_SUBTYPE_ARM64_ALL; diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/lldb/procfs.patch b/nixpkgs/pkgs/development/compilers/llvm/git/lldb/procfs.patch index a798216aa62c..7b200e86505c 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/lldb/procfs.patch +++ b/nixpkgs/pkgs/development/compilers/llvm/git/lldb/procfs.patch @@ -1,14 +1,20 @@ --- a/source/Plugins/Process/Linux/Procfs.h +++ b/source/Plugins/Process/Linux/Procfs.h -@@ -10,6 +10,7 @@ +@@ -10,6 +10,13 @@ // sys/procfs.h on Android/Linux for all supported architectures. #include <sys/ptrace.h> +#include <asm/ptrace.h> ++ ++// on i686 preprocessor symbols with these register names are defined as ++// numeric constants; these symbols clash with identifier names used in ++// `llvm/Support/VirtualFileSystem.h` and `llvm/ADT/SmallVector.h` ++#undef FS ++#undef CS #include "lldb/lldb-types.h" -@@ -17,23 +18,13 @@ +@@ -17,23 +24,13 @@ #include <vector> diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/lldb/resource-dir.patch b/nixpkgs/pkgs/development/compilers/llvm/git/lldb/resource-dir.patch deleted file mode 100644 index e0db80afeb9f..000000000000 --- a/nixpkgs/pkgs/development/compilers/llvm/git/lldb/resource-dir.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake -index 37364341ff8b..7f74c1a3e257 100644 ---- a/cmake/modules/LLDBConfig.cmake -+++ b/cmake/modules/LLDBConfig.cmake -@@ -257,7 +257,7 @@ if (NOT TARGET clang-resource-headers) - # Iterate over the possible places where the external resource directory - # could be and pick the first that exists. - foreach(CANDIDATE "${Clang_DIR}/../.." "${LLVM_DIR}" "${LLVM_LIBRARY_DIRS}" -- "${LLVM_BUILD_LIBRARY_DIR}" -+ "${LLVM_BUILD_LIBRARY_DIR}" "@clangLibDir@" - "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}") - # Build the resource directory path by appending 'clang/<version number>'. - set(CANDIDATE_RESOURCE_DIR "${CANDIDATE}/clang/${LLDB_CLANG_RESOURCE_DIR_NAME}") diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/default.nix index 119b2272beda..3d05837d45da 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/default.nix @@ -2,13 +2,14 @@ , pkgsBuildBuild , monorepoSrc , runCommand -, fetchpatch , cmake , darwin , ninja , python3 +, python3Packages , libffi -, enableGoldPlugin ? (!stdenv.isDarwin && !stdenv.targetPlatform.isWasi) +# TODO: Gold plugin on LLVM16 has a severe memory corruption bug: https://github.com/llvm/llvm-project/issues/61350. +, enableGoldPlugin ? false , libbfd , libpfm , libxml2 @@ -56,12 +57,17 @@ let # So, we "manually" assemble one python derivation for the package to depend # on, taking into account whether checks are enabled or not: python = if doCheck then + # Note that we _explicitly_ ask for a python interpreter for our host + # platform here; the splicing that would ordinarily take care of this for + # us does not seem to work once we use `withPackages`. let checkDeps = ps: with ps; [ psutil ]; - in python3.withPackages checkDeps + in pkgsBuildBuild.targetPackages.python3.withPackages checkDeps else python3; -in stdenv.mkDerivation (rec { +in + assert (lib.assertMsg (!enableGoldPlugin) "Gold plugin cannot be enabled on LLVM16 due to a upstream issue: https://github.com/llvm/llvm-project/issues/61350"); + stdenv.mkDerivation (rec { pname = "llvm"; inherit version; @@ -80,7 +86,11 @@ in stdenv.mkDerivation (rec { outputs = [ "out" "lib" "dev" "python" ]; nativeBuildInputs = [ cmake ninja python ] - ++ optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ]; + ++ optionals enableManpages [ + # Note: we intentionally use `python3Packages` instead of `python3.pkgs`; + # splicing does *not* work with the latter. (TODO: fix) + python3Packages.sphinx python3Packages.recommonmark + ]; buildInputs = [ libxml2 libffi ] ++ optional enablePFM libpfm; # exegesis @@ -134,13 +144,6 @@ in stdenv.mkDerivation (rec { # It's not clear to me why this isn't an issue for LLVM developers running # on macOS (nothing about this _seems_ nix specific).. ./lit-shell-script-runner-set-dyld-library-path.patch - - # Fix musl build. - (fetchpatch { - url = "https://github.com/llvm/llvm-project/commit/5cd554303ead0f8891eee3cd6d25cb07f5a7bf67.patch"; - relative = "llvm"; - hash = "sha256-XPbvNJ45SzjMGlNUgt/IgEvM2dHQpDOe6woUJY+nUYA="; - }) ] ++ lib.optionals enablePolly [ ./gnu-install-dirs-polly.patch @@ -152,29 +155,28 @@ in stdenv.mkDerivation (rec { substituteInPlace cmake/modules/AddLLVM.cmake \ --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \ --replace 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}''${LLVM_LIBDIR_SUFFIX}" ''${extra_libdir})' "" + # As of LLVM 15, marked as XFAIL on arm64 macOS but lit doesn't seem to pick # this up: https://github.com/llvm/llvm-project/blob/c344d97a125b18f8fed0a64aace73c49a870e079/llvm/test/MC/ELF/cfi-version.ll#L7 rm test/MC/ELF/cfi-version.ll # This test tries to call `sw_vers` by absolute path (`/usr/bin/sw_vers`) # and thus fails under the sandbox: - substituteInPlace unittests/Support/Host.cpp \ + substituteInPlace unittests/TargetParser/Host.cpp \ --replace '/usr/bin/sw_vers' "${(builtins.toString darwin.DarwinTools) + "/bin/sw_vers" }" - '' + optionalString (stdenv.isDarwin && stdenv.hostPlatform.isx86) '' + # This test tries to call the intrinsics `@llvm.roundeven.f32` and # `@llvm.roundeven.f64` which seem to (incorrectly?) lower to `roundevenf` - # and `roundeven` on x86_64 macOS. + # and `roundeven` on macOS. # # However these functions are glibc specific so the test fails: # - https://www.gnu.org/software/gnulib/manual/html_node/roundevenf.html # - https://www.gnu.org/software/gnulib/manual/html_node/roundeven.html # - # TODO(@rrbutani): this seems to run fine on `aarch64-darwin`, why does it - # pass there? substituteInPlace test/ExecutionEngine/Interpreter/intrinsics.ll \ --replace "%roundeven32 = call float @llvm.roundeven.f32(float 0.000000e+00)" "" \ --replace "%roundeven64 = call double @llvm.roundeven.f64(double 0.000000e+00)" "" - + '' + optionalString (stdenv.isDarwin && stdenv.hostPlatform.isx86) '' # This test fails on darwin x86_64 because `sw_vers` reports a different # macOS version than what LLVM finds by reading # `/System/Library/CoreServices/SystemVersion.plist` (which is passed into @@ -203,13 +205,13 @@ in stdenv.mkDerivation (rec { # not clear to me when/where/for what this even gets used in LLVM. # # TODO(@rrbutani): fix/follow-up - substituteInPlace unittests/Support/Host.cpp \ + substituteInPlace unittests/TargetParser/Host.cpp \ --replace "getMacOSHostVersion" "DISABLED_getMacOSHostVersion" # This test fails with a `dysmutil` crash; have not yet dug into what's # going on here (TODO(@rrbutani)). rm test/tools/dsymutil/ARM/obfuscated.test - '' + '' + '' + '' # FileSystem permissions tests fail with various special bits substituteInPlace unittests/Support/CMakeLists.txt \ --replace "Path.cpp" "" @@ -234,6 +236,8 @@ in stdenv.mkDerivation (rec { rm test/tools/gold/X86/split-dwarf.ll rm test/tools/llvm-dwarfdump/X86/prettyprint_types.s rm test/tools/llvm-dwarfdump/X86/simplified-template-names.s + rm test/CodeGen/RISCV/attributes.ll + rm test/CodeGen/RISCV/xtheadmempair.ll '' + optionalString (stdenv.hostPlatform.system == "armv6l-linux") '' # Seems to require certain floating point hardware (NEON?) rm test/ExecutionEngine/frem.ll @@ -321,7 +325,7 @@ in stdenv.mkDerivation (rec { "-DSPHINX_OUTPUT_MAN=ON" "-DSPHINX_OUTPUT_HTML=OFF" "-DSPHINX_WARNINGS_AS_ERRORS=OFF" - ] ++ optionals (enableGoldPlugin) [ + ] ++ optionals (false) [ "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" ] ++ optionals isDarwin [ "-DLLVM_ENABLE_LIBCXX=ON" diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch index 0ef317af8cc7..e2122ebf603d 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch +++ b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch @@ -1,8 +1,8 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 45399dc0537e..5d946e9e6583 100644 +index 471817d68286..c51463304159 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -942,7 +942,7 @@ if (NOT TENSORFLOW_AOT_PATH STREQUAL "") +@@ -1010,7 +1010,7 @@ if (NOT TENSORFLOW_AOT_PATH STREQUAL "") add_subdirectory(${TENSORFLOW_AOT_PATH}/xla_aot_runtime_src ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/tf_runtime) install(TARGETS tf_xla_runtime EXPORT LLVMExports @@ -12,10 +12,10 @@ index 45399dc0537e..5d946e9e6583 100644 # Once we add more modules, we should handle this more automatically. if (DEFINED LLVM_OVERRIDE_MODEL_HEADER_INLINERSIZEMODEL) diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake -index 057431208322..56f0dcb258da 100644 +index 230620c37027..dd16cab1835e 100644 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake -@@ -844,8 +844,8 @@ macro(add_llvm_library name) +@@ -876,8 +876,8 @@ macro(add_llvm_library name) get_target_export_arg(${name} LLVM export_to_llvmexports ${umbrella}) install(TARGETS ${name} ${export_to_llvmexports} @@ -26,16 +26,16 @@ index 057431208322..56f0dcb258da 100644 RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name}) if (NOT LLVM_ENABLE_IDE) -@@ -2007,7 +2007,7 @@ function(llvm_install_library_symlink name dest type) - set(full_name ${CMAKE_${type}_LIBRARY_PREFIX}${name}${CMAKE_${type}_LIBRARY_SUFFIX}) - set(full_dest ${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX}) +@@ -2069,7 +2069,7 @@ function(llvm_install_library_symlink name dest type) + set(LLVM_LINK_OR_COPY copy) + endif() - set(output_dir lib${LLVM_LIBDIR_SUFFIX}) + set(output_dir ${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) if(WIN32 AND "${type}" STREQUAL "SHARED") set(output_dir "${CMAKE_INSTALL_BINDIR}") endif() -@@ -2271,15 +2271,15 @@ function(llvm_setup_rpath name) +@@ -2344,16 +2344,37 @@ function(llvm_setup_rpath name) if (APPLE) set(_install_name_dir INSTALL_NAME_DIR "@rpath") @@ -49,7 +49,30 @@ index 057431208322..56f0dcb258da 100644 - set(_install_rpath "${LLVM_LIBRARY_OUTPUT_INTDIR}" "${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) + set(_install_rpath "${LLVM_LIBRARY_OUTPUT_INTDIR}" "${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) elseif(UNIX) -- set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) +- set(_build_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) +- set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}") ++ # Note that we add `extra_libdir` (aka `LLVM_LIBRARY_DIR` in our case) back ++ # to `_install_rpath` here. ++ # ++ # In nixpkgs we do not build and install LLVM alongside rdeps of LLVM (i.e. ++ # clang); instead LLVM is its own package and thus lands at its own nix ++ # store path. This makes it so that the default relative rpath (`../lib/`) ++ # does not point at the LLVM shared objects. ++ # ++ # More discussion here: ++ # - https://github.com/NixOS/nixpkgs/pull/235624#discussion_r1220150329 ++ # - https://reviews.llvm.org/D146918 (16.0.5+) ++ # ++ # Note that we leave `extra_libdir` in `_build_rpath`: without FHS there is ++ # no potential that this will result in us pulling in the "wrong" LLVM. ++ # Adding this to the build rpath means we aren't forced to use ++ # `installCheckPhase` instead of `checkPhase` (i.e. binaries in the build ++ # dir, pre-install, will have the right rpath for LLVM). ++ # ++ # As noted in the differential above, an alternative solution is to have ++ # all rdeps of nixpkgs' LLVM (that use the AddLLVM.cmake machinery) set ++ # `CMAKE_INSTALL_RPATH`. ++ set(_build_rpath "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) + set(_install_rpath "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)") set_property(TARGET ${name} APPEND_STRING PROPERTY @@ -71,10 +94,10 @@ index 891c9e6d618c..8d963f3b0069 100644 list(APPEND ocaml_flags "-ldopt" "-Wl,-rpath,${ocaml_rpath}") diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt -index d4b0ab959148..26ed981fd09f 100644 +index d99af79aa38e..21e794224b99 100644 --- a/cmake/modules/CMakeLists.txt +++ b/cmake/modules/CMakeLists.txt -@@ -128,7 +128,7 @@ set(LLVM_CONFIG_INCLUDE_DIRS +@@ -127,7 +127,7 @@ set(LLVM_CONFIG_INCLUDE_DIRS ) list(REMOVE_DUPLICATES LLVM_CONFIG_INCLUDE_DIRS) @@ -83,30 +106,6 @@ index d4b0ab959148..26ed981fd09f 100644 set(LLVM_CONFIG_LIBRARY_DIRS "${LLVM_CONFIG_LIBRARY_DIR}" # FIXME: Should there be other entries here? -diff --git a/docs/CMake.rst b/docs/CMake.rst -index 879b7b231d4c..9c31d14e8950 100644 ---- a/docs/CMake.rst -+++ b/docs/CMake.rst -@@ -250,7 +250,7 @@ description is in `LLVM-related variables`_ below. - **LLVM_LIBDIR_SUFFIX**:STRING - Extra suffix to append to the directory where libraries are to be - installed. On a 64-bit architecture, one could use ``-DLLVM_LIBDIR_SUFFIX=64`` -- to install libraries to ``/usr/lib64``. -+ to install libraries to ``/usr/lib64``. See also ``CMAKE_INSTALL_LIBDIR``. - - **LLVM_PARALLEL_{COMPILE,LINK}_JOBS**:STRING - Building the llvm toolchain can use a lot of resources, particularly -@@ -284,6 +284,10 @@ manual, or execute ``cmake --help-variable VARIABLE_NAME``. - The path to install executables, relative to the *CMAKE_INSTALL_PREFIX*. - Defaults to "bin". - -+**CMAKE_INSTALL_LIBDIR**:PATH -+ The path to install libraries, relative to the *CMAKE_INSTALL_PREFIX*. -+ Defaults to "lib". -+ - **CMAKE_INSTALL_INCLUDEDIR**:PATH - The path to install header files, relative to the *CMAKE_INSTALL_PREFIX*. - Defaults to "include". diff --git a/tools/llvm-config/BuildVariables.inc.in b/tools/llvm-config/BuildVariables.inc.in index 370005cd8d7d..7e790bc52111 100644 --- a/tools/llvm-config/BuildVariables.inc.in @@ -120,10 +119,10 @@ index 370005cd8d7d..7e790bc52111 100644 #define LLVM_INSTALL_PACKAGE_DIR "@LLVM_INSTALL_PACKAGE_DIR@" #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@" diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp -index 2c6c55f89d38..f6d2068a0827 100644 +index e86eb2b44b10..f63e207e792e 100644 --- a/tools/llvm-config/llvm-config.cpp +++ b/tools/llvm-config/llvm-config.cpp -@@ -369,7 +369,11 @@ int main(int argc, char **argv) { +@@ -366,7 +366,11 @@ int main(int argc, char **argv) { sys::fs::make_absolute(ActivePrefix, Path); ActiveBinDir = std::string(Path.str()); } diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/lit-shell-script-runner-set-dyld-library-path.patch b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/lit-shell-script-runner-set-dyld-library-path.patch index 32f1d13a9dc2..82b7b21c55fb 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/lit-shell-script-runner-set-dyld-library-path.patch +++ b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/lit-shell-script-runner-set-dyld-library-path.patch @@ -15,12 +15,3 @@ index 0242e0b75af3..d732011306f7 100644 for i, ln in enumerate(commands): match = re.match(kPdbgRegex, ln) if match: -@@ -1363,7 +1369,7 @@ def applySubstitutions(script, substitutions, conditions={}, - return processed - - process = processLine if recursion_limit is None else processLineToFixedPoint -- -+ - return [unescapePercents(process(ln)) for ln in script] - - diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch index d824516c0a16..d4ccb2ae9822 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch +++ b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch @@ -10,23 +10,23 @@ index 81e8dc04acea..479ff95681e2 100644 import subprocess import lit.formats -@@ -55,3 +56,26 @@ if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir): +@@ -55,3 +56,26 @@ if sys.platform in ["win32", "cygwin"] and os.path.isdir(config.shlibdir): # Win32 may use %SYSTEMDRIVE% during file system shell operations, so propogate. - if sys.platform == 'win32' and 'SYSTEMDRIVE' in os.environ: - config.environment['SYSTEMDRIVE'] = os.environ['SYSTEMDRIVE'] + if sys.platform == "win32" and "SYSTEMDRIVE" in os.environ: + config.environment["SYSTEMDRIVE"] = os.environ["SYSTEMDRIVE"] + +# Add the LLVM dynamic libs to the platform-specific loader search path env var: +# +# TODO: this is copied from `clang`'s `lit.cfg.py`; should unify.. +def find_shlibpath_var(): -+ if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'OpenBSD', 'SunOS']: -+ yield 'LD_LIBRARY_PATH' -+ elif platform.system() == 'Darwin': -+ yield 'DYLD_LIBRARY_PATH' -+ elif platform.system() == 'Windows': -+ yield 'PATH' -+ elif platform.system() == 'AIX': -+ yield 'LIBPATH' ++ if platform.system() in ["Linux", "FreeBSD", "NetBSD", "OpenBSD", "SunOS"]: ++ yield "LD_LIBRARY_PATH" ++ elif platform.system() == "Darwin": ++ yield "DYLD_LIBRARY_PATH" ++ elif platform.system() == "Windows": ++ yield "PATH" ++ elif platform.system() == "AIX": ++ yield "LIBPATH" + +for shlibpath_var in find_shlibpath_var(): + shlibpath = os.path.pathsep.join( @@ -41,22 +41,22 @@ diff --git a/test/lit.cfg.py b/test/lit.cfg.py index 75a38b4c5dad..856fc75c9d74 100644 --- a/test/lit.cfg.py +++ b/test/lit.cfg.py -@@ -42,6 +42,26 @@ llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True) +@@ -42,6 +42,26 @@ llvm_config.with_environment("PATH", config.llvm_tools_dir, append_path=True) llvm_config.with_system_environment( - ['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP']) + ["HOME", "INCLUDE", "LIB", "TMP", "TEMP"]) +# Add the LLVM dynamic libs to the platform-specific loader search path env var: +# +# TODO: this is copied from `clang`'s `lit.cfg.py`; should unify.. +def find_shlibpath_var(): -+ if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'OpenBSD', 'SunOS']: -+ yield 'LD_LIBRARY_PATH' -+ elif platform.system() == 'Darwin': -+ yield 'DYLD_LIBRARY_PATH' -+ elif platform.system() == 'Windows': -+ yield 'PATH' -+ elif platform.system() == 'AIX': -+ yield 'LIBPATH' ++ if platform.system() in ["Linux", "FreeBSD", "NetBSD", "OpenBSD", "SunOS"]: ++ yield "LD_LIBRARY_PATH" ++ elif platform.system() == "Darwin": ++ yield "DYLD_LIBRARY_PATH" ++ elif platform.system() == "Windows": ++ yield "PATH" ++ elif platform.system() == "AIX": ++ yield "LIBPATH" + +for shlibpath_var in find_shlibpath_var(): + shlibpath = config.llvm_shlib_dir @@ -67,13 +67,14 @@ index 75a38b4c5dad..856fc75c9d74 100644 + .format(platform.system())) # Set up OCAMLPATH to include newly built OCaml libraries. - top_ocaml_lib = os.path.join(config.llvm_lib_dir, 'ocaml') + top_ocaml_lib = os.path.join(config.llvm_lib_dir, "ocaml") @@ -318,7 +338,7 @@ def have_cxx_shared_library(): try: readobj_cmd = subprocess.Popen( -- [readobj_exe, '--needed-libs', readobj_exe], stdout=subprocess.PIPE) -+ [readobj_exe, '--needed-libs', readobj_exe], stdout=subprocess.PIPE, env=config.environment) +- [readobj_exe, "--needed-libs", readobj_exe], stdout=subprocess.PIPE ++ [readobj_exe, "--needed-libs", readobj_exe], stdout=subprocess.PIPE, env=config.environment + ) except OSError: - print('could not exec llvm-readobj') - return False + print("could not exec llvm-readobj") + diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/openmp/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/openmp/default.nix index 52aeb4bd9800..d51335436ad2 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/openmp/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/git/openmp/default.nix @@ -11,6 +11,7 @@ , clang-unwrapped , perl , pkg-config +, xcbuild , version }: @@ -39,6 +40,8 @@ stdenv.mkDerivation rec { (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm) ]; + nativeCheckInputs = lib.optional stdenv.hostPlatform.isDarwin xcbuild.xcrun; + # Unsup:Pass:XFail:Fail # 26:267:16:8 doCheck = false; diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/openmp/fix-find-tool.patch b/nixpkgs/pkgs/development/compilers/llvm/git/openmp/fix-find-tool.patch index 103b054ed176..b7f51196f7ba 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/openmp/fix-find-tool.patch +++ b/nixpkgs/pkgs/development/compilers/llvm/git/openmp/fix-find-tool.patch @@ -1,5 +1,5 @@ diff --git a/libomptarget/DeviceRTL/CMakeLists.txt b/libomptarget/DeviceRTL/CMakeLists.txt -index ce66214822a2..6ab7b33c95da 100644 +index 630947abec7e..9f032dc7bd3f 100644 --- a/libomptarget/DeviceRTL/CMakeLists.txt +++ b/libomptarget/DeviceRTL/CMakeLists.txt @@ -27,10 +27,10 @@ endif() @@ -8,11 +8,10 @@ index ce66214822a2..6ab7b33c95da 100644 # A standalone or LLVM_ENABLE_RUNTIMES=openmp build takes this route - find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) + find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR}) - find_program(LINK_TOOL llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR} -- NO_DEFAULT_PATH) + find_program(PACKAGER_TOOL clang-offload-packager PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) + find_program(LINK_TOOL llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) - find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) -+ ) + find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR}) - if ((NOT CLANG_TOOL) OR (NOT LINK_TOOL) OR (NOT OPT_TOOL)) - libomptarget_say("Not building DeviceRTL. Missing clang: ${CLANG_TOOL}, llvm-link: ${LINK_TOOL} or opt: ${OPT_TOOL}") + if ((NOT CLANG_TOOL) OR (NOT LINK_TOOL) OR (NOT OPT_TOOL) OR (NOT PACKAGER_TOOL)) + libomptarget_say("Not building DeviceRTL. Missing clang: ${CLANG_TOOL}, llvm-link: ${LINK_TOOL}, opt: ${OPT_TOOL}, or clang-offload-packager: ${PACKAGER_TOOL}") return() diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/openmp/run-lit-directly.patch b/nixpkgs/pkgs/development/compilers/llvm/git/openmp/run-lit-directly.patch index 1e952fdc36a8..e69de29bb2d1 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/git/openmp/run-lit-directly.patch +++ b/nixpkgs/pkgs/development/compilers/llvm/git/openmp/run-lit-directly.patch @@ -1,12 +0,0 @@ -diff --git a/cmake/OpenMPTesting.cmake b/cmake/OpenMPTesting.cmake ---- a/cmake/OpenMPTesting.cmake -+++ b/cmake/OpenMPTesting.cmake -@@ -185,7 +185,7 @@ function(add_openmp_testsuite target comment) - if (${OPENMP_STANDALONE_BUILD}) - set(LIT_ARGS ${OPENMP_LIT_ARGS} ${ARG_ARGS}) - add_custom_target(${target} -- COMMAND ${PYTHON_EXECUTABLE} ${OPENMP_LLVM_LIT_EXECUTABLE} ${LIT_ARGS} ${ARG_UNPARSED_ARGUMENTS} -+ COMMAND ${OPENMP_LLVM_LIT_EXECUTABLE} ${LIT_ARGS} ${ARG_UNPARSED_ARGUMENTS} - COMMENT ${comment} - DEPENDS ${ARG_DEPENDS} - USES_TERMINAL |