diff options
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/llvm/11/llvm/default.nix')
-rw-r--r-- | nixpkgs/pkgs/development/compilers/llvm/11/llvm/default.nix | 90 |
1 files changed, 64 insertions, 26 deletions
diff --git a/nixpkgs/pkgs/development/compilers/llvm/11/llvm/default.nix b/nixpkgs/pkgs/development/compilers/llvm/11/llvm/default.nix index ee2fe9c90b2b..192cacd6510c 100644 --- a/nixpkgs/pkgs/development/compilers/llvm/11/llvm/default.nix +++ b/nixpkgs/pkgs/development/compilers/llvm/11/llvm/default.nix @@ -1,5 +1,7 @@ -{ lib, stdenv +{ lib, stdenv, llvm_meta +, pkgsBuildBuild , fetch +, fetchpatch , cmake , python3 , libffi @@ -10,15 +12,15 @@ , version , release_version , zlib -, buildPackages +, buildLlvmTools , debugVersion ? false , enableManpages ? false -, enableSharedLibraries ? true +, 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 +, enablePolly ? false # TODO should be on by default }: let @@ -44,8 +46,7 @@ in stdenv.mkDerivation (rec { mv polly-* $sourceRoot/tools/polly ''; - outputs = [ "out" "python" ] - ++ optional enableSharedLibraries "lib"; + outputs = [ "out" "lib" "dev" "python" ]; nativeBuildInputs = [ cmake python3 ] ++ optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ]; @@ -55,10 +56,21 @@ in stdenv.mkDerivation (rec { 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/../lib''${LLVM_LIBDIR_SUFFIX}" ''${extra_libdir})' "" + --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) '' @@ -99,6 +111,7 @@ in stdenv.mkDerivation (rec { 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" @@ -122,7 +135,20 @@ in stdenv.mkDerivation (rec { "-DCAN_TARGET_i386=false" ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ "-DCMAKE_CROSSCOMPILING=True" - "-DLLVM_TABLEGEN=${buildPackages.llvm_11}/bin/llvm-tblgen" + "-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 = '' @@ -136,33 +162,43 @@ in stdenv.mkDerivation (rec { postInstall = '' mkdir -p $python/share mv $out/share/opt-viewer $python/share/opt-viewer - '' - + optionalString enableSharedLibraries '' - moveToOutput "lib/libLLVM-*" "$lib" - moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib" - '' - + optionalString (enableSharedLibraries && (!stdenv.isDarwin)) '' - substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ - --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-" + 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) '' - substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ - --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib" 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); + doCheck = stdenv.isLinux && (!stdenv.isx86_32) && (!stdenv.hostPlatform.isMusl) && (!stdenv.hostPlatform.isRiscV); checkTarget = "check-all"; requiredSystemFeatures = [ "big-parallel" ]; - meta = { - description = "Collection of modular and reusable compiler and toolchain technologies"; - homepage = "https://llvm.org/"; - license = lib.licenses.ncsa; - maintainers = with lib.maintainers; [ lovek323 raskin dtzWill primeos ]; - platforms = lib.platforms.all; + 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"; @@ -184,5 +220,7 @@ in stdenv.mkDerivation (rec { doCheck = false; - meta.description = "man pages for LLVM ${version}"; + meta = llvm_meta // { + description = "man pages for LLVM ${version}"; + }; }) |