summary refs log tree commit diff
path: root/pkgs/development/compilers/llvm/12/llvm
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-08-04 10:43:07 +0000
committerAlyssa Ross <hi@alyssa.is>2021-08-04 10:43:07 +0000
commit62614cbef7da005c1eda8c9400160f6bcd6546b8 (patch)
treec2630f69080637987b68acb1ee8676d2681fe304 /pkgs/development/compilers/llvm/12/llvm
parentd9c82ed3044c72cecf01c6ea042489d30914577c (diff)
parente24069138dfec3ef94f211f1da005bb5395adc11 (diff)
downloadnixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.gz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.bz2
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.lz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.xz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.zst
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.zip
Merge branch 'nixpkgs-update' into master
Diffstat (limited to 'pkgs/development/compilers/llvm/12/llvm')
-rw-r--r--pkgs/development/compilers/llvm/12/llvm/default.nix232
-rw-r--r--pkgs/development/compilers/llvm/12/llvm/gnu-install-dirs-polly.patch105
-rw-r--r--pkgs/development/compilers/llvm/12/llvm/gnu-install-dirs.patch417
-rw-r--r--pkgs/development/compilers/llvm/12/llvm/outputs.patch26
4 files changed, 780 insertions, 0 deletions
diff --git a/pkgs/development/compilers/llvm/12/llvm/default.nix b/pkgs/development/compilers/llvm/12/llvm/default.nix
new file mode 100644
index 00000000000..361c6798385
--- /dev/null
+++ b/pkgs/development/compilers/llvm/12/llvm/default.nix
@@ -0,0 +1,232 @@
+{ lib, stdenv, llvm_meta
+, pkgsBuildBuild
+, fetch
+, fetchpatch
+, cmake
+, python3
+, libffi
+, libbfd
+, libpfm
+, libxml2
+, ncurses
+, version
+, release_version
+, zlib
+, buildLlvmTools
+, debugVersion ? false
+, enableManpages ? false
+, enableSharedLibraries ? !stdenv.hostPlatform.isStatic
+, enablePFM ? !(stdenv.isDarwin
+  || stdenv.isAarch64 # broken for Ampere eMAG 8180 (c2.large.arm on Packet) #56245
+  || stdenv.isAarch32 # broken for the armv7l builder
+)
+, enablePolly ? false
+}:
+
+let
+  inherit (lib) optional optionals optionalString;
+
+  # Used when creating a version-suffixed symlink of libLLVM.dylib
+  shortVersion = with lib;
+    concatStringsSep "." (take 1 (splitString "." release_version));
+
+in stdenv.mkDerivation (rec {
+  pname = "llvm";
+  inherit version;
+
+  src = fetch pname "1pzx9zrmd7r3481sbhwvkms68fwhffpp4mmz45dgrkjpyl2q96kx";
+  polly_src = fetch "polly" "1yfm9ixda4a2sx7ak5vswijx4ydk5lv1c1xh39xmd2kh299y4m12";
+
+  unpackPhase = ''
+    unpackFile $src
+    mv llvm-${release_version}* llvm
+    sourceRoot=$PWD/llvm
+  '' + optionalString enablePolly ''
+    unpackFile $polly_src
+    mv polly-* $sourceRoot/tools/polly
+  '';
+
+  outputs = [ "out" "lib" "dev" "python" ];
+
+  nativeBuildInputs = [ cmake python3 ]
+    ++ optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ];
+
+  buildInputs = [ libxml2 libffi ]
+    ++ optional enablePFM libpfm; # exegesis
+
+  propagatedBuildInputs = [ ncurses zlib ];
+
+  patches = [
+    ./gnu-install-dirs.patch
+    # On older CPUs (e.g. Hydra/wendy) we'd be getting an error in this test.
+    (fetchpatch {
+      name = "uops-CMOV16rm-noreg.diff";
+      url = "https://github.com/llvm/llvm-project/commit/9e9f991ac033.diff";
+      sha256 = "sha256:12s8vr6ibri8b48h2z38f3afhwam10arfiqfy4yg37bmc054p5hi";
+      stripLen = 1;
+    })
+  ] ++ lib.optional enablePolly ./gnu-install-dirs-polly.patch;
+
+  postPatch = optionalString stdenv.isDarwin ''
+    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})' ""
+  ''
+  # Patch llvm-config to return correct library path based on --link-{shared,static}.
+  + optionalString (enableSharedLibraries) ''
+    substitute '${./outputs.patch}' ./outputs.patch --subst-var lib
+    patch -p1 < ./outputs.patch
+  '' + ''
+    # FileSystem permissions tests fail with various special bits
+    substituteInPlace unittests/Support/CMakeLists.txt \
+      --replace "Path.cpp" ""
+    rm unittests/Support/Path.cpp
+    substituteInPlace unittests/IR/CMakeLists.txt \
+      --replace "PassBuilderCallbacksTest.cpp" ""
+    rm unittests/IR/PassBuilderCallbacksTest.cpp
+    # TODO: Fix failing tests:
+    rm test/DebugInfo/X86/vla-multi.ll
+  '' + optionalString stdenv.hostPlatform.isMusl ''
+    patch -p1 -i ${../../TLI-musl.patch}
+    substituteInPlace unittests/Support/CMakeLists.txt \
+      --replace "add_subdirectory(DynamicLibrary)" ""
+    rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
+    # valgrind unhappy with musl or glibc, but fails w/musl only
+    rm test/CodeGen/AArch64/wineh4.mir
+  '' + optionalString stdenv.hostPlatform.isAarch32 ''
+    # skip failing X86 test cases on 32-bit ARM
+    rm test/DebugInfo/X86/convert-debugloc.ll
+    rm test/DebugInfo/X86/convert-inlined.ll
+    rm test/DebugInfo/X86/convert-linked.ll
+    rm test/DebugInfo/X86/vla-multi.ll
+    rm test/tools/dsymutil/X86/op-convert.test
+  '' + optionalString (stdenv.hostPlatform.system == "armv6l-linux") ''
+    # Seems to require certain floating point hardware (NEON?)
+    rm test/ExecutionEngine/frem.ll
+  '' + ''
+    patchShebangs test/BugPoint/compile-custom.ll.py
+  '';
+
+  # hacky fix: created binaries need to be run before installation
+  preBuild = ''
+    mkdir -p $out/
+    ln -sv $PWD/lib $out
+  '';
+
+  # E.g. mesa.drivers use the build-id as a cache key (see #93946):
+  LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1";
+
+  cmakeFlags = with stdenv; [
+    "-DLLVM_INSTALL_CMAKE_DIR=${placeholder "dev"}/lib/cmake/llvm/"
+    "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}"
+    "-DLLVM_INSTALL_UTILS=ON"  # Needed by rustc
+    "-DLLVM_BUILD_TESTS=ON"
+    "-DLLVM_ENABLE_FFI=ON"
+    "-DLLVM_ENABLE_RTTI=ON"
+    "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
+    "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
+    "-DLLVM_ENABLE_DUMP=ON"
+  ] ++ optionals enableSharedLibraries [
+    "-DLLVM_LINK_LLVM_DYLIB=ON"
+  ] ++ optionals enableManpages [
+    "-DLLVM_BUILD_DOCS=ON"
+    "-DLLVM_ENABLE_SPHINX=ON"
+    "-DSPHINX_OUTPUT_MAN=ON"
+    "-DSPHINX_OUTPUT_HTML=OFF"
+    "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
+  ] ++ optionals (!isDarwin) [
+    "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
+  ] ++ optionals isDarwin [
+    "-DLLVM_ENABLE_LIBCXX=ON"
+    "-DCAN_TARGET_i386=false"
+  ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+    "-DCMAKE_CROSSCOMPILING=True"
+    "-DLLVM_TABLEGEN=${buildLlvmTools.llvm}/bin/llvm-tblgen"
+    (
+      let
+        nativeCC = pkgsBuildBuild.targetPackages.stdenv.cc;
+        nativeBintools = nativeCC.bintools.bintools;
+        nativeToolchainFlags = [
+          "-DCMAKE_C_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}cc"
+          "-DCMAKE_CXX_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}c++"
+          "-DCMAKE_AR=${nativeBintools}/bin/${nativeBintools.targetPrefix}ar"
+          "-DCMAKE_STRIP=${nativeBintools}/bin/${nativeBintools.targetPrefix}strip"
+          "-DCMAKE_RANLIB=${nativeBintools}/bin/${nativeBintools.targetPrefix}ranlib"
+        ];
+      in "-DCROSS_TOOLCHAIN_FLAGS_NATIVE:list=${lib.concatStringsSep ";" nativeToolchainFlags}"
+    )
+  ];
+
+  postBuild = ''
+    rm -fR $out
+  '';
+
+  preCheck = ''
+    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/lib
+  '';
+
+  postInstall = ''
+    mkdir -p $python/share
+    mv $out/share/opt-viewer $python/share/opt-viewer
+    moveToOutput "bin/llvm-config*" "$dev"
+    substituteInPlace "$dev/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
+      --replace "\''${_IMPORT_PREFIX}/lib/lib" "$lib/lib/lib" \
+      --replace "$out/bin/llvm-config" "$dev/bin/llvm-config"
+    substituteInPlace "$dev/lib/cmake/llvm/LLVMConfig.cmake" \
+      --replace 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}")' 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}'"$lib"'")'
+  ''
+  + optionalString (stdenv.isDarwin && enableSharedLibraries) ''
+    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib
+    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib
+  ''
+  + optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
+    cp NATIVE/bin/llvm-config $dev/bin/llvm-config-native
+  '';
+
+  doCheck = stdenv.isLinux && (!stdenv.isx86_32) && (!stdenv.hostPlatform.isMusl);
+
+  checkTarget = "check-all";
+
+  requiredSystemFeatures = [ "big-parallel" ];
+  meta = llvm_meta // {
+    homepage = "https://llvm.org/";
+    description = "A collection of modular and reusable compiler and toolchain technologies";
+    longDescription = ''
+      The LLVM Project is a collection of modular and reusable compiler and
+      toolchain technologies. Despite its name, LLVM has little to do with
+      traditional virtual machines. The name "LLVM" itself is not an acronym; it
+      is the full name of the project.
+      LLVM began as a research project at the University of Illinois, with the
+      goal of providing a modern, SSA-based compilation strategy capable of
+      supporting both static and dynamic compilation of arbitrary programming
+      languages. Since then, LLVM has grown to be an umbrella project consisting
+      of a number of subprojects, many of which are being used in production by
+      a wide variety of commercial and open source projects as well as being
+      widely used in academic research. Code in the LLVM project is licensed
+      under the "Apache 2.0 License with LLVM exceptions".
+    '';
+  };
+} // lib.optionalAttrs enableManpages {
+  pname = "llvm-manpages";
+
+  buildPhase = ''
+    make docs-llvm-man
+  '';
+
+  propagatedBuildInputs = [];
+
+  installPhase = ''
+    make -C docs install
+  '';
+
+  postPatch = null;
+  postInstall = null;
+
+  outputs = [ "out" ];
+
+  doCheck = false;
+
+  meta = llvm_meta // {
+    description = "man pages for LLVM ${version}";
+  };
+})
diff --git a/pkgs/development/compilers/llvm/12/llvm/gnu-install-dirs-polly.patch b/pkgs/development/compilers/llvm/12/llvm/gnu-install-dirs-polly.patch
new file mode 100644
index 00000000000..68f3c45396f
--- /dev/null
+++ b/pkgs/development/compilers/llvm/12/llvm/gnu-install-dirs-polly.patch
@@ -0,0 +1,105 @@
+diff --git a/tools/polly/CMakeLists.txt b/tools/polly/CMakeLists.txt
+index ca7c04c565bb..6ed5db5dd4f8 100644
+--- a/tools/polly/CMakeLists.txt
++++ b/tools/polly/CMakeLists.txt
+@@ -2,7 +2,11 @@
+ 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)
+   # 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(
+ 
+ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
+   install(DIRECTORY include/
+-    DESTINATION include
++    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+     FILES_MATCHING
+     PATTERN "*.h"
+     )
+ 
+   install(DIRECTORY ${POLLY_BINARY_DIR}/include/
+-    DESTINATION include
++    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+     FILES_MATCHING
+     PATTERN "*.h"
+     PATTERN "CMakeFiles" EXCLUDE
+diff --git a/tools/polly/cmake/CMakeLists.txt b/tools/polly/cmake/CMakeLists.txt
+index 7cc129ba2e90..137be25e4b80 100644
+--- a/tools/polly/cmake/CMakeLists.txt
++++ b/tools/polly/cmake/CMakeLists.txt
+@@ -79,18 +79,18 @@ file(GENERATE
+ 
+ # Generate PollyConfig.cmake for the install tree.
+ unset(POLLY_EXPORTS)
+-set(POLLY_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
++set(POLLY_INSTALL_PREFIX "")
+ set(POLLY_CONFIG_LLVM_CMAKE_DIR "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
+-set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
+-set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}")
++set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
++set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
+ if (POLLY_BUNDLED_ISL)
+   set(POLLY_CONFIG_INCLUDE_DIRS
+-    "${POLLY_INSTALL_PREFIX}/include"
+-    "${POLLY_INSTALL_PREFIX}/include/polly"
++    "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}"
++    "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_LIBDIR}/polly"
+     )
+ else()
+   set(POLLY_CONFIG_INCLUDE_DIRS
+-    "${POLLY_INSTALL_PREFIX}/include"
++    "${POLLY_INSTALL_PREFIX}${CMAKE_INSTALL_FULL_INCLUDEDIR}"
+     ${ISL_INCLUDE_DIRS}
+     )
+ endif()
+@@ -100,12 +100,12 @@ endif()
+ foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
+   get_target_property(tgt_type ${tgt} TYPE)
+   if (tgt_type STREQUAL "EXECUTABLE")
+-    set(tgt_prefix "bin/")
++    set(tgt_prefix "${CMAKE_INSTALL_BINDIR}/")
+   else()
+-    set(tgt_prefix "lib/")
++    set(tgt_prefix "${CMAKE_INSTALL_LIBDIR}/")
+   endif()
+ 
+-  set(tgt_path "${CMAKE_INSTALL_PREFIX}/${tgt_prefix}$<TARGET_FILE_NAME:${tgt}>")
++  set(tgt_path "${tgt_prefix}$<TARGET_FILE_NAME:${tgt}>")
+   file(RELATIVE_PATH tgt_path ${POLLY_CONFIG_CMAKE_DIR} ${tgt_path})
+ 
+   if (NOT tgt_type STREQUAL "INTERFACE_LIBRARY")
+diff --git a/tools/polly/cmake/polly_macros.cmake b/tools/polly/cmake/polly_macros.cmake
+index 518a09b45a42..bd9d6f5542ad 100644
+--- a/tools/polly/cmake/polly_macros.cmake
++++ b/tools/polly/cmake/polly_macros.cmake
+@@ -44,8 +44,8 @@ macro(add_polly_library name)
+   if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LLVMPolly")
+     install(TARGETS ${name}
+       EXPORT LLVMExports
+-      LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+-      ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
++	  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}
++      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
+   endif()
+   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
+--- a/tools/polly/lib/External/CMakeLists.txt
++++ b/tools/polly/lib/External/CMakeLists.txt
+@@ -275,7 +275,7 @@ if (POLLY_BUNDLED_ISL)
+     install(DIRECTORY
+       ${ISL_SOURCE_DIR}/include/
+       ${ISL_BINARY_DIR}/include/
+-      DESTINATION include/polly
++      DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/polly
+       FILES_MATCHING
+       PATTERN "*.h"
+       PATTERN "CMakeFiles" EXCLUDE
diff --git a/pkgs/development/compilers/llvm/12/llvm/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/12/llvm/gnu-install-dirs.patch
new file mode 100644
index 00000000000..da8dc144517
--- /dev/null
+++ b/pkgs/development/compilers/llvm/12/llvm/gnu-install-dirs.patch
@@ -0,0 +1,417 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 277d0fe54d7b..af69c8be8745 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -256,15 +256,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)
+ 
++set(LLVM_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/cmake/llvm" CACHE STRING
++	"Path for CMake subdirectory (defaults to lib/cmake/llvm)" )
++
+ # 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})
+@@ -567,9 +573,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
+@@ -1027,7 +1033,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"
+@@ -1038,7 +1044,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"
+@@ -1052,13 +1058,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 97c9980c7de3..409e8b615f75 100644
+--- a/cmake/modules/AddLLVM.cmake
++++ b/cmake/modules/AddLLVM.cmake
+@@ -804,9 +804,9 @@ macro(add_llvm_library name)
+ 
+       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})
+ 
+       if (NOT LLVM_ENABLE_IDE)
+         add_llvm_install_targets(install-${name}
+@@ -1022,7 +1022,7 @@ function(process_llvm_pass_plugins)
+           "set(LLVM_STATIC_EXTENSIONS ${LLVM_STATIC_EXTENSIONS})")
+       install(FILES
+           ${llvm_cmake_builddir}/LLVMConfigExtensions.cmake
+-          DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
++          DESTINATION ${LLVM_INSTALL_CMAKE_DIR}
+           COMPONENT cmake-exports)
+ 
+       set(ExtensionDef "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def")
+@@ -1242,7 +1242,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)
+@@ -1854,7 +1854,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})
+ 
+-  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 bin)
+   endif()
+@@ -1871,7 +1871,7 @@ function(llvm_install_library_symlink name dest type)
+   endif()
+ endfunction()
+ 
+-function(llvm_install_symlink name dest)
++function(llvm_install_symlink name dest output_dir)
+   cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN})
+   foreach(path ${CMAKE_MODULE_PATH})
+     if(EXISTS ${path}/LLVMInstallSymlink.cmake)
+@@ -1894,7 +1894,7 @@ function(llvm_install_symlink name dest)
+   set(full_dest ${dest}${CMAKE_EXECUTABLE_SUFFIX})
+ 
+   install(SCRIPT ${INSTALL_SYMLINK}
+-          CODE "install_symlink(${full_name} ${full_dest} ${LLVM_TOOLS_INSTALL_DIR})"
++          CODE "install_symlink(${full_name} ${full_dest} ${output_dir})"
+           COMPONENT ${component})
+ 
+   if (NOT LLVM_ENABLE_IDE AND NOT ARG_ALWAYS_GENERATE)
+@@ -1977,7 +1977,8 @@ function(add_llvm_tool_symlink link_name target)
+     endif()
+ 
+     if ((TOOL_IS_TOOLCHAIN OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) AND LLVM_BUILD_TOOLS)
+-      llvm_install_symlink(${link_name} ${target})
++      GNUInstallDirs_get_absolute_install_dir(output_dir LLVM_TOOLS_INSTALL_DIR)
++      llvm_install_symlink(${link_name} ${target} ${output_dir})
+     endif()
+   endif()
+ endfunction()
+@@ -2100,9 +2101,9 @@ function(llvm_setup_rpath name)
+ 
+   if (APPLE)
+     set(_install_name_dir INSTALL_NAME_DIR "@rpath")
+-    set(_install_rpath "@loader_path/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
++    set(_install_rpath "@loader_path/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
+   elseif(UNIX)
+-    set(_install_rpath "\$ORIGIN/../lib${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
+                    LINK_FLAGS " -Wl,-z,origin ")
+diff --git a/cmake/modules/AddOCaml.cmake b/cmake/modules/AddOCaml.cmake
+index 554046b20edf..4d1ad980641e 100644
+--- a/cmake/modules/AddOCaml.cmake
++++ b/cmake/modules/AddOCaml.cmake
+@@ -144,9 +144,9 @@ function(add_ocaml_library name)
+   endforeach()
+ 
+   if( APPLE )
+-    set(ocaml_rpath "@executable_path/../../../lib${LLVM_LIBDIR_SUFFIX}")
++    set(ocaml_rpath "@executable_path/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
+   elseif( UNIX )
+-    set(ocaml_rpath "\\$ORIGIN/../../../lib${LLVM_LIBDIR_SUFFIX}")
++    set(ocaml_rpath "\\$ORIGIN/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
+   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 505dc9a29d70..36e6c63af3f4 100644
+--- a/cmake/modules/CMakeLists.txt
++++ b/cmake/modules/CMakeLists.txt
+@@ -1,4 +1,4 @@
+-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.
+@@ -107,13 +107,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)
+diff --git a/cmake/modules/LLVMInstallSymlink.cmake b/cmake/modules/LLVMInstallSymlink.cmake
+index 09fed8085c23..aa79f192abf0 100644
+--- a/cmake/modules/LLVMInstallSymlink.cmake
++++ b/cmake/modules/LLVMInstallSymlink.cmake
+@@ -10,7 +10,7 @@ function(install_symlink name target outdir)
+     set(LINK_OR_COPY copy)
+   endif()
+ 
+-  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 bb821b417ad9..6a528f7c2ad3 100644
+--- a/docs/CMake.rst
++++ b/docs/CMake.rst
+@@ -196,7 +196,7 @@ CMake manual, or execute ``cmake --help-variable VARIABLE_NAME``.
+ **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``.
+ 
+ **CMAKE_C_FLAGS**:STRING
+   Extra flags to use when compiling C source files.
+@@ -550,8 +550,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_ENABLE_SPHINX**:BOOL
+   If specified, CMake will search for the ``sphinx-build`` executable and will make
+@@ -582,13 +582,33 @@ LLVM-specific variables
+ 
+ **LLVM_INSTALL_SPHINX_HTML_DIR**:STRING
+   The path to install Sphinx-generated HTML documentation to. This path can
+-  either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to
+-  `share/doc/llvm/html`.
++  either be absolute or relative to the ``CMAKE_INSTALL_PREFIX``. Defaults to
++  `${CMAKE_INSTALL_DOCDIR}/${project}/html`.
+ 
+ **LLVM_INSTALL_OCAMLDOC_HTML_DIR**:STRING
+   The path to install OCamldoc-generated HTML documentation to. This path can
+-  either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to
+-  `share/doc/llvm/ocaml-html`.
++  either be absolute or relative to the ``CMAKE_INSTALL_PREFIX``. Defaults to
++  `${CMAKE_INSTALL_DOCDIR}/${project}/ocaml-html`.
++
++**CMAKE_INSTALL_BINDIR**:STRING
++  The path to install binary tools, relative to the ``CMAKE_INSTALL_PREFIX``.
++  Defaults to `bin`.
++
++**CMAKE_INSTALL_LIBDIR**:STRING
++  The path to install libraries, relative to the ``CMAKE_INSTALL_PREFIX``.
++  Defaults to `lib`.
++
++**CMAKE_INSTALL_INCLUDEDIR**:STRING
++  The path to install header files, relative to the ``CMAKE_INSTALL_PREFIX``.
++  Defaults to `include`.
++
++**CMAKE_INSTALL_DOCDIR**:STRING
++  The path to install documentation, relative to the ``CMAKE_INSTALL_PREFIX``.
++  Defaults to `share/doc`.
++
++**CMAKE_INSTALL_MANDIR**:STRING
++  The path to install manpage files, relative to the ``CMAKE_INSTALL_PREFIX``.
++  Defaults to `share/man`.
+ 
+ **LLVM_CREATE_XCODE_TOOLCHAIN**:BOOL
+   macOS Only: If enabled CMake will generate a target named
+@@ -786,9 +806,11 @@ the ``cmake`` command or by setting it directly in ``ccmake`` or ``cmake-gui``).
+ 
+ This file is available in two different locations.
+ 
+-* ``<INSTALL_PREFIX>/lib/cmake/llvm/LLVMConfig.cmake`` where
+-  ``<INSTALL_PREFIX>`` is the install prefix of an installed version of LLVM.
+-  On Linux typically this is ``/usr/lib/cmake/llvm/LLVMConfig.cmake``.
++* ``<LLVM_INSTALL_PACKAGE_DIR>LLVMConfig.cmake`` where
++  ``<LLVM_INSTALL_PACKAGE_DIR>`` is the location where LLVM CMake modules are
++  installed as part of an installed version of LLVM. This is typically
++  ``cmake/llvm/`` within the lib directory. On Linux, this is typically
++  ``/usr/lib/cmake/llvm/LLVMConfig.cmake``.
+ 
+ * ``<LLVM_BUILD_ROOT>/lib/cmake/llvm/LLVMConfig.cmake`` where
+   ``<LLVM_BUILD_ROOT>`` 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
++++ b/include/llvm/CMakeLists.txt
+@@ -5,5 +5,5 @@ add_subdirectory(Frontend)
+ # If we're doing an out-of-tree build, copy a module map for generated
+ # header files into the build area.
+ if (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
+-  configure_file(module.modulemap.build module.modulemap COPYONLY)
++  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
+--- a/tools/llvm-config/BuildVariables.inc.in
++++ b/tools/llvm-config/BuildVariables.inc.in
+@@ -23,6 +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_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
+--- 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());
+-    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(StringRef(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 2963f97cad88..69d66c9c9ca1 100644
+--- a/tools/lto/CMakeLists.txt
++++ b/tools/lto/CMakeLists.txt
+@@ -25,7 +25,7 @@ add_llvm_library(LTO SHARED 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/12/llvm/outputs.patch b/pkgs/development/compilers/llvm/12/llvm/outputs.patch
new file mode 100644
index 00000000000..40096fa3497
--- /dev/null
+++ b/pkgs/development/compilers/llvm/12/llvm/outputs.patch
@@ -0,0 +1,26 @@
+diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
+index 94d426b..37f7794 100644
+--- a/tools/llvm-config/llvm-config.cpp
++++ b/tools/llvm-config/llvm-config.cpp
+@@ -333,6 +333,21 @@ int main(int argc, char **argv) {
+     ActiveIncludeOption = "-I" + ActiveIncludeDir;
+   }
+ 
++  /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared
++  if (!IsInDevelopmentTree) {
++    bool WantShared = true;
++    for (int i = 1; i < argc; ++i) {
++      StringRef Arg = argv[i];
++      if (Arg == "--link-shared")
++        WantShared = true;
++      else if (Arg == "--link-static")
++        WantShared = false; // the last one wins
++    }
++
++    if (WantShared)
++      ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX;
++  }
++
+   /// We only use `shared library` mode in cases where the static library form
+   /// of the components provided are not available; note however that this is
+   /// skipped if we're run from within the build dir. However, once installed,