From 4badff49fda90fba01684d2f19c31442688252b4 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 9 Jan 2022 08:59:00 +0000 Subject: [PATCH] llvmPackages_git.*: Bump to newer commit --- .../compilers/llvm/git/clang/default.nix | 15 +- .../llvm/git/clang/gnu-install-dirs.patch | 42 +-- .../llvm/git/compiler-rt/default.nix | 17 +- .../git/compiler-rt/gnu-install-dirs.patch | 55 ++++ .../compilers/llvm/git/default.nix | 12 +- .../compilers/llvm/git/libcxx/default.nix | 24 +- .../llvm/git/libcxx/gnu-install-dirs.patch | 97 ++++--- .../compilers/llvm/git/libcxxabi/default.nix | 19 +- .../llvm/git/libcxxabi/gnu-install-dirs.patch | 29 +- .../compilers/llvm/git/libunwind/default.nix | 20 +- .../llvm/git/libunwind/gnu-install-dirs.patch | 61 +++- .../compilers/llvm/git/lld/default.nix | 23 +- .../llvm/git/lld/fix-root-src-dir.patch | 13 + .../llvm/git/lld/gnu-install-dirs.patch | 58 +--- .../compilers/llvm/git/lldb/default.nix | 11 +- .../llvm/git/lldb/gnu-install-dirs.patch | 69 +---- .../compilers/llvm/git/llvm/default.nix | 17 +- .../git/llvm/gnu-install-dirs-polly.patch | 17 +- .../llvm/git/llvm/gnu-install-dirs.patch | 273 ++++-------------- .../compilers/llvm/git/openmp/default.nix | 23 +- .../llvm/git/openmp/fix-find-tool.patch | 54 ++++ .../llvm/git/openmp/gnu-install-dirs.patch | 89 ++++++ 22 files changed, 563 insertions(+), 475 deletions(-) create mode 100644 pkgs/development/compilers/llvm/git/compiler-rt/gnu-install-dirs.patch create mode 100644 pkgs/development/compilers/llvm/git/lld/fix-root-src-dir.patch create mode 100644 pkgs/development/compilers/llvm/git/openmp/fix-find-tool.patch create mode 100644 pkgs/development/compilers/llvm/git/openmp/gnu-install-dirs.patch diff --git a/pkgs/development/compilers/llvm/git/clang/default.nix b/pkgs/development/compilers/llvm/git/clang/default.nix index de2eff9f3e375..a4c99949d1074 100644 --- a/pkgs/development/compilers/llvm/git/clang/default.nix +++ b/pkgs/development/compilers/llvm/git/clang/default.nix @@ -1,16 +1,23 @@ -{ lib, stdenv, llvm_meta, src, substituteAll, cmake, libxml2, libllvm, version, python3 +{ lib, stdenv, llvm_meta +, monorepoSrc, runCommand +, substituteAll, cmake, libxml2, libllvm, version, python3 , buildLlvmTools , fixDarwinDylibNames , enableManpages ? false }: let - self = stdenv.mkDerivation ({ + self = stdenv.mkDerivation (rec { pname = "clang"; inherit version; - inherit src; - sourceRoot = "source/clang"; + src = runCommand "${pname}-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${pname} "$out" + ''; + + sourceRoot = "${src.name}/${pname}"; nativeBuildInputs = [ cmake python3 ] ++ lib.optional enableManpages python3.pkgs.sphinx diff --git a/pkgs/development/compilers/llvm/git/clang/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/git/clang/gnu-install-dirs.patch index b834d386b4ebc..a8825f08850e4 100644 --- a/pkgs/development/compilers/llvm/git/clang/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/git/clang/gnu-install-dirs.patch @@ -1,9 +1,9 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 9e74014134a0..976e6a1757fd 100644 +index 7ea37850ad60..ac0f2d4f60b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ cmake_minimum_required(VERSION 3.13.4) - if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) + if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(Clang) + include(GNUInstallDirs) @@ -11,7 +11,7 @@ index 9e74014134a0..976e6a1757fd 100644 set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to") set(CMAKE_CXX_STANDARD_REQUIRED YES) set(CMAKE_CXX_EXTENSIONS NO) -@@ -416,7 +418,7 @@ include_directories(BEFORE +@@ -424,7 +426,7 @@ include_directories(BEFORE if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) install(DIRECTORY include/clang include/clang-c @@ -20,7 +20,7 @@ index 9e74014134a0..976e6a1757fd 100644 COMPONENT clang-headers FILES_MATCHING PATTERN "*.def" -@@ -425,7 +427,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) +@@ -433,7 +435,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) ) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/clang @@ -29,7 +29,7 @@ index 9e74014134a0..976e6a1757fd 100644 COMPONENT clang-headers FILES_MATCHING PATTERN "CMakeFiles" EXCLUDE -@@ -445,7 +447,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) +@@ -453,7 +455,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) add_custom_target(bash-autocomplete DEPENDS utils/bash-autocomplete.sh) install(PROGRAMS utils/bash-autocomplete.sh @@ -39,10 +39,10 @@ index 9e74014134a0..976e6a1757fd 100644 if(NOT LLVM_ENABLE_IDE) add_llvm_install_targets(install-bash-autocomplete diff --git a/cmake/modules/AddClang.cmake b/cmake/modules/AddClang.cmake -index 704278a0e93b..d25c8d325c71 100644 +index 5752f4277444..5bf08dbf5e83 100644 --- a/cmake/modules/AddClang.cmake +++ b/cmake/modules/AddClang.cmake -@@ -123,9 +123,9 @@ macro(add_clang_library name) +@@ -118,9 +118,9 @@ macro(add_clang_library name) install(TARGETS ${lib} COMPONENT ${lib} ${export_to_clangtargets} @@ -55,8 +55,8 @@ index 704278a0e93b..d25c8d325c71 100644 if (NOT LLVM_ENABLE_IDE) add_llvm_install_targets(install-${lib} -@@ -170,7 +170,7 @@ macro(add_clang_tool name) - +@@ -159,7 +159,7 @@ macro(add_clang_tool name) + get_target_export_arg(${name} Clang export_to_clangtargets) install(TARGETS ${name} ${export_to_clangtargets} - RUNTIME DESTINATION bin @@ -64,7 +64,7 @@ index 704278a0e93b..d25c8d325c71 100644 COMPONENT ${name}) if(NOT LLVM_ENABLE_IDE) -@@ -185,7 +185,7 @@ endmacro() +@@ -174,7 +174,7 @@ endmacro() macro(add_clang_symlink name dest) add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE) # Always generate install targets @@ -74,10 +74,10 @@ index 704278a0e93b..d25c8d325c71 100644 function(clang_target_link_libraries target type) diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt -index b2c0ce8dd4a0..19e5443d8c25 100644 +index 078988980c52..14b58614b40a 100644 --- a/lib/Headers/CMakeLists.txt +++ b/lib/Headers/CMakeLists.txt -@@ -215,7 +215,7 @@ set_target_properties(clang-resource-headers PROPERTIES +@@ -234,7 +234,7 @@ set_target_properties(clang-resource-headers PROPERTIES FOLDER "Misc" RUNTIME_OUTPUT_DIRECTORY "${output_dir}") @@ -87,10 +87,10 @@ index b2c0ce8dd4a0..19e5443d8c25 100644 install( FILES ${files} ${generated_files} diff --git a/tools/c-index-test/CMakeLists.txt b/tools/c-index-test/CMakeLists.txt -index ceef4b08637c..8efad5520ca4 100644 +index 99c6081db2d6..0887102febb3 100644 --- a/tools/c-index-test/CMakeLists.txt +++ b/tools/c-index-test/CMakeLists.txt -@@ -54,7 +54,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) +@@ -49,7 +49,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) set_property(TARGET c-index-test APPEND PROPERTY INSTALL_RPATH "@executable_path/../../lib") else() @@ -146,10 +146,10 @@ index cda8e29ec5b1..0134d8ccd70b 100644 + DESTINATION ${CMAKE_INSTALL_DATADIR}/clang COMPONENT clang-rename) diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt -index 51ff2e7e1565..1ed5f8a079a1 100644 +index bf88dca0a34b..7a10181e7738 100644 --- a/tools/libclang/CMakeLists.txt +++ b/tools/libclang/CMakeLists.txt -@@ -166,7 +166,7 @@ endif() +@@ -186,7 +186,7 @@ endif() if(INTERNAL_INSTALL_PREFIX) set(LIBCLANG_HEADERS_INSTALL_DESTINATION "${INTERNAL_INSTALL_PREFIX}/include") else() @@ -158,7 +158,7 @@ index 51ff2e7e1565..1ed5f8a079a1 100644 endif() install(DIRECTORY ../../include/clang-c -@@ -196,7 +196,7 @@ foreach(PythonVersion ${CLANG_PYTHON_BINDINGS_VERSIONS}) +@@ -216,7 +216,7 @@ foreach(PythonVersion ${CLANG_PYTHON_BINDINGS_VERSIONS}) COMPONENT libclang-python-bindings DESTINATION @@ -168,7 +168,7 @@ index 51ff2e7e1565..1ed5f8a079a1 100644 if(NOT LLVM_ENABLE_IDE) add_custom_target(libclang-python-bindings) diff --git a/tools/scan-build/CMakeLists.txt b/tools/scan-build/CMakeLists.txt -index ec0702d76f18..d25d982f51da 100644 +index 74334e53c9b1..ebaae33e4324 100644 --- a/tools/scan-build/CMakeLists.txt +++ b/tools/scan-build/CMakeLists.txt @@ -47,7 +47,7 @@ if(CLANG_INSTALL_SCANBUILD) @@ -199,10 +199,10 @@ index ec0702d76f18..d25d982f51da 100644 endforeach() diff --git a/tools/scan-view/CMakeLists.txt b/tools/scan-view/CMakeLists.txt -index dd3d33439299..fea19c12ce70 100644 +index eccc6b83195b..ff72d9cf0666 100644 --- a/tools/scan-view/CMakeLists.txt +++ b/tools/scan-view/CMakeLists.txt -@@ -19,7 +19,7 @@ if(CLANG_INSTALL_SCANVIEW) +@@ -20,7 +20,7 @@ if(CLANG_INSTALL_SCANVIEW) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile}) list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile}) install(PROGRAMS bin/${BinFile} @@ -211,7 +211,7 @@ index dd3d33439299..fea19c12ce70 100644 COMPONENT scan-view) endforeach() -@@ -33,7 +33,7 @@ if(CLANG_INSTALL_SCANVIEW) +@@ -34,7 +34,7 @@ if(CLANG_INSTALL_SCANVIEW) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/${ShareFile}) list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-view/${ShareFile}) install(FILES share/${ShareFile} diff --git a/pkgs/development/compilers/llvm/git/compiler-rt/default.nix b/pkgs/development/compilers/llvm/git/compiler-rt/default.nix index 019148039d175..59ca5348fed44 100644 --- a/pkgs/development/compilers/llvm/git/compiler-rt/default.nix +++ b/pkgs/development/compilers/llvm/git/compiler-rt/default.nix @@ -1,4 +1,7 @@ -{ lib, stdenv, llvm_meta, version, src, cmake, python3, libllvm, libcxxabi }: +{ lib, stdenv, llvm_meta, version +, monorepoSrc, runCommand +, cmake, python3, libllvm, libcxxabi +}: let @@ -7,14 +10,21 @@ let haveLibc = stdenv.cc.libc != null; inherit (stdenv.hostPlatform) isMusl; + baseName = "compiler-rt"; + + src = runCommand "${baseName}-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${baseName} "$out" + ''; in stdenv.mkDerivation { - pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc"; + pname = baseName + lib.optionalString (haveLibc) "-libc"; inherit version; inherit src; - sourceRoot = "source/compiler-rt"; + sourceRoot = "${src.name}/${baseName}"; nativeBuildInputs = [ cmake python3 libllvm.dev ]; buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; @@ -58,6 +68,7 @@ stdenv.mkDerivation { patches = [ ./codesign.patch # Revert compiler-rt commit that makes codesign mandatory ./X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config + ./gnu-install-dirs.patch # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the # extra `/`. ./normalize-var.patch diff --git a/pkgs/development/compilers/llvm/git/compiler-rt/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/git/compiler-rt/gnu-install-dirs.patch new file mode 100644 index 0000000000000..909b5193ffd88 --- /dev/null +++ b/pkgs/development/compilers/llvm/git/compiler-rt/gnu-install-dirs.patch @@ -0,0 +1,55 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c5003b5efa1d..4fffb9721284 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -5,6 +5,8 @@ + + cmake_minimum_required(VERSION 3.13.4) + ++include(GNUInstallDirs) ++ + # Check if compiler-rt is built as a standalone project. + if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR COMPILER_RT_STANDALONE_BUILD) + project(CompilerRT C CXX ASM) +diff --git a/cmake/base-config-ix.cmake b/cmake/base-config-ix.cmake +index 1ada0ab30ba0..b4be6c4a3c73 100644 +--- a/cmake/base-config-ix.cmake ++++ b/cmake/base-config-ix.cmake +@@ -66,7 +66,7 @@ if (LLVM_TREE_AVAILABLE) + else() + # Take output dir and install path from the user. + set(COMPILER_RT_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH +- "Path where built compiler-rt libraries should be stored.") ++ "Path where built compiler-rt build artifacts should be stored.") + set(COMPILER_RT_EXEC_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/bin CACHE PATH + "Path where built compiler-rt executables should be stored.") + set(COMPILER_RT_INSTALL_PATH "" CACHE PATH +@@ -98,23 +98,23 @@ endif() + if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) + set(COMPILER_RT_OUTPUT_LIBRARY_DIR + ${COMPILER_RT_OUTPUT_DIR}/lib) +- extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" lib) ++ extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_LIBDIR}") + set(COMPILER_RT_INSTALL_LIBRARY_DIR "${default_install_path}" CACHE PATH + "Path where built compiler-rt libraries should be installed.") + else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) + set(COMPILER_RT_OUTPUT_LIBRARY_DIR + ${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR}) +- extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "lib/${COMPILER_RT_OS_DIR}") ++ extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_LIBDIR}/${COMPILER_RT_OS_DIR}") + set(COMPILER_RT_INSTALL_LIBRARY_DIR "${default_install_path}" CACHE PATH + "Path where built compiler-rt libraries should be installed.") + endif() +-extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" bin) ++extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_BINDIR}") + set(COMPILER_RT_INSTALL_BINARY_DIR "${default_install_path}" CACHE PATH + "Path where built compiler-rt executables should be installed.") +-extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" include) ++extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_INCLUDEDIR}") + set(COMPILER_RT_INSTALL_INCLUDE_DIR "${default_install_path}" CACHE PATH + "Path where compiler-rt headers should be installed.") +-extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" share) ++extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_DATADIR}") + set(COMPILER_RT_INSTALL_DATA_DIR "${default_install_path}" CACHE PATH + "Path where compiler-rt data files should be installed.") + diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix index 666e9be3cd89e..8c7da99bcd6da 100644 --- a/pkgs/development/compilers/llvm/git/default.nix +++ b/pkgs/development/compilers/llvm/git/default.nix @@ -21,16 +21,16 @@ let release_version = "14.0.0"; candidate = ""; # empty or "rcN" dash-candidate = lib.optionalString (candidate != "") "-${candidate}"; - rev = "ee65938357d5fffe9e586fa155b37268b5a358ac"; # When using a Git commit - rev-version = "unstable-2021-08-13"; # When using a Git commit + rev = "fb1582f6c54422995c6fb61ba4c55126b357f64e"; # When using a Git commit + rev-version = "unstable-2022-01-07"; # When using a Git commit version = if rev != "" then rev-version else "${release_version}${dash-candidate}"; targetConfig = stdenv.targetPlatform.config; - src = fetchFromGitHub { + monorepoSrc = fetchFromGitHub { owner = "llvm"; repo = "llvm-project"; rev = if rev != "" then rev else "llvmorg-${version}"; - sha256 = "10ahc108wbg2rsp50j3mc8h018a453ykg1rivjkhizng80pyllm1"; + sha256 = "1pkgdsscvf59i22ix763lp2z3sg0v2z2ywh0n07k3ki7q1qpqbhk"; }; llvm_meta = { @@ -40,7 +40,7 @@ let }; tools = lib.makeExtensible (tools: let - callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version src buildLlvmTools; }); + callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version monorepoSrc buildLlvmTools; }); mkExtraBuildCommands0 = cc: '' rsrc="$out/resource-root" mkdir "$rsrc" @@ -214,7 +214,7 @@ let }); libraries = lib.makeExtensible (libraries: let - callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version src; }); + callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version monorepoSrc; }); in { compiler-rt-libc = callPackage ./compiler-rt { diff --git a/pkgs/development/compilers/llvm/git/libcxx/default.nix b/pkgs/development/compilers/llvm/git/libcxx/default.nix index bedfd5afee150..725c14da14999 100644 --- a/pkgs/development/compilers/llvm/git/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/git/libcxx/default.nix @@ -1,4 +1,6 @@ -{ lib, stdenv, llvm_meta, src, cmake, python3, fixDarwinDylibNames, version +{ lib, stdenv, llvm_meta +, monorepoSrc, runCommand +, cmake, python3, fixDarwinDylibNames, version , libcxxabi , enableShared ? !stdenv.hostPlatform.isStatic @@ -10,12 +12,26 @@ , headersOnly ? false }: +let + basename = "libcxx"; +in + stdenv.mkDerivation rec { - pname = if headersOnly then "cxx-headers" else "libcxx"; + pname = basename + lib.optionalString headersOnly "-headers"; inherit version; - inherit src; - sourceRoot = "source/libcxx"; + src = runCommand "${pname}-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${basename} "$out" + mkdir -p "$out/libcxxabi" + cp -r ${monorepoSrc}/libcxxabi/include "$out/libcxxabi" + mkdir -p "$out/llvm" + cp -r ${monorepoSrc}/llvm/cmake "$out/llvm" + cp -r ${monorepoSrc}/llvm/utils "$out/llvm" + ''; + + sourceRoot = "${src.name}/${basename}"; outputs = [ "out" ] ++ lib.optional (!headersOnly) "dev"; diff --git a/pkgs/development/compilers/llvm/git/libcxx/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/git/libcxx/gnu-install-dirs.patch index 744967a6ee0bd..0f1d5c411ab8f 100644 --- a/pkgs/development/compilers/llvm/git/libcxx/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/git/libcxx/gnu-install-dirs.patch @@ -1,82 +1,85 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index b1e25358d41a..7fe1f4d85401 100644 +index b0569a4a54ca..7d665f5a3258 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -26,6 +26,8 @@ set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build") - if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXX_STANDALONE_BUILD) - project(libcxx CXX C) +@@ -10,6 +10,8 @@ endif() + #=============================================================================== + cmake_minimum_required(VERSION 3.13.4) -+ include(GNUInstallDirs) ++include(GNUInstallDirs) + - set(PACKAGE_NAME libcxx) - set(PACKAGE_VERSION 13.0.0git) - set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") -@@ -412,7 +414,7 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) + set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") + + # Add path for custom modules +@@ -415,13 +417,13 @@ 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 ++ 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_DIR "include/c++/v1" CACHE PATH +- set(LIBCXX_INSTALL_RUNTIME_DIR bin CACHE PATH ++ set(LIBCXX_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH + "Path where built libc++ runtime libraries should be installed.") +- set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH ++ set(LIBCXX_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE PATH "Path where target-agnostic libc++ headers should be installed.") -@@ -426,7 +428,7 @@ elseif(LLVM_LIBRARY_OUTPUT_INTDIR) +- set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH ++ 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.") + if(LIBCXX_LIBDIR_SUBDIR) + string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR}) +@@ -431,11 +433,11 @@ elseif(LLVM_LIBRARY_OUTPUT_INTDIR) set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") 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_DIR "include/c++/v1" CACHE PATH +- set(LIBCXX_INSTALL_RUNTIME_DIR bin CACHE PATH ++ set(LIBCXX_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}/c++/v1" CACHE PATH + "Path where built libc++ runtime libraries should be installed.") +- set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH ++ set(LIBCXX_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE PATH "Path where target-agnostic libc++ headers should be installed.") -@@ -436,7 +438,7 @@ else() + set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH + "Path where target-specific libc++ headers should be installed.") +@@ -443,11 +445,11 @@ else() set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") 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_DIR "include/c++/v1" CACHE PATH +- set(LIBCXX_INSTALL_RUNTIME_DIR bin CACHE PATH ++ set(LIBCXX_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH + "Path where built libc++ runtime libraries should be installed.") +- set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH ++ set(LIBCXX_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE PATH "Path where target-agnostic libc++ headers 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/cmake/Modules/HandleLibCXXABI.cmake b/cmake/Modules/HandleLibCXXABI.cmake -index 5a8a4a270a1a..c06bae0001aa 100644 +index 5a8a4a270a1a..d69405ddeeac 100644 --- a/cmake/Modules/HandleLibCXXABI.cmake +++ b/cmake/Modules/HandleLibCXXABI.cmake -@@ -63,7 +63,7 @@ macro(setup_abi_lib abidefines abishared abistatic abifiles abidirs) +@@ -1,8 +1,9 @@ +- + #=============================================================================== + # Add an ABI library if appropriate + #=============================================================================== + ++include(GNUInstallDirs) ++ + # + # _setup_abi: Set up the build to use an ABI library + # +@@ -63,7 +64,7 @@ macro(setup_abi_lib abidefines abishared abistatic abifiles abidirs) if (LIBCXX_INSTALL_HEADERS) install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}" - DESTINATION include/c++/v1/${dstdir} -+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/c++/v1/${dstdir} ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1/${dstdir}" COMPONENT cxx-headers PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) -diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index 496429f3841e..1a0c9c0a3159 100644 ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -376,21 +376,21 @@ if (LIBCXX_INSTALL_SHARED_LIBRARY) - install(TARGETS cxx_shared - ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx - LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx -- RUNTIME DESTINATION bin COMPONENT cxx) -+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT cxx) - endif() - - if (LIBCXX_INSTALL_STATIC_LIBRARY) - install(TARGETS cxx_static - ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx - LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx -- RUNTIME DESTINATION bin COMPONENT cxx) -+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT cxx) - endif() - - if(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY) - install(TARGETS cxx_experimental - LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx - ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx -- RUNTIME DESTINATION bin COMPONENT cxx) -+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT cxx) - endif() - - # NOTE: This install command must go after the cxx install command otherwise diff --git a/pkgs/development/compilers/llvm/git/libcxxabi/default.nix b/pkgs/development/compilers/llvm/git/libcxxabi/default.nix index 9f14f87a7a024..d64708ab040ae 100644 --- a/pkgs/development/compilers/llvm/git/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/git/libcxxabi/default.nix @@ -1,4 +1,6 @@ -{ lib, stdenv, llvm_meta, cmake, python3, src, cxx-headers, libunwind, version +{ lib, stdenv, llvm_meta, cmake, python3 +, monorepoSrc, runCommand +, cxx-headers, libunwind, version , enableShared ? !stdenv.hostPlatform.isStatic }: @@ -6,8 +8,19 @@ stdenv.mkDerivation rec { pname = "libcxxabi"; inherit version; - inherit src; - sourceRoot = "source/${pname}"; + src = runCommand "${pname}-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${pname} "$out" + mkdir -p "$out/libcxx/src" + cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx" + cp -r ${monorepoSrc}/libcxx/include "$out/libcxx" + cp -r ${monorepoSrc}/libcxx/src/include "$out/libcxx/src" + mkdir -p "$out/llvm" + cp -r ${monorepoSrc}/llvm/cmake "$out/llvm" + ''; + + sourceRoot = "${src.name}/${pname}"; outputs = [ "out" "dev" ]; diff --git a/pkgs/development/compilers/llvm/git/libcxxabi/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/git/libcxxabi/gnu-install-dirs.patch index 5d562dd59a992..a93348ded0c10 100644 --- a/pkgs/development/compilers/llvm/git/libcxxabi/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/git/libcxxabi/gnu-install-dirs.patch @@ -1,37 +1,46 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 9fb35860d483..5739d9e8af62 100644 +index 858f5d5cfd7f..16c67d7062be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -27,6 +27,8 @@ set(LIBCXXABI_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH - if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXXABI_STANDALONE_BUILD) - project(libcxxabi CXX C) +@@ -10,6 +10,8 @@ endif() -+ include(GNUInstallDirs) + cmake_minimum_required(VERSION 3.13.4) + ++include(GNUInstallDirs) + - set(PACKAGE_NAME libcxxabi) - set(PACKAGE_VERSION 11.0.0git) - set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") -@@ -195,7 +197,7 @@ set(CMAKE_MODULE_PATH + set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") + + # Add path for custom modules +@@ -213,9 +215,9 @@ set(CMAKE_MODULE_PATH 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 ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH "Path where built libc++abi libraries should be installed.") +- set(LIBCXXABI_INSTALL_RUNTIME_DIR bin CACHE PATH ++ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH + "Path where built libc++abi runtime libraries should be installed.") if(LIBCXX_LIBDIR_SUBDIR) string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR}) -@@ -204,12 +206,12 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) +@@ -224,16 +226,16 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) elseif(LLVM_LIBRARY_OUTPUT_INTDIR) set(LIBCXXABI_HEADER_DIR ${LLVM_BINARY_DIR}) set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) - set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH + set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH "Path where built libc++abi libraries should be installed.") +- set(LIBCXXABI_INSTALL_RUNTIME_DIR bin CACHE PATH ++ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH + "Path where built libc++abi runtime libraries should be installed.") else() set(LIBCXXABI_HEADER_DIR ${CMAKE_BINARY_DIR}) set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX}) - set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH + set(LIBCXXABI_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBCXXABI_LIBDIR_SUFFIX} CACHE PATH "Path where built libc++abi libraries should be installed.") +- set(LIBCXXABI_INSTALL_RUNTIME_DIR bin CACHE PATH ++ set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH + "Path where built libc++abi runtime libraries should be installed.") endif() diff --git a/pkgs/development/compilers/llvm/git/libunwind/default.nix b/pkgs/development/compilers/llvm/git/libunwind/default.nix index b6017e7417289..c6d9eda5e4749 100644 --- a/pkgs/development/compilers/llvm/git/libunwind/default.nix +++ b/pkgs/development/compilers/llvm/git/libunwind/default.nix @@ -1,4 +1,6 @@ -{ lib, stdenv, llvm_meta, version, src, cmake +{ lib, stdenv, llvm_meta, version +, monorepoSrc, runCommand +, cmake , enableShared ? !stdenv.hostPlatform.isStatic }: @@ -6,8 +8,20 @@ stdenv.mkDerivation rec { pname = "libunwind"; inherit version; - inherit src; - sourceRoot = "source/${pname}"; + # I am not so comfortable giving libc++ and friends the whole monorepo as + # requested, so I filter it to what is needed. + src = runCommand "${pname}-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${pname} "$out" + mkdir -p "$out/libcxx" + cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx" + cp -r ${monorepoSrc}/libcxx/utils "$out/libcxx" + mkdir -p "$out/llvm" + cp -r ${monorepoSrc}/llvm/cmake "$out/llvm" + ''; + + sourceRoot = "${src.name}/${pname}"; patches = [ ./gnu-install-dirs.patch diff --git a/pkgs/development/compilers/llvm/git/libunwind/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/git/libunwind/gnu-install-dirs.patch index 8cd25c56f8ccc..3f05d2a87269c 100644 --- a/pkgs/development/compilers/llvm/git/libunwind/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/git/libunwind/gnu-install-dirs.patch @@ -1,36 +1,65 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 81eddbc24879..e2afb2002150 100644 +index e3cc66dd2226..1299b596ce0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -23,6 +23,8 @@ set(LIBUNWIND_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH - if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBUNWIND_STANDALONE_BUILD) - project(libunwind LANGUAGES C CXX ASM) +@@ -8,6 +8,8 @@ endif() -+ include(GNUInstallDirs) + cmake_minimum_required(VERSION 3.13.4) + ++include(GNUInstallDirs) + - set(PACKAGE_NAME libunwind) - set(PACKAGE_VERSION 13.0.0git) - set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") -@@ -116,7 +118,7 @@ set(CMAKE_MODULE_PATH + set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") + + # Add path for custom modules +@@ -139,25 +141,27 @@ set(CMAKE_MODULE_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_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}" CACHE PATH ++ "Path where built libunwind headers should be installed.") + 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.") +- set(LIBUNWIND_INSTALL_RUNTIME_DIR bin CACHE PATH ++ set(LIBUNWIND_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH + "Path where built libunwind runtime libraries should be installed.") if(LIBCXX_LIBDIR_SUBDIR) string(APPEND LIBUNWIND_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR}) -@@ -124,11 +126,11 @@ if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) + string(APPEND LIBUNWIND_INSTALL_LIBRARY_DIR /${LIBUNWIND_LIBDIR_SUBDIR}) endif() - elseif(LLVM_LIBRARY_OUTPUT_INTDIR) - set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) +-elseif(LLVM_LIBRARY_OUTPUT_INTDIR) +- set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) - set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH -+ set(LIBUNWIND_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} CACHE PATH - "Path where built libunwind libraries should be installed.") +- "Path where built libunwind libraries should be installed.") +- set(LIBUNWIND_INSTALL_RUNTIME_DIR bin CACHE PATH +- "Path where built libunwind runtime libraries should be installed.") else() - set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX}) +- set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX}) - set(LIBUNWIND_INSTALL_LIBRARY_DIR lib${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH -+ set(LIBUNWIND_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} CACHE PATH ++ if(LLVM_LIBRARY_OUTPUT_INTDIR) ++ set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) ++ else() ++ set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX}) ++ endif() ++ set(LIBUNWIND_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}" CACHE PATH ++ "Path where built libunwind headers should be installed.") ++ set(LIBUNWIND_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}${LIBUNWIND_LIBDIR_SUFFIX} CACHE PATH "Path where built libunwind libraries should be installed.") +- set(LIBUNWIND_INSTALL_RUNTIME_DIR bin CACHE PATH ++ set(LIBUNWIND_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH + "Path where built libunwind runtime libraries should be installed.") endif() +diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt +index c3bb1dd0f69f..adf1766c44cb 100644 +--- a/include/CMakeLists.txt ++++ b/include/CMakeLists.txt +@@ -14,7 +14,7 @@ if(LIBUNWIND_INSTALL_HEADERS) + foreach(file ${files}) + get_filename_component(dir ${file} DIRECTORY) + install(FILES ${file} +- DESTINATION "include/${dir}" ++ DESTINATION "${LIBUNWIND_INSTALL_INCLUDE_DIR}/${dir}" + COMPONENT unwind-headers + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + ) diff --git a/pkgs/development/compilers/llvm/git/lld/default.nix b/pkgs/development/compilers/llvm/git/lld/default.nix index 34ac265f4bfd0..cdd2f5f0fa7fa 100644 --- a/pkgs/development/compilers/llvm/git/lld/default.nix +++ b/pkgs/development/compilers/llvm/git/lld/default.nix @@ -1,6 +1,6 @@ { lib, stdenv, llvm_meta , buildLlvmTools -, src +, monorepoSrc, runCommand , cmake , libxml2 , libllvm @@ -11,19 +11,30 @@ stdenv.mkDerivation rec { pname = "lld"; inherit version; - inherit src; - sourceRoot = "source/${pname}"; + # Blank llvm dir just so relative path works + src = runCommand "${pname}-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${pname} "$out" + mkdir -p "$out/libunwind" + cp -r ${monorepoSrc}/libunwind/include "$out/libunwind" + mkdir -p "$out/llvm" + ''; + + sourceRoot = "${src.name}/${pname}"; patches = [ ./gnu-install-dirs.patch + # On Darwin the llvm-config is perhaps not working fine as the + # LLVM_MAIN_SRC_DIR is not getting set correctly, and the build fails as + # the include path is not correct. + ./fix-root-src-dir.patch ]; nativeBuildInputs = [ cmake ]; buildInputs = [ libllvm libxml2 ]; - cmakeFlags = [ - "-DLLVM_CONFIG_PATH=${libllvm.dev}/bin/llvm-config${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native"}" - ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + cmakeFlags = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" ]; diff --git a/pkgs/development/compilers/llvm/git/lld/fix-root-src-dir.patch b/pkgs/development/compilers/llvm/git/lld/fix-root-src-dir.patch new file mode 100644 index 0000000000000..26ecef2564952 --- /dev/null +++ b/pkgs/development/compilers/llvm/git/lld/fix-root-src-dir.patch @@ -0,0 +1,13 @@ +diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt +index e1a29b884d17..9d542f8fbfc1 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -64,7 +64,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + + set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include") + 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_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path to LLVM source tree") + + find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} + NO_DEFAULT_PATH) diff --git a/pkgs/development/compilers/llvm/git/lld/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/git/lld/gnu-install-dirs.patch index 61e2f0e486536..89a5822df49cb 100644 --- a/pkgs/development/compilers/llvm/git/lld/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/git/lld/gnu-install-dirs.patch @@ -1,68 +1,22 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index d4e561b50d8f..cfa5bdd79c2a 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -6,6 +6,8 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - set(CMAKE_INCLUDE_CURRENT_DIR ON) - set(LLD_BUILT_STANDALONE TRUE) - -+ include(GNUInstallDirs) -+ - find_program(LLVM_CONFIG_PATH "llvm-config" DOC "Path to llvm-config binary") - if(NOT LLVM_CONFIG_PATH) - message(FATAL_ERROR "llvm-config not found: specify LLVM_CONFIG_PATH") -@@ -179,7 +181,7 @@ include_directories(BEFORE - - if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) - install(DIRECTORY include/ -- DESTINATION include -+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - FILES_MATCHING - PATTERN "*.h" - ) diff --git a/cmake/modules/AddLLD.cmake b/cmake/modules/AddLLD.cmake -index 23df41312403..d62372c88de7 100644 +index dd2898ce6236..ebbea040ff54 100644 --- a/cmake/modules/AddLLD.cmake +++ b/cmake/modules/AddLLD.cmake -@@ -20,9 +20,9 @@ macro(add_lld_library name) +@@ -18,8 +18,8 @@ macro(add_lld_library name) install(TARGETS ${name} COMPONENT ${name} ${export_to_lldtargets} - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} -- RUNTIME DESTINATION bin) -+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} -+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} -+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ++ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ++ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES) - add_llvm_install_targets(install-${name} -@@ -54,7 +54,7 @@ macro(add_lld_tool name) - - install(TARGETS ${name} - ${export_to_lldtargets} -- RUNTIME DESTINATION bin -+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT ${name}) - - if(NOT CMAKE_CONFIGURATION_TYPES) -@@ -69,5 +69,5 @@ endmacro() +@@ -62,5 +62,5 @@ endmacro() macro(add_lld_symlink name dest) add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE) # Always generate install targets - llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE) + llvm_install_symlink(${name} ${dest} ${CMAKE_INSTALL_FULL_BINDIR} ALWAYS_GENERATE) endmacro() -diff --git a/tools/lld/CMakeLists.txt b/tools/lld/CMakeLists.txt -index 5cff736ff57f..64e775c771b9 100644 ---- a/tools/lld/CMakeLists.txt -+++ b/tools/lld/CMakeLists.txt -@@ -21,7 +21,7 @@ target_link_libraries(lld - ) - - install(TARGETS lld -- RUNTIME DESTINATION bin) -+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - - if(NOT LLD_SYMLINKS_TO_CREATE) - set(LLD_SYMLINKS_TO_CREATE diff --git a/pkgs/development/compilers/llvm/git/lldb/default.nix b/pkgs/development/compilers/llvm/git/lldb/default.nix index 96d8b19ee419c..a2c68b224775e 100644 --- a/pkgs/development/compilers/llvm/git/lldb/default.nix +++ b/pkgs/development/compilers/llvm/git/lldb/default.nix @@ -1,6 +1,6 @@ { lib, stdenv, llvm_meta , runCommand -, src +, monorepoSrc , cmake , zlib , ncurses @@ -27,8 +27,13 @@ stdenv.mkDerivation (rec { pname = "lldb"; inherit version; - inherit src; - sourceRoot = "source/${pname}"; + src = runCommand "${pname}-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${pname} "$out" + ''; + + sourceRoot = "${src.name}/${pname}"; patches = [ ./procfs.patch diff --git a/pkgs/development/compilers/llvm/git/lldb/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/git/lldb/gnu-install-dirs.patch index afc945ce26147..f69ed9e162fb4 100644 --- a/pkgs/development/compilers/llvm/git/lldb/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/git/lldb/gnu-install-dirs.patch @@ -1,8 +1,8 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index b5633e21c56a..f2f1035e9238 100644 +index 79d451965ed4..78188978d6de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -10,6 +10,8 @@ set(CMAKE_MODULE_PATH +@@ -12,6 +12,8 @@ set(CMAKE_MODULE_PATH # If we are not building as part of LLVM, build LLDB as a standalone project, # using LLVM as an external library. if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) @@ -12,10 +12,10 @@ index b5633e21c56a..f2f1035e9238 100644 include(LLDBStandalone) diff --git a/cmake/modules/AddLLDB.cmake b/cmake/modules/AddLLDB.cmake -index 4ed5c647c5d2..89f96e710d55 100644 +index 3291a7c808e1..b27d27ce6a87 100644 --- a/cmake/modules/AddLLDB.cmake +++ b/cmake/modules/AddLLDB.cmake -@@ -107,13 +107,13 @@ function(add_lldb_library name) +@@ -109,7 +109,7 @@ function(add_lldb_library name) endif() if(PARAM_SHARED) @@ -24,68 +24,13 @@ index 4ed5c647c5d2..89f96e710d55 100644 if(PARAM_INSTALL_PREFIX) set(install_dest ${PARAM_INSTALL_PREFIX}) endif() - # RUNTIME is relevant for DLL platforms, FRAMEWORK for macOS - install(TARGETS ${name} COMPONENT ${name} -- RUNTIME DESTINATION bin -+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${install_dest} - ARCHIVE DESTINATION ${install_dest} - FRAMEWORK DESTINATION ${install_dest}) -diff --git a/cmake/modules/LLDBConfig.cmake b/cmake/modules/LLDBConfig.cmake -index 2fdf1502d055..37364341ff8b 100644 ---- a/cmake/modules/LLDBConfig.cmake -+++ b/cmake/modules/LLDBConfig.cmake -@@ -225,7 +225,7 @@ include_directories(BEFORE - if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) - install(DIRECTORY include/ - COMPONENT lldb-headers -- DESTINATION include -+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - FILES_MATCHING - PATTERN "*.h" - PATTERN ".cmake" EXCLUDE -@@ -233,7 +233,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) - - install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/ - COMPONENT lldb-headers -- DESTINATION include -+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - FILES_MATCHING - PATTERN "*.h" - PATTERN ".cmake" EXCLUDE diff --git a/tools/intel-features/CMakeLists.txt b/tools/intel-features/CMakeLists.txt -index 734167e51bc5..f95761b5df58 100644 +index 7d48491ec89a..c04543585588 100644 --- a/tools/intel-features/CMakeLists.txt +++ b/tools/intel-features/CMakeLists.txt -@@ -65,4 +65,4 @@ if (LLDB_ENABLE_PYTHON AND LLDB_BUILD_INTEL_PT) - endif() +@@ -30,4 +30,4 @@ add_lldb_library(lldbIntelFeatures SHARED + ) install(TARGETS lldbIntelFeatures - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}) + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) -diff --git a/cmake/modules/LLDBStandalone.cmake b/cmake/modules/LLDBStandalone.cmake -index 752113b..010f187 100644 ---- a/cmake/modules/LLDBStandalone.cmake -+++ b/cmake/modules/LLDBStandalone.cmake -@@ -62,7 +62,7 @@ endif() - - # They are used as destination of target generators. - set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin) --set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}) -+set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}) - if(WIN32 OR CYGWIN) - # DLL platform -- put DLLs into bin. - set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) -diff --git a/CMakeLists.txt b/CMakeLists.txt -index b5633e2..86e4738 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -79,7 +79,7 @@ if (LLDB_ENABLE_PYTHON) - if(LLDB_BUILD_FRAMEWORK) - set(lldb_python_target_dir "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb") - else() -- set(lldb_python_target_dir "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb") -+ set(lldb_python_target_dir "${CMAKE_INSTALL_LIBDIR}/../${LLDB_PYTHON_RELATIVE_PATH}/lldb") - endif() - get_target_property(lldb_python_bindings_dir swig_wrapper_python BINARY_DIR) - finish_swig_python("lldb-python" "${lldb_python_bindings_dir}" "${lldb_python_target_dir}") diff --git a/pkgs/development/compilers/llvm/git/llvm/default.nix b/pkgs/development/compilers/llvm/git/llvm/default.nix index 4c895f81dbbac..c76778193adf0 100644 --- a/pkgs/development/compilers/llvm/git/llvm/default.nix +++ b/pkgs/development/compilers/llvm/git/llvm/default.nix @@ -1,6 +1,7 @@ { lib, stdenv, llvm_meta , pkgsBuildBuild -, src +, monorepoSrc +, runCommand , fetchpatch , cmake , python3 @@ -22,7 +23,7 @@ || stdenv.isAarch32 # broken for the armv7l builder ) , enablePolly ? false -}: +} @args: let inherit (lib) optional optionals optionalString; @@ -35,8 +36,16 @@ in stdenv.mkDerivation (rec { pname = "llvm"; inherit version; - inherit src; - sourceRoot = "source/${pname}"; + src = runCommand "${pname}-src-${version}" {} ('' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${pname} "$out" + cp -r ${monorepoSrc}/third-party "$out" + '' + lib.optionalString enablePolly '' + cp -r ${monorepoSrc}/polly "$out/llvm/tools" + ''); + + sourceRoot = "${src.name}/${pname}"; outputs = [ "out" "lib" "dev" "python" ]; diff --git a/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs-polly.patch b/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs-polly.patch index 68f3c45396f67..98e998e65a961 100644 --- a/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs-polly.patch +++ b/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs-polly.patch @@ -1,20 +1,17 @@ diff --git a/tools/polly/CMakeLists.txt b/tools/polly/CMakeLists.txt -index ca7c04c565bb..6ed5db5dd4f8 100644 +index ca7c04c565bb..6a6155806ffa 100644 --- a/tools/polly/CMakeLists.txt +++ b/tools/polly/CMakeLists.txt -@@ -2,7 +2,11 @@ - if (NOT DEFINED LLVM_MAIN_SRC_DIR) +@@ -3,6 +3,8 @@ if (NOT DEFINED LLVM_MAIN_SRC_DIR) project(Polly) cmake_minimum_required(VERSION 3.13.4) -+endif() -+ -+include(GNUInstallDirs) -+if (NOT DEFINED LLVM_MAIN_SRC_DIR) ++ include(GNUInstallDirs) ++ # Where is LLVM installed? find_package(LLVM CONFIG REQUIRED) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR}) -@@ -122,13 +126,13 @@ include_directories( +@@ -122,13 +124,13 @@ include_directories( if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) install(DIRECTORY include/ @@ -91,10 +88,10 @@ index 518a09b45a42..bd9d6f5542ad 100644 set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) endmacro(add_polly_library) diff --git a/tools/polly/lib/External/CMakeLists.txt b/tools/polly/lib/External/CMakeLists.txt -index 8991094d92c7..178d8ad606bb 100644 +index e3a5683fccdc..293b482eb28a 100644 --- a/tools/polly/lib/External/CMakeLists.txt +++ b/tools/polly/lib/External/CMakeLists.txt -@@ -275,7 +275,7 @@ if (POLLY_BUNDLED_ISL) +@@ -290,7 +290,7 @@ if (POLLY_BUNDLED_ISL) install(DIRECTORY ${ISL_SOURCE_DIR}/include/ ${ISL_BINARY_DIR}/include/ diff --git a/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch index 18fa5fc6d89c7..55862ab393045 100644 --- a/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch @@ -1,23 +1,10 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 135036f509d2..265c36f8211b 100644 +index fec956091cd5..5a766f5c5d7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -270,15 +270,21 @@ if (CMAKE_BUILD_TYPE AND - message(FATAL_ERROR "Invalid value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") - endif() - -+include(GNUInstallDirs) -+ - set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" ) - --set(LLVM_TOOLS_INSTALL_DIR "bin" CACHE STRING "Path for binary subdirectory (defaults to 'bin')") -+set(LLVM_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING -+ "Path for binary subdirectory (defaults to 'bin')") - mark_as_advanced(LLVM_TOOLS_INSTALL_DIR) - - set(LLVM_UTILS_INSTALL_DIR "${LLVM_TOOLS_INSTALL_DIR}" CACHE STRING - "Path to install LLVM utilities (enabled by LLVM_INSTALL_UTILS=ON) (defaults to LLVM_TOOLS_INSTALL_DIR)") - mark_as_advanced(LLVM_UTILS_INSTALL_DIR) +@@ -303,6 +303,9 @@ set(LLVM_EXAMPLES_INSTALL_DIR "examples" CACHE STRING + "Path for examples subdirectory (enabled by LLVM_BUILD_EXAMPLES=ON) (defaults to 'examples')") + mark_as_advanced(LLVM_EXAMPLES_INSTALL_DIR) +set(LLVM_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/cmake/llvm" CACHE STRING + "Path for CMake subdirectory (defaults to lib/cmake/llvm)" ) @@ -25,70 +12,22 @@ index 135036f509d2..265c36f8211b 100644 # They are used as destination of target generators. set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin) set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}) -@@ -581,9 +587,9 @@ option (LLVM_ENABLE_SPHINX "Use Sphinx to generate llvm documentation." OFF) - option (LLVM_ENABLE_OCAMLDOC "Build OCaml bindings documentation." ON) - option (LLVM_ENABLE_BINDINGS "Build bindings." ON) - --set(LLVM_INSTALL_DOXYGEN_HTML_DIR "share/doc/llvm/doxygen-html" -+set(LLVM_INSTALL_DOXYGEN_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/${project}/doxygen-html" - CACHE STRING "Doxygen-generated HTML documentation install directory") --set(LLVM_INSTALL_OCAMLDOC_HTML_DIR "share/doc/llvm/ocaml-html" -+set(LLVM_INSTALL_OCAMLDOC_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/${project}/ocaml-html" - CACHE STRING "OCamldoc-generated HTML documentation install directory") - - option (LLVM_BUILD_EXTERNAL_COMPILER_RT -@@ -1048,7 +1054,7 @@ endif() - - if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) - install(DIRECTORY include/llvm include/llvm-c -- DESTINATION include -+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - COMPONENT llvm-headers - FILES_MATCHING - PATTERN "*.def" -@@ -1059,7 +1065,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) - ) - - install(DIRECTORY ${LLVM_INCLUDE_DIR}/llvm ${LLVM_INCLUDE_DIR}/llvm-c -- DESTINATION include -+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - COMPONENT llvm-headers - FILES_MATCHING - PATTERN "*.def" -@@ -1073,13 +1079,13 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) - - if (LLVM_INSTALL_MODULEMAPS) - install(DIRECTORY include/llvm include/llvm-c -- DESTINATION include -+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - COMPONENT llvm-headers - FILES_MATCHING - PATTERN "module.modulemap" - ) - install(FILES include/llvm/module.install.modulemap -- DESTINATION include/llvm -+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/llvm - COMPONENT llvm-headers - RENAME "module.extern.modulemap" - ) diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake -index 9c2b85374307..5531ceeb2eeb 100644 +index fed1fec7d72e..4baed19b9e98 100644 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake -@@ -818,9 +818,9 @@ macro(add_llvm_library name) +@@ -838,8 +838,8 @@ macro(add_llvm_library name) get_target_export_arg(${name} LLVM export_to_llvmexports ${umbrella}) install(TARGETS ${name} ${export_to_llvmexports} - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name} - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name} -- RUNTIME DESTINATION bin COMPONENT ${name}) -+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} COMPONENT ${name} -+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} COMPONENT ${name} -+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${name}) ++ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" COMPONENT ${name} ++ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" COMPONENT ${name} + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name}) if (NOT LLVM_ENABLE_IDE) - add_llvm_install_targets(install-${name} -@@ -1036,7 +1036,7 @@ function(process_llvm_pass_plugins) +@@ -1056,7 +1056,7 @@ function(process_llvm_pass_plugins) "set(LLVM_STATIC_EXTENSIONS ${LLVM_STATIC_EXTENSIONS})") install(FILES ${llvm_cmake_builddir}/LLVMConfigExtensions.cmake @@ -97,16 +36,7 @@ index 9c2b85374307..5531ceeb2eeb 100644 COMPONENT cmake-exports) set(ExtensionDef "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def") -@@ -1250,7 +1250,7 @@ macro(add_llvm_example name) - endif() - add_llvm_executable(${name} ${ARGN}) - if( LLVM_BUILD_EXAMPLES ) -- install(TARGETS ${name} RUNTIME DESTINATION examples) -+ install(TARGETS ${name} RUNTIME DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples) - endif() - set_target_properties(${name} PROPERTIES FOLDER "Examples") - endmacro(add_llvm_example name) -@@ -1868,7 +1868,7 @@ function(llvm_install_library_symlink name dest type) +@@ -1902,7 +1902,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}) @@ -115,7 +45,7 @@ index 9c2b85374307..5531ceeb2eeb 100644 if(WIN32 AND "${type}" STREQUAL "SHARED") set(output_dir bin) endif() -@@ -1879,7 +1879,7 @@ function(llvm_install_library_symlink name dest type) +@@ -1913,7 +1913,7 @@ function(llvm_install_library_symlink name dest type) endfunction() @@ -124,7 +54,7 @@ index 9c2b85374307..5531ceeb2eeb 100644 cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN}) foreach(path ${CMAKE_MODULE_PATH}) if(EXISTS ${path}/LLVMInstallSymlink.cmake) -@@ -1902,7 +1902,7 @@ function(llvm_install_symlink name dest) +@@ -1936,7 +1936,7 @@ function(llvm_install_symlink name dest) set(full_dest ${dest}${CMAKE_EXECUTABLE_SUFFIX}) install(SCRIPT ${INSTALL_SYMLINK} @@ -133,7 +63,7 @@ index 9c2b85374307..5531ceeb2eeb 100644 COMPONENT ${component}) if (NOT LLVM_ENABLE_IDE AND NOT ARG_ALWAYS_GENERATE) -@@ -1985,7 +1985,8 @@ function(add_llvm_tool_symlink link_name target) +@@ -2019,7 +2019,8 @@ function(add_llvm_tool_symlink link_name target) endif() if ((TOOL_IS_TOOLCHAIN OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) AND LLVM_BUILD_TOOLS) @@ -143,7 +73,7 @@ index 9c2b85374307..5531ceeb2eeb 100644 endif() endif() endfunction() -@@ -2114,9 +2115,9 @@ function(llvm_setup_rpath name) +@@ -2148,9 +2149,9 @@ function(llvm_setup_rpath name) # Since BUILD_SHARED_LIBS is only recommended for use by developers, # hardcode the rpath to build/install lib dir first in this mode. # FIXME: update this when there is better solution. @@ -156,10 +86,10 @@ index 9c2b85374307..5531ceeb2eeb 100644 set_property(TARGET ${name} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-z,origin ") diff --git a/cmake/modules/AddOCaml.cmake b/cmake/modules/AddOCaml.cmake -index 554046b20edf..4d1ad980641e 100644 +index 891c9e6d618c..8d963f3b0069 100644 --- a/cmake/modules/AddOCaml.cmake +++ b/cmake/modules/AddOCaml.cmake -@@ -144,9 +144,9 @@ function(add_ocaml_library name) +@@ -147,9 +147,9 @@ function(add_ocaml_library name) endforeach() if( APPLE ) @@ -171,86 +101,55 @@ index 554046b20edf..4d1ad980641e 100644 endif() list(APPEND ocaml_flags "-ldopt" "-Wl,-rpath,${ocaml_rpath}") -diff --git a/cmake/modules/AddSphinxTarget.cmake b/cmake/modules/AddSphinxTarget.cmake -index e80c3b5c1cac..482f6d715ef5 100644 ---- a/cmake/modules/AddSphinxTarget.cmake -+++ b/cmake/modules/AddSphinxTarget.cmake -@@ -90,7 +90,7 @@ function (add_sphinx_target builder project) - endif() - elseif (builder STREQUAL html) - string(TOUPPER "${project}" project_upper) -- set(${project_upper}_INSTALL_SPHINX_HTML_DIR "share/doc/${project}/html" -+ set(${project_upper}_INSTALL_SPHINX_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/${project}/html" - CACHE STRING "HTML documentation install directory for ${project}") - - # '/.' indicates: copy the contents of the directory directly into diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt -index 51b6a4fdc284..4adc2acfc074 100644 +index cea0c1df0a14..eedcd9450312 100644 --- a/cmake/modules/CMakeLists.txt +++ b/cmake/modules/CMakeLists.txt -@@ -1,6 +1,6 @@ +@@ -2,7 +2,7 @@ include(ExtendPath) include(LLVMDistributionSupport) + include(FindPrefixFromConfig) -set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm) +set(LLVM_INSTALL_PACKAGE_DIR ${LLVM_INSTALL_CMAKE_DIR} CACHE STRING "Path for CMake subdirectory (defaults to 'cmake/llvm')") set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}") # First for users who use an installed LLVM, create the LLVMExports.cmake file. -@@ -109,13 +109,13 @@ foreach(p ${_count}) - set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE} - get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)") - endforeach(p) --set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include") -+set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") - set(LLVM_CONFIG_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}") - set(LLVM_CONFIG_MAIN_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}") --set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib\${LLVM_LIBDIR_SUFFIX}") -+set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}\${LLVM_LIBDIR_SUFFIX}") - set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}") - set(LLVM_CONFIG_BINARY_DIR "\${LLVM_INSTALL_PREFIX}") --set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin") -+set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") - - # Generate a default location for lit - if (LLVM_INSTALL_UTILS AND LLVM_BUILD_UTILS) +@@ -122,7 +122,7 @@ set(LLVM_CONFIG_INCLUDE_DIRS + ) + list(REMOVE_DUPLICATES LLVM_CONFIG_INCLUDE_DIRS) + +-extend_path(LLVM_CONFIG_LIBRARY_DIR "\${LLVM_INSTALL_PREFIX}" "lib\${LLVM_LIBDIR_SUFFIX}") ++extend_path(LLVM_CONFIG_LIBRARY_DIR "\${LLVM_INSTALL_PREFIX}" "${CMAKE_INSTALL_LIBDIR}\${LLVM_LIBDIR_SUFFIX}") + set(LLVM_CONFIG_LIBRARY_DIRS + "${LLVM_CONFIG_LIBRARY_DIR}" + # FIXME: Should there be other entries here? diff --git a/cmake/modules/LLVMInstallSymlink.cmake b/cmake/modules/LLVMInstallSymlink.cmake -index 3e6a2c9a2648..52e14d955c60 100644 +index b5c35f706cb7..9261ab797de6 100644 --- a/cmake/modules/LLVMInstallSymlink.cmake +++ b/cmake/modules/LLVMInstallSymlink.cmake -@@ -4,7 +4,7 @@ +@@ -6,7 +6,7 @@ include(GNUInstallDirs) function(install_symlink name target outdir) set(DESTDIR $ENV{DESTDIR}) -- set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}/") +- set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}") + set(bindir "${DESTDIR}${outdir}/") message(STATUS "Creating ${name}") diff --git a/docs/CMake.rst b/docs/CMake.rst -index f1ac2c7d4934..c6e1469b5e13 100644 +index 044ec8a4d39d..504d0eac3ade 100644 --- a/docs/CMake.rst +++ b/docs/CMake.rst -@@ -202,7 +202,7 @@ CMake manual, or execute ``cmake --help-variable VARIABLE_NAME``. +@@ -224,7 +224,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``. - Rarely-used CMake variables - --------------------------- -@@ -551,8 +551,8 @@ LLVM-specific variables - - **LLVM_INSTALL_DOXYGEN_HTML_DIR**:STRING - The path to install Doxygen-generated HTML documentation to. This path can -- either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to -- `share/doc/llvm/doxygen-html`. -+ either be absolute or relative to the ``CMAKE_INSTALL_PREFIX``. Defaults to -+ `${CMAKE_INSTALL_DOCDIR}/${project}/doxygen-html`. - - **LLVM_LINK_LLVM_DYLIB**:BOOL - If enabled, tools will be linked with the libLLVM shared library. Defaults -@@ -792,9 +792,11 @@ the ``cmake`` command or by setting it directly in ``ccmake`` or ``cmake-gui``). + **LLVM_PARALLEL_{COMPILE,LINK}_JOBS**:STRING + Building the llvm toolchain can use a lot of resources, particularly +@@ -910,9 +910,11 @@ the ``cmake`` command or by setting it directly in ``ccmake`` or ``cmake-gui``). This file is available in two different locations. @@ -265,18 +164,6 @@ index f1ac2c7d4934..c6e1469b5e13 100644 * ``/lib/cmake/llvm/LLVMConfig.cmake`` where ```` is the root of the LLVM build tree. **Note: this is only -diff --git a/examples/Bye/CMakeLists.txt b/examples/Bye/CMakeLists.txt -index bb96edb4b4bf..678c22fb43c8 100644 ---- a/examples/Bye/CMakeLists.txt -+++ b/examples/Bye/CMakeLists.txt -@@ -14,6 +14,6 @@ if (NOT WIN32) - BUILDTREE_ONLY - ) - -- install(TARGETS ${name} RUNTIME DESTINATION examples) -+ install(TARGETS ${name} RUNTIME DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples) - set_target_properties(${name} PROPERTIES FOLDER "Examples") - endif() diff --git a/include/llvm/CMakeLists.txt b/include/llvm/CMakeLists.txt index b46319f24fc8..2feabd1954e4 100644 --- a/include/llvm/CMakeLists.txt @@ -289,93 +176,45 @@ index b46319f24fc8..2feabd1954e4 100644 + configure_file(module.modulemap.build ${LLVM_INCLUDE_DIR}/module.modulemap COPYONLY) endif (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") diff --git a/tools/llvm-config/BuildVariables.inc.in b/tools/llvm-config/BuildVariables.inc.in -index ebe5b73a5c65..70c497be12f5 100644 +index abbb8a450da6..70c497be12f5 100644 --- a/tools/llvm-config/BuildVariables.inc.in +++ b/tools/llvm-config/BuildVariables.inc.in -@@ -23,6 +23,10 @@ +@@ -23,7 +23,10 @@ #define LLVM_CXXFLAGS "@LLVM_CXXFLAGS@" #define LLVM_BUILDMODE "@LLVM_BUILDMODE@" #define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@" +#define LLVM_INSTALL_BINDIR "@CMAKE_INSTALL_BINDIR@" +#define LLVM_INSTALL_LIBDIR "@CMAKE_INSTALL_LIBDIR@" -+#define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@" + #define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@" +#define LLVM_INSTALL_CMAKEDIR "@LLVM_INSTALL_CMAKE_DIR@" #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@" #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@" #define LLVM_BUILD_SYSTEM "@LLVM_BUILD_SYSTEM@" diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp -index 1a2f04552d13..44fa7d3eec6b 100644 +index 8ed88f33ead4..5e7184bab90d 100644 --- a/tools/llvm-config/llvm-config.cpp +++ b/tools/llvm-config/llvm-config.cpp -@@ -357,12 +357,26 @@ int main(int argc, char **argv) { - ("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include"); - } else { - ActivePrefix = CurrentExecPrefix; -- ActiveIncludeDir = ActivePrefix + "/include"; -- SmallString<256> path(StringRef(LLVM_TOOLS_INSTALL_DIR)); -- sys::fs::make_absolute(ActivePrefix, path); -- ActiveBinDir = std::string(path.str()); +@@ -363,12 +363,20 @@ int main(int argc, char **argv) { + ActiveIncludeDir = std::string(Path.str()); + } + { +- SmallString<256> Path(LLVM_TOOLS_INSTALL_DIR); ++ SmallString<256> Path(LLVM_INSTALL_BINDIR); + sys::fs::make_absolute(ActivePrefix, Path); + ActiveBinDir = std::string(Path.str()); + } - ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX; - ActiveCMakeDir = ActiveLibDir + "/cmake/llvm"; + { -+ SmallString<256> path(StringRef(LLVM_INSTALL_INCLUDEDIR)); -+ sys::fs::make_absolute(ActivePrefix, path); -+ ActiveIncludeDir = std::string(path.str()); -+ } -+ { -+ SmallString<256> path(StringRef(LLVM_INSTALL_BINDIR)); -+ sys::fs::make_absolute(ActivePrefix, path); -+ ActiveBinDir = std::string(path.str()); -+ } -+ { -+ SmallString<256> path(StringRef(LLVM_INSTALL_LIBDIR LLVM_LIBDIR_SUFFIX)); -+ sys::fs::make_absolute(ActivePrefix, path); -+ ActiveLibDir = std::string(path.str()); ++ SmallString<256> Path(LLVM_INSTALL_LIBDIR LLVM_LIBDIR_SUFFIX); ++ sys::fs::make_absolute(ActivePrefix, Path); ++ ActiveLibDir = std::string(Path.str()); + } + { -+ SmallString<256> path(StringRef(LLVM_INSTALL_CMAKEDIR)); -+ sys::fs::make_absolute(ActivePrefix, path); -+ ActiveCMakeDir = std::string(path.str()); ++ SmallString<256> Path(LLVM_INSTALL_CMAKEDIR); ++ sys::fs::make_absolute(ActivePrefix, Path); ++ ActiveCMakeDir = std::string(Path.str()); + } ActiveIncludeOption = "-I" + ActiveIncludeDir; } -diff --git a/tools/lto/CMakeLists.txt b/tools/lto/CMakeLists.txt -index 0af29ad762c5..37b99b83e35c 100644 ---- a/tools/lto/CMakeLists.txt -+++ b/tools/lto/CMakeLists.txt -@@ -33,7 +33,7 @@ add_llvm_library(${LTO_LIBRARY_NAME} ${LTO_LIBRARY_TYPE} INSTALL_WITH_TOOLCHAIN - ${SOURCES} DEPENDS intrinsics_gen) - - install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h -- DESTINATION include/llvm-c -+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/llvm-c - COMPONENT LTO) - - if (APPLE) -diff --git a/tools/opt-viewer/CMakeLists.txt b/tools/opt-viewer/CMakeLists.txt -index ead73ec13a8f..250362021f17 100644 ---- a/tools/opt-viewer/CMakeLists.txt -+++ b/tools/opt-viewer/CMakeLists.txt -@@ -8,7 +8,7 @@ set (files - - foreach (file ${files}) - install(PROGRAMS ${file} -- DESTINATION share/opt-viewer -+ DESTINATION ${CMAKE_INSTALL_DATADIR}/opt-viewer - COMPONENT opt-viewer) - endforeach (file) - -diff --git a/tools/remarks-shlib/CMakeLists.txt b/tools/remarks-shlib/CMakeLists.txt -index 865436247270..ce1daa62f6ab 100644 ---- a/tools/remarks-shlib/CMakeLists.txt -+++ b/tools/remarks-shlib/CMakeLists.txt -@@ -19,7 +19,7 @@ if(LLVM_ENABLE_PIC) - endif() - - install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/Remarks.h -- DESTINATION include/llvm-c -+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/llvm-c - COMPONENT Remarks) - - if (APPLE) diff --git a/pkgs/development/compilers/llvm/git/openmp/default.nix b/pkgs/development/compilers/llvm/git/openmp/default.nix index c5a33df975607..7add0c7ed465d 100644 --- a/pkgs/development/compilers/llvm/git/openmp/default.nix +++ b/pkgs/development/compilers/llvm/git/openmp/default.nix @@ -1,10 +1,13 @@ { lib , stdenv , llvm_meta -, src +, monorepoSrc +, runCommand , cmake , llvm +, clang-unwrapped , perl +, pkg-config , version }: @@ -12,10 +15,22 @@ stdenv.mkDerivation rec { pname = "openmp"; inherit version; - inherit src; - sourceRoot = "source/${pname}"; + src = runCommand "${pname}-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${pname} "$out" + ''; - nativeBuildInputs = [ cmake perl ]; + sourceRoot = "${src.name}/${pname}"; + + patches = [ + ./gnu-install-dirs.patch + ./fix-find-tool.patch + ]; + + outputs = [ "out" "dev" ]; + + nativeBuildInputs = [ cmake perl pkg-config clang-unwrapped ]; buildInputs = [ llvm ]; cmakeFlags = [ diff --git a/pkgs/development/compilers/llvm/git/openmp/fix-find-tool.patch b/pkgs/development/compilers/llvm/git/openmp/fix-find-tool.patch new file mode 100644 index 0000000000000..b5d0e7b417757 --- /dev/null +++ b/pkgs/development/compilers/llvm/git/openmp/fix-find-tool.patch @@ -0,0 +1,54 @@ +diff --git a/libomptarget/DeviceRTL/CMakeLists.txt b/libomptarget/DeviceRTL/CMakeLists.txt +index 242df638f80d..a4654e96371f 100644 +--- a/libomptarget/DeviceRTL/CMakeLists.txt ++++ b/libomptarget/DeviceRTL/CMakeLists.txt +@@ -25,16 +25,16 @@ endif() + + if (LLVM_DIR) + # Builds that use pre-installed LLVM have LLVM_DIR set. +- find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) ++ find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) + 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) ++ REQUIRED) ++ find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) + libomptarget_say("Building DeviceRTL. Using clang: ${CLANG_TOOL}") + elseif (LLVM_TOOL_CLANG_BUILD AND NOT CMAKE_CROSSCOMPILING AND NOT OPENMP_STANDALONE_BUILD) + # LLVM in-tree builds may use CMake target names to discover the tools. +- set(CLANG_TOOL $) +- set(LINK_TOOL $) +- set(OPT_TOOL $) ++ set(CLANG_TOOL $ REQUIRED) ++ set(LINK_TOOL $ REQUIRED) ++ set(OPT_TOOL $ REQUIRED) + libomptarget_say("Building DeviceRTL. Using clang from in-tree build") + else() + libomptarget_say("Not building DeviceRTL. No appropriate clang found") +diff --git a/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt b/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt +index 3f4c02671aeb..be9f4677d7b5 100644 +--- a/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt ++++ b/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt +@@ -38,16 +38,16 @@ endif() + + if (LLVM_DIR) + # Builds that use pre-installed LLVM have LLVM_DIR set. +- find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) ++ find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) + 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) ++ REQUIRED) ++ find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) + libomptarget_say("Building AMDGCN device RTL. Using clang: ${CLANG_TOOL}") + elseif (LLVM_TOOL_CLANG_BUILD AND NOT CMAKE_CROSSCOMPILING AND NOT OPENMP_STANDALONE_BUILD) + # LLVM in-tree builds may use CMake target names to discover the tools. +- set(CLANG_TOOL $) +- set(LINK_TOOL $) +- set(OPT_TOOL $) ++ set(CLANG_TOOL $ REQUIRED) ++ set(LINK_TOOL $ REQUIRED) ++ set(OPT_TOOL $ REQUIRED) + libomptarget_say("Building AMDGCN device RTL. Using clang from in-tree build") + else() + libomptarget_say("Not building AMDGCN device RTL. No appropriate clang found") diff --git a/pkgs/development/compilers/llvm/git/openmp/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/git/openmp/gnu-install-dirs.patch new file mode 100644 index 0000000000000..352a469231158 --- /dev/null +++ b/pkgs/development/compilers/llvm/git/openmp/gnu-install-dirs.patch @@ -0,0 +1,89 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7f11a05f5622..fb90f8f6a49b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -8,6 +8,8 @@ if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_S + set(OPENMP_STANDALONE_BUILD TRUE) + project(openmp C CXX) + ++ include(GNUInstallDirs) ++ + # CMAKE_BUILD_TYPE was not set, default to Release. + if (NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +@@ -19,7 +21,7 @@ if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_S + set(OPENMP_LIBDIR_SUFFIX "" CACHE STRING + "Suffix of lib installation directory, e.g. 64 => lib64") + # Do not use OPENMP_LIBDIR_SUFFIX directly, use OPENMP_INSTALL_LIBDIR. +- set(OPENMP_INSTALL_LIBDIR "lib${OPENMP_LIBDIR_SUFFIX}") ++ set(OPENMP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}${OPENMP_LIBDIR_SUFFIX}") + + # Group test settings. + set(OPENMP_TEST_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING +@@ -30,7 +32,7 @@ if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_S + else() + set(OPENMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR}) + # If building in tree, we honor the same install suffix LLVM uses. +- set(OPENMP_INSTALL_LIBDIR "lib${LLVM_LIBDIR_SUFFIX}") ++ set(OPENMP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}") + + if (NOT MSVC) + set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang) +index 0e1ce2afd154..8b3810f83713 100644 +--- a/libomptarget/plugins/amdgpu/CMakeLists.txt ++++ b/libomptarget/plugins/amdgpu/CMakeLists.txt +@@ -80,7 +80,7 @@ add_library(omptarget.rtl.amdgpu SHARED + + # Install plugin under the lib destination folder. + # When we build for debug, OPENMP_LIBDIR_SUFFIX get set to -debug +-install(TARGETS omptarget.rtl.amdgpu LIBRARY DESTINATION "lib${OPENMP_LIBDIR_SUFFIX}") ++install(TARGETS omptarget.rtl.amdgpu LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${OPENMP_LIBDIR_SUFFIX}") + set_property(TARGET omptarget.rtl.amdgpu PROPERTY INSTALL_RPATH_USE_LINK_PATH ON) + + if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") +diff --git a/libomptarget/plugins/ve/CMakeLists.txt b/libomptarget/plugins/ve/CMakeLists.txt +index 16ce0891ca23..db30ee9c769f 100644 +--- a/libomptarget/plugins/ve/CMakeLists.txt ++++ b/libomptarget/plugins/ve/CMakeLists.txt +@@ -32,7 +32,7 @@ if(${LIBOMPTARGET_DEP_VEO_FOUND}) + + # Install plugin under the lib destination folder. + install(TARGETS "omptarget.rtl.${tmachine_libname}" +- LIBRARY DESTINATION lib${OPENMP_LIBDIR_SUFFIX}) ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${OPENMP_LIBDIR_SUFFIX}) + + target_link_libraries( + "omptarget.rtl.${tmachine_libname}" +diff --git a/runtime/src/CMakeLists.txt b/runtime/src/CMakeLists.txt +index e4f4e6e1e73f..1164b3b22b0e 100644 +--- a/runtime/src/CMakeLists.txt ++++ b/runtime/src/CMakeLists.txt +@@ -346,13 +346,13 @@ add_dependencies(libomp-micro-tests libomp-test-deps) + # We want to install libomp in DESTDIR/CMAKE_INSTALL_PREFIX/lib + # We want to install headers in DESTDIR/CMAKE_INSTALL_PREFIX/include + if(${OPENMP_STANDALONE_BUILD}) +- set(LIBOMP_HEADERS_INSTALL_PATH include) ++ set(LIBOMP_HEADERS_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}") + else() + string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION ${PACKAGE_VERSION}) + set(LIBOMP_HEADERS_INSTALL_PATH "${OPENMP_INSTALL_LIBDIR}/clang/${CLANG_VERSION}/include") + endif() + if(WIN32) +- install(TARGETS omp RUNTIME DESTINATION bin) ++ install(TARGETS omp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(TARGETS ${LIBOMP_IMP_LIB_TARGET} ARCHIVE DESTINATION "${OPENMP_INSTALL_LIBDIR}") + # Create aliases (regular copies) of the library for backwards compatibility + set(LIBOMP_ALIASES "libiomp5md") +diff --git a/tools/multiplex/CMakeLists.txt b/tools/multiplex/CMakeLists.txt +index 64317c112176..4002784da736 100644 +--- a/tools/multiplex/CMakeLists.txt ++++ b/tools/multiplex/CMakeLists.txt +@@ -4,7 +4,7 @@ if(LIBOMP_OMPT_SUPPORT) + add_library(ompt-multiplex INTERFACE) + target_include_directories(ompt-multiplex INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) + +- install(FILES ompt-multiplex.h DESTINATION include) ++ install(FILES ompt-multiplex.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + + add_subdirectory(tests) + endif()