Merge pull request #303948 from ExpidusOS/feat/llvm-git-commonify-clang

llvmPackages_{12,13,14,15,16,17,18,git}: use common clang

authored by Weijia Wang and committed by GitHub 6da46d61 62b47440

+310 -971
-132
pkgs/development/compilers/llvm/12/clang/default.nix
··· 1 - { lib, stdenv, llvm_meta, fetch, substituteAll, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3 2 - , buildLlvmTools 3 - , fixDarwinDylibNames 4 - , enableManpages ? false 5 - }: 6 - 7 - let 8 - self = stdenv.mkDerivation ({ 9 - pname = "clang"; 10 - inherit version; 11 - 12 - src = fetch "clang" "0px4gl27az6cdz6adds89qzdwb1cqpjsfvrldbz9qvpmphrj34bf"; 13 - inherit clang-tools-extra_src; 14 - 15 - unpackPhase = '' 16 - unpackFile $src 17 - mv clang-* clang 18 - sourceRoot=$PWD/clang 19 - unpackFile ${clang-tools-extra_src} 20 - mv clang-tools-extra-* $sourceRoot/tools/extra 21 - substituteInPlace $sourceRoot/tools/extra/clangd/quality/CompletionModel.cmake \ 22 - --replace ' ''${CMAKE_SOURCE_DIR}/../clang-tools-extra' ' ''${CMAKE_SOURCE_DIR}/tools/extra' 23 - ''; 24 - 25 - nativeBuildInputs = [ cmake python3 ] 26 - ++ lib.optional enableManpages python3.pkgs.sphinx 27 - ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 28 - 29 - buildInputs = [ libxml2 libllvm ]; 30 - 31 - cmakeFlags = [ 32 - "-DCLANGD_BUILD_XPC=OFF" 33 - "-DLLVM_ENABLE_RTTI=ON" 34 - ] ++ lib.optionals enableManpages [ 35 - "-DCLANG_INCLUDE_DOCS=ON" 36 - "-DLLVM_ENABLE_SPHINX=ON" 37 - "-DSPHINX_OUTPUT_MAN=ON" 38 - "-DSPHINX_OUTPUT_HTML=OFF" 39 - "-DSPHINX_WARNINGS_AS_ERRORS=OFF" 40 - ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 41 - "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" 42 - "-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen" 43 - ]; 44 - 45 - patches = [ 46 - ./purity.patch 47 - # https://reviews.llvm.org/D51899 48 - ./gnu-install-dirs.patch 49 - (substituteAll { 50 - src = ../../common/clang/clang-11-15-LLVMgold-path.patch; 51 - libllvmLibdir = "${libllvm.lib}/lib"; 52 - }) 53 - ]; 54 - 55 - postPatch = '' 56 - sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \ 57 - -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \ 58 - lib/Driver/ToolChains/*.cpp 59 - '' + lib.optionalString stdenv.hostPlatform.isMusl '' 60 - sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp 61 - ''; 62 - 63 - outputs = [ "out" "lib" "dev" "python" ]; 64 - 65 - postInstall = '' 66 - ln -sv $out/bin/clang $out/bin/cpp 67 - 68 - # Move libclang to 'lib' output 69 - moveToOutput "lib/libclang.*" "$lib" 70 - moveToOutput "lib/libclang-cpp.*" "$lib" 71 - substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \ 72 - --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ 73 - --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." 74 - 75 - mkdir -p $python/bin $python/share/{clang,scan-view} 76 - mv $out/bin/{git-clang-format,scan-view} $python/bin 77 - if [ -e $out/bin/set-xcode-analyzer ]; then 78 - mv $out/bin/set-xcode-analyzer $python/bin 79 - fi 80 - mv $out/share/clang/*.py $python/share/clang 81 - mv $out/share/scan-view/*.py $python/share/scan-view 82 - rm $out/bin/c-index-test 83 - patchShebangs $python/bin 84 - 85 - mkdir -p $dev/bin 86 - cp bin/clang-tblgen $dev/bin 87 - ''; 88 - 89 - passthru = { 90 - inherit libllvm; 91 - isClang = true; 92 - hardeningUnsupportedFlags = [ "fortify3" "zerocallusedregs" ]; 93 - }; 94 - 95 - meta = llvm_meta // { 96 - homepage = "https://clang.llvm.org/"; 97 - description = "A C language family frontend for LLVM"; 98 - longDescription = '' 99 - The Clang project provides a language front-end and tooling 100 - infrastructure for languages in the C language family (C, C++, Objective 101 - C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project. 102 - It aims to deliver amazingly fast compiles, extremely useful error and 103 - warning messages and to provide a platform for building great source 104 - level tools. The Clang Static Analyzer and clang-tidy are tools that 105 - automatically find bugs in your code, and are great examples of the sort 106 - of tools that can be built using the Clang frontend as a library to 107 - parse C/C++ code. 108 - ''; 109 - mainProgram = "clang"; 110 - }; 111 - } // lib.optionalAttrs enableManpages { 112 - pname = "clang-manpages"; 113 - 114 - buildPhase = '' 115 - make docs-clang-man 116 - ''; 117 - 118 - installPhase = '' 119 - mkdir -p $out/share/man/man1 120 - # Manually install clang manpage 121 - cp docs/man/*.1 $out/share/man/man1/ 122 - ''; 123 - 124 - outputs = [ "out" ]; 125 - 126 - doCheck = false; 127 - 128 - meta = llvm_meta // { 129 - description = "man page for Clang ${version}"; 130 - }; 131 - }); 132 - in self
+13 -3
pkgs/development/compilers/llvm/12/default.nix
··· 1 1 { lowPrio, newScope, pkgs, lib, stdenv, cmake 2 2 , preLibcCrossHeaders 3 - , substitute, fetchFromGitHub, fetchpatch 3 + , substitute, substituteAll, fetchFromGitHub, fetchpatch 4 4 , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith 5 5 , buildLlvmTools # tools, but from the previous stage, for cross 6 6 , targetLlvmLibraries # libraries, but from the next stage, for cross ··· 56 56 then tools.bintools 57 57 else bootBintools; 58 58 59 - in { 59 + in rec { 60 60 61 61 libllvm = callPackage ./llvm { 62 62 inherit llvm_meta; ··· 66 66 # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* 67 67 llvm = tools.libllvm; 68 68 69 - libclang = callPackage ./clang { 69 + libclang = callPackage ../common/clang { 70 + src = fetch "clang" "0px4gl27az6cdz6adds89qzdwb1cqpjsfvrldbz9qvpmphrj34bf"; 71 + patches = [ 72 + ./clang/purity.patch 73 + # https://reviews.llvm.org/D51899 74 + ./clang/gnu-install-dirs.patch 75 + (substituteAll { 76 + src = ../common/clang/clang-11-15-LLVMgold-path.patch; 77 + libllvmLibdir = "${libllvm.lib}/lib"; 78 + }) 79 + ]; 70 80 inherit clang-tools-extra_src llvm_meta; 71 81 }; 72 82
-126
pkgs/development/compilers/llvm/13/clang/default.nix
··· 1 - { lib, stdenv, llvm_meta, src, substituteAll, cmake, libxml2, libllvm, version, python3 2 - , buildLlvmTools 3 - , fixDarwinDylibNames 4 - , enableManpages ? false 5 - }: 6 - 7 - let 8 - self = stdenv.mkDerivation ({ 9 - pname = "clang"; 10 - inherit version; 11 - 12 - inherit src; 13 - sourceRoot = "${src.name}/clang"; 14 - 15 - nativeBuildInputs = [ cmake python3 ] 16 - ++ lib.optional enableManpages python3.pkgs.sphinx 17 - ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 18 - 19 - buildInputs = [ libxml2 libllvm ]; 20 - 21 - cmakeFlags = [ 22 - "-DCLANGD_BUILD_XPC=OFF" 23 - "-DLLVM_ENABLE_RTTI=ON" 24 - ] ++ lib.optionals enableManpages [ 25 - "-DCLANG_INCLUDE_DOCS=ON" 26 - "-DLLVM_ENABLE_SPHINX=ON" 27 - "-DSPHINX_OUTPUT_MAN=ON" 28 - "-DSPHINX_OUTPUT_HTML=OFF" 29 - "-DSPHINX_WARNINGS_AS_ERRORS=OFF" 30 - ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 31 - "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" 32 - "-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen" 33 - ]; 34 - 35 - patches = [ 36 - ./purity.patch 37 - # https://reviews.llvm.org/D51899 38 - ./gnu-install-dirs.patch 39 - # Revert of https://reviews.llvm.org/D100879 40 - # The malloc alignment assumption is incorrect for jemalloc and causes 41 - # mis-compilation in firefox. 42 - # See: https://bugzilla.mozilla.org/show_bug.cgi?id=1741454 43 - ./revert-malloc-alignment-assumption.patch 44 - ../../common/clang/add-nostdlibinc-flag.patch 45 - (substituteAll { 46 - src = ../../common/clang/clang-11-15-LLVMgold-path.patch; 47 - libllvmLibdir = "${libllvm.lib}/lib"; 48 - }) 49 - ]; 50 - 51 - postPatch = '' 52 - (cd tools && ln -s ../../clang-tools-extra extra) 53 - '' + lib.optionalString stdenv.hostPlatform.isMusl '' 54 - sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp 55 - ''; 56 - 57 - outputs = [ "out" "lib" "dev" "python" ]; 58 - 59 - postInstall = '' 60 - ln -sv $out/bin/clang $out/bin/cpp 61 - 62 - # Move libclang to 'lib' output 63 - moveToOutput "lib/libclang.*" "$lib" 64 - moveToOutput "lib/libclang-cpp.*" "$lib" 65 - substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \ 66 - --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ 67 - --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." 68 - 69 - mkdir -p $python/bin $python/share/{clang,scan-view} 70 - mv $out/bin/{git-clang-format,scan-view} $python/bin 71 - if [ -e $out/bin/set-xcode-analyzer ]; then 72 - mv $out/bin/set-xcode-analyzer $python/bin 73 - fi 74 - mv $out/share/clang/*.py $python/share/clang 75 - mv $out/share/scan-view/*.py $python/share/scan-view 76 - rm $out/bin/c-index-test 77 - patchShebangs $python/bin 78 - 79 - mkdir -p $dev/bin 80 - cp bin/clang-tblgen $dev/bin 81 - ''; 82 - 83 - passthru = { 84 - inherit libllvm; 85 - isClang = true; 86 - hardeningUnsupportedFlags = [ "fortify3" "zerocallusedregs" ]; 87 - }; 88 - 89 - meta = llvm_meta // { 90 - homepage = "https://clang.llvm.org/"; 91 - description = "A C language family frontend for LLVM"; 92 - longDescription = '' 93 - The Clang project provides a language front-end and tooling 94 - infrastructure for languages in the C language family (C, C++, Objective 95 - C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project. 96 - It aims to deliver amazingly fast compiles, extremely useful error and 97 - warning messages and to provide a platform for building great source 98 - level tools. The Clang Static Analyzer and clang-tidy are tools that 99 - automatically find bugs in your code, and are great examples of the sort 100 - of tools that can be built using the Clang frontend as a library to 101 - parse C/C++ code. 102 - ''; 103 - mainProgram = "clang"; 104 - }; 105 - } // lib.optionalAttrs enableManpages { 106 - pname = "clang-manpages"; 107 - 108 - buildPhase = '' 109 - make docs-clang-man 110 - ''; 111 - 112 - installPhase = '' 113 - mkdir -p $out/share/man/man1 114 - # Manually install clang manpage 115 - cp docs/man/*.1 $out/share/man/man1/ 116 - ''; 117 - 118 - outputs = [ "out" ]; 119 - 120 - doCheck = false; 121 - 122 - meta = llvm_meta // { 123 - description = "man page for Clang ${version}"; 124 - }; 125 - }); 126 - in self
+18 -3
pkgs/development/compilers/llvm/13/default.nix
··· 1 1 { lowPrio, newScope, pkgs, lib, stdenv, cmake 2 2 , preLibcCrossHeaders 3 3 , fetchpatch 4 - , libxml2, python3, isl, fetchFromGitHub, substitute, overrideCC, wrapCCWith, wrapBintoolsWith 4 + , libxml2, python3, isl, fetchFromGitHub, substitute, substituteAll, overrideCC, wrapCCWith, wrapBintoolsWith 5 5 , buildLlvmTools # tools, but from the previous stage, for cross 6 6 , targetLlvmLibraries # libraries, but from the next stage, for cross 7 7 , targetLlvm ··· 82 82 then tools.bintools 83 83 else bootBintools; 84 84 85 - in { 85 + in rec { 86 86 87 87 libllvm = callPackage ./llvm { 88 88 inherit llvm_meta; ··· 92 92 # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* 93 93 llvm = tools.libllvm; 94 94 95 - libclang = callPackage ./clang { 95 + libclang = callPackage ../common/clang { 96 + patches = [ 97 + ./clang/purity.patch 98 + # https://reviews.llvm.org/D51899 99 + ./clang/gnu-install-dirs.patch 100 + # Revert of https://reviews.llvm.org/D100879 101 + # The malloc alignment assumption is incorrect for jemalloc and causes 102 + # mis-compilation in firefox. 103 + # See: https://bugzilla.mozilla.org/show_bug.cgi?id=1741454 104 + ./clang/revert-malloc-alignment-assumption.patch 105 + ../common/clang/add-nostdlibinc-flag.patch 106 + (substituteAll { 107 + src = ../common/clang/clang-11-15-LLVMgold-path.patch; 108 + libllvmLibdir = "${libllvm.lib}/lib"; 109 + }) 110 + ]; 96 111 inherit llvm_meta; 97 112 }; 98 113
-129
pkgs/development/compilers/llvm/14/clang/default.nix
··· 1 - { lib, stdenv, llvm_meta 2 - , monorepoSrc, runCommand 3 - , substituteAll, cmake, libxml2, libllvm, version, python3 4 - , buildLlvmTools 5 - , fixDarwinDylibNames 6 - , enableManpages ? false 7 - }: 8 - 9 - let 10 - self = stdenv.mkDerivation (rec { 11 - pname = "clang"; 12 - inherit version; 13 - 14 - src = runCommand "${pname}-src-${version}" {} '' 15 - mkdir -p "$out" 16 - cp -r ${monorepoSrc}/cmake "$out" 17 - cp -r ${monorepoSrc}/${pname} "$out" 18 - cp -r ${monorepoSrc}/clang-tools-extra "$out" 19 - ''; 20 - 21 - sourceRoot = "${src.name}/${pname}"; 22 - 23 - nativeBuildInputs = [ cmake python3 ] 24 - ++ lib.optional enableManpages python3.pkgs.sphinx 25 - ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 26 - 27 - buildInputs = [ libxml2 libllvm ]; 28 - 29 - cmakeFlags = [ 30 - "-DCLANGD_BUILD_XPC=OFF" 31 - "-DLLVM_ENABLE_RTTI=ON" 32 - ] ++ lib.optionals enableManpages [ 33 - "-DCLANG_INCLUDE_DOCS=ON" 34 - "-DLLVM_ENABLE_SPHINX=ON" 35 - "-DSPHINX_OUTPUT_MAN=ON" 36 - "-DSPHINX_OUTPUT_HTML=OFF" 37 - "-DSPHINX_WARNINGS_AS_ERRORS=OFF" 38 - ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 39 - "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" 40 - "-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen" 41 - ]; 42 - 43 - patches = [ 44 - ./purity.patch 45 - # https://reviews.llvm.org/D51899 46 - ./gnu-install-dirs.patch 47 - ../../common/clang/add-nostdlibinc-flag.patch 48 - (substituteAll { 49 - src = ../../common/clang/clang-11-15-LLVMgold-path.patch; 50 - libllvmLibdir = "${libllvm.lib}/lib"; 51 - }) 52 - ]; 53 - 54 - postPatch = '' 55 - (cd tools && ln -s ../../clang-tools-extra extra) 56 - '' + lib.optionalString stdenv.hostPlatform.isMusl '' 57 - sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp 58 - ''; 59 - 60 - outputs = [ "out" "lib" "dev" "python" ]; 61 - 62 - postInstall = '' 63 - ln -sv $out/bin/clang $out/bin/cpp 64 - 65 - # Move libclang to 'lib' output 66 - moveToOutput "lib/libclang.*" "$lib" 67 - moveToOutput "lib/libclang-cpp.*" "$lib" 68 - substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \ 69 - --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ 70 - --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." 71 - 72 - mkdir -p $python/bin $python/share/{clang,scan-view} 73 - mv $out/bin/{git-clang-format,scan-view} $python/bin 74 - if [ -e $out/bin/set-xcode-analyzer ]; then 75 - mv $out/bin/set-xcode-analyzer $python/bin 76 - fi 77 - mv $out/share/clang/*.py $python/share/clang 78 - mv $out/share/scan-view/*.py $python/share/scan-view 79 - rm $out/bin/c-index-test 80 - patchShebangs $python/bin 81 - 82 - mkdir -p $dev/bin 83 - cp bin/clang-tblgen $dev/bin 84 - ''; 85 - 86 - passthru = { 87 - inherit libllvm; 88 - isClang = true; 89 - hardeningUnsupportedFlags = [ "fortify3" "zerocallusedregs" ]; 90 - }; 91 - 92 - meta = llvm_meta // { 93 - homepage = "https://clang.llvm.org/"; 94 - description = "A C language family frontend for LLVM"; 95 - longDescription = '' 96 - The Clang project provides a language front-end and tooling 97 - infrastructure for languages in the C language family (C, C++, Objective 98 - C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project. 99 - It aims to deliver amazingly fast compiles, extremely useful error and 100 - warning messages and to provide a platform for building great source 101 - level tools. The Clang Static Analyzer and clang-tidy are tools that 102 - automatically find bugs in your code, and are great examples of the sort 103 - of tools that can be built using the Clang frontend as a library to 104 - parse C/C++ code. 105 - ''; 106 - mainProgram = "clang"; 107 - }; 108 - } // lib.optionalAttrs enableManpages { 109 - pname = "clang-manpages"; 110 - 111 - buildPhase = '' 112 - make docs-clang-man 113 - ''; 114 - 115 - installPhase = '' 116 - mkdir -p $out/share/man/man1 117 - # Manually install clang manpage 118 - cp docs/man/*.1 $out/share/man/man1/ 119 - ''; 120 - 121 - outputs = [ "out" ]; 122 - 123 - doCheck = false; 124 - 125 - meta = llvm_meta // { 126 - description = "man page for Clang ${version}"; 127 - }; 128 - }); 129 - in self
+13 -3
pkgs/development/compilers/llvm/14/default.nix
··· 1 1 { lowPrio, newScope, pkgs, lib, stdenv, cmake 2 2 , preLibcCrossHeaders 3 - , libxml2, python3, fetchFromGitHub, substitute, overrideCC, wrapCCWith, wrapBintoolsWith 3 + , libxml2, python3, fetchFromGitHub, substitute, substituteAll, overrideCC, wrapCCWith, wrapBintoolsWith 4 4 , buildLlvmTools # tools, but from the previous stage, for cross 5 5 , targetLlvmLibraries # libraries, but from the next stage, for cross 6 6 , targetLlvm ··· 78 78 then tools.bintools 79 79 else bootBintools; 80 80 81 - in { 81 + in rec { 82 82 83 83 libllvm = callPackage ./llvm { 84 84 inherit llvm_meta; ··· 88 88 # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* 89 89 llvm = tools.libllvm; 90 90 91 - libclang = callPackage ./clang { 91 + libclang = callPackage ../common/clang { 92 + patches = [ 93 + ./clang/purity.patch 94 + # https://reviews.llvm.org/D51899 95 + ./clang/gnu-install-dirs.patch 96 + ../common/clang/add-nostdlibinc-flag.patch 97 + (substituteAll { 98 + src = ../common/clang/clang-11-15-LLVMgold-path.patch; 99 + libllvmLibdir = "${libllvm.lib}/lib"; 100 + }) 101 + ]; 92 102 inherit llvm_meta; 93 103 }; 94 104
-143
pkgs/development/compilers/llvm/15/clang/default.nix
··· 1 - { lib, stdenv, llvm_meta 2 - , monorepoSrc, runCommand 3 - , substituteAll, cmake, ninja, libxml2, libllvm, version, python3 4 - , buildLlvmTools 5 - , fixDarwinDylibNames 6 - , enableManpages ? false 7 - }: 8 - 9 - let 10 - self = stdenv.mkDerivation (finalAttrs: rec { 11 - pname = "clang"; 12 - inherit version; 13 - 14 - src = runCommand "${pname}-src-${version}" {} '' 15 - mkdir -p "$out" 16 - cp -r ${monorepoSrc}/cmake "$out" 17 - cp -r ${monorepoSrc}/${pname} "$out" 18 - cp -r ${monorepoSrc}/clang-tools-extra "$out" 19 - ''; 20 - 21 - sourceRoot = "${src.name}/${pname}"; 22 - 23 - nativeBuildInputs = [ cmake ninja python3 ] 24 - ++ lib.optional enableManpages python3.pkgs.sphinx 25 - ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 26 - 27 - buildInputs = [ libxml2 libllvm ]; 28 - 29 - cmakeFlags = [ 30 - "-DCLANG_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/clang" 31 - "-DCLANGD_BUILD_XPC=OFF" 32 - "-DLLVM_ENABLE_RTTI=ON" 33 - ] ++ lib.optionals enableManpages [ 34 - "-DCLANG_INCLUDE_DOCS=ON" 35 - "-DLLVM_ENABLE_SPHINX=ON" 36 - "-DSPHINX_OUTPUT_MAN=ON" 37 - "-DSPHINX_OUTPUT_HTML=OFF" 38 - "-DSPHINX_WARNINGS_AS_ERRORS=OFF" 39 - ] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ 40 - "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" 41 - "-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen" 42 - # Added in LLVM15: 43 - # `clang-tidy-confusable-chars-gen`: https://github.com/llvm/llvm-project/commit/c3574ef739fbfcc59d405985a3a4fa6f4619ecdb 44 - # `clang-pseudo-gen`: https://github.com/llvm/llvm-project/commit/cd2292ef824591cc34cc299910a3098545c840c7 45 - "-DCLANG_TIDY_CONFUSABLE_CHARS_GEN=${buildLlvmTools.libclang.dev}/bin/clang-tidy-confusable-chars-gen" 46 - "-DCLANG_PSEUDO_GEN=${buildLlvmTools.libclang.dev}/bin/clang-pseudo-gen" 47 - ]; 48 - 49 - patches = [ 50 - ./purity.patch 51 - # https://reviews.llvm.org/D51899 52 - ./gnu-install-dirs.patch 53 - ../../common/clang/add-nostdlibinc-flag.patch 54 - (substituteAll { 55 - src = ../../common/clang/clang-11-15-LLVMgold-path.patch; 56 - libllvmLibdir = "${libllvm.lib}/lib"; 57 - }) 58 - ]; 59 - 60 - postPatch = '' 61 - (cd tools && ln -s ../../clang-tools-extra extra) 62 - '' + lib.optionalString stdenv.hostPlatform.isMusl '' 63 - sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp 64 - ''; 65 - 66 - outputs = [ "out" "lib" "dev" "python" ]; 67 - 68 - env = lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { 69 - # The following warning is triggered with (at least) gcc >= 70 - # 12, but appears to occur only for cross compiles. 71 - NIX_CFLAGS_COMPILE = "-Wno-maybe-uninitialized"; 72 - }; 73 - 74 - postInstall = '' 75 - ln -sv $out/bin/clang $out/bin/cpp 76 - 77 - # Move libclang to 'lib' output 78 - moveToOutput "lib/libclang.*" "$lib" 79 - moveToOutput "lib/libclang-cpp.*" "$lib" 80 - substituteInPlace $dev/lib/cmake/clang/ClangTargets-release.cmake \ 81 - --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ 82 - --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." 83 - 84 - mkdir -p $python/bin $python/share/clang/ 85 - mv $out/bin/{git-clang-format,scan-view} $python/bin 86 - if [ -e $out/bin/set-xcode-analyzer ]; then 87 - mv $out/bin/set-xcode-analyzer $python/bin 88 - fi 89 - mv $out/share/clang/*.py $python/share/clang 90 - rm $out/bin/c-index-test 91 - patchShebangs $python/bin 92 - 93 - mkdir -p $dev/bin 94 - cp bin/{clang-tblgen,clang-tidy-confusable-chars-gen,clang-pseudo-gen} $dev/bin 95 - ''; 96 - 97 - passthru = { 98 - inherit libllvm; 99 - isClang = true; 100 - hardeningUnsupportedFlags = [ 101 - "fortify3" 102 - ]; 103 - hardeningUnsupportedFlagsByTargetPlatform = targetPlatform: 104 - lib.optional (!(targetPlatform.isx86_64 || targetPlatform.isAarch64)) "zerocallusedregs" 105 - ++ (finalAttrs.passthru.hardeningUnsupportedFlags or []); 106 - }; 107 - 108 - meta = llvm_meta // { 109 - homepage = "https://clang.llvm.org/"; 110 - description = "A C language family frontend for LLVM"; 111 - longDescription = '' 112 - The Clang project provides a language front-end and tooling 113 - infrastructure for languages in the C language family (C, C++, Objective 114 - C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project. 115 - It aims to deliver amazingly fast compiles, extremely useful error and 116 - warning messages and to provide a platform for building great source 117 - level tools. The Clang Static Analyzer and clang-tidy are tools that 118 - automatically find bugs in your code, and are great examples of the sort 119 - of tools that can be built using the Clang frontend as a library to 120 - parse C/C++ code. 121 - ''; 122 - mainProgram = "clang"; 123 - }; 124 - } // lib.optionalAttrs enableManpages { 125 - pname = "clang-manpages"; 126 - 127 - ninjaFlags = [ "docs-clang-man" ]; 128 - 129 - installPhase = '' 130 - mkdir -p $out/share/man/man1 131 - # Manually install clang manpage 132 - cp docs/man/*.1 $out/share/man/man1/ 133 - ''; 134 - 135 - outputs = [ "out" ]; 136 - 137 - doCheck = false; 138 - 139 - meta = llvm_meta // { 140 - description = "man page for Clang ${version}"; 141 - }; 142 - }); 143 - in self
+13 -3
pkgs/development/compilers/llvm/15/default.nix
··· 1 1 { lowPrio, newScope, pkgs, lib, stdenv, cmake, ninja 2 2 , preLibcCrossHeaders 3 - , libxml2, python3, fetchFromGitHub, fetchpatch, substitute, overrideCC, wrapCCWith, wrapBintoolsWith 3 + , libxml2, python3, fetchFromGitHub, fetchpatch, substitute, substituteAll, overrideCC, wrapCCWith, wrapBintoolsWith 4 4 , buildLlvmTools # tools, but from the previous stage, for cross 5 5 , targetLlvmLibraries # libraries, but from the next stage, for cross 6 6 , targetLlvm ··· 84 84 then tools.bintools 85 85 else bootBintools; 86 86 87 - in { 87 + in rec { 88 88 89 89 libllvm = callPackage ./llvm { 90 90 inherit llvm_meta; ··· 94 94 # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* 95 95 llvm = tools.libllvm; 96 96 97 - libclang = callPackage ./clang { 97 + libclang = callPackage ../common/clang { 98 + patches = [ 99 + ./clang/purity.patch 100 + # https://reviews.llvm.org/D51899 101 + ./clang/gnu-install-dirs.patch 102 + ../common/clang/add-nostdlibinc-flag.patch 103 + (substituteAll { 104 + src = ../common/clang/clang-11-15-LLVMgold-path.patch; 105 + libllvmLibdir = "${libllvm.lib}/lib"; 106 + }) 107 + ]; 98 108 inherit llvm_meta; 99 109 }; 100 110
-137
pkgs/development/compilers/llvm/16/clang/default.nix
··· 1 - { lib, stdenv, llvm_meta 2 - , monorepoSrc, runCommand 3 - , substituteAll, cmake, ninja, libxml2, libllvm, version, python3 4 - , buildLlvmTools 5 - , fixDarwinDylibNames 6 - , enableManpages ? false 7 - }: 8 - 9 - let 10 - self = stdenv.mkDerivation (finalAttrs: rec { 11 - pname = "clang"; 12 - inherit version; 13 - 14 - src = runCommand "${pname}-src-${version}" {} '' 15 - mkdir -p "$out" 16 - cp -r ${monorepoSrc}/cmake "$out" 17 - cp -r ${monorepoSrc}/${pname} "$out" 18 - cp -r ${monorepoSrc}/clang-tools-extra "$out" 19 - ''; 20 - 21 - sourceRoot = "${src.name}/${pname}"; 22 - 23 - nativeBuildInputs = [ cmake ninja python3 ] 24 - ++ lib.optional enableManpages python3.pkgs.sphinx 25 - ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 26 - 27 - buildInputs = [ libxml2 libllvm ]; 28 - 29 - cmakeFlags = [ 30 - "-DCLANG_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/clang" 31 - "-DCLANGD_BUILD_XPC=OFF" 32 - "-DLLVM_ENABLE_RTTI=ON" 33 - ] ++ lib.optionals enableManpages [ 34 - "-DCLANG_INCLUDE_DOCS=ON" 35 - "-DLLVM_ENABLE_SPHINX=ON" 36 - "-DSPHINX_OUTPUT_MAN=ON" 37 - "-DSPHINX_OUTPUT_HTML=OFF" 38 - "-DSPHINX_WARNINGS_AS_ERRORS=OFF" 39 - ] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ 40 - "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" 41 - "-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen" 42 - # Added in LLVM15: 43 - # `clang-tidy-confusable-chars-gen`: https://github.com/llvm/llvm-project/commit/c3574ef739fbfcc59d405985a3a4fa6f4619ecdb 44 - # `clang-pseudo-gen`: https://github.com/llvm/llvm-project/commit/cd2292ef824591cc34cc299910a3098545c840c7 45 - "-DCLANG_TIDY_CONFUSABLE_CHARS_GEN=${buildLlvmTools.libclang.dev}/bin/clang-tidy-confusable-chars-gen" 46 - "-DCLANG_PSEUDO_GEN=${buildLlvmTools.libclang.dev}/bin/clang-pseudo-gen" 47 - ]; 48 - 49 - patches = [ 50 - ./purity.patch 51 - # https://reviews.llvm.org/D51899 52 - ./gnu-install-dirs.patch 53 - ../../common/clang/add-nostdlibinc-flag.patch 54 - (substituteAll { 55 - src = ../../common/clang/clang-at-least-16-LLVMgold-path.patch; 56 - libllvmLibdir = "${libllvm.lib}/lib"; 57 - }) 58 - ]; 59 - 60 - postPatch = '' 61 - (cd tools && ln -s ../../clang-tools-extra extra) 62 - '' + lib.optionalString stdenv.hostPlatform.isMusl '' 63 - sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp 64 - ''; 65 - 66 - outputs = [ "out" "lib" "dev" "python" ]; 67 - 68 - postInstall = '' 69 - ln -sv $out/bin/clang $out/bin/cpp 70 - 71 - # Move libclang to 'lib' output 72 - moveToOutput "lib/libclang.*" "$lib" 73 - moveToOutput "lib/libclang-cpp.*" "$lib" 74 - substituteInPlace $dev/lib/cmake/clang/ClangTargets-release.cmake \ 75 - --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ 76 - --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." 77 - 78 - mkdir -p $python/bin $python/share/clang/ 79 - mv $out/bin/{git-clang-format,scan-view} $python/bin 80 - if [ -e $out/bin/set-xcode-analyzer ]; then 81 - mv $out/bin/set-xcode-analyzer $python/bin 82 - fi 83 - mv $out/share/clang/*.py $python/share/clang 84 - rm $out/bin/c-index-test 85 - patchShebangs $python/bin 86 - 87 - mkdir -p $dev/bin 88 - cp bin/{clang-tblgen,clang-tidy-confusable-chars-gen,clang-pseudo-gen} $dev/bin 89 - ''; 90 - 91 - passthru = { 92 - inherit libllvm; 93 - isClang = true; 94 - hardeningUnsupportedFlags = [ 95 - "fortify3" 96 - ]; 97 - hardeningUnsupportedFlagsByTargetPlatform = targetPlatform: 98 - lib.optional (!(targetPlatform.isx86_64 || targetPlatform.isAarch64)) "zerocallusedregs" 99 - ++ (finalAttrs.passthru.hardeningUnsupportedFlags or []); 100 - }; 101 - 102 - meta = llvm_meta // { 103 - homepage = "https://clang.llvm.org/"; 104 - description = "A C language family frontend for LLVM"; 105 - longDescription = '' 106 - The Clang project provides a language front-end and tooling 107 - infrastructure for languages in the C language family (C, C++, Objective 108 - C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project. 109 - It aims to deliver amazingly fast compiles, extremely useful error and 110 - warning messages and to provide a platform for building great source 111 - level tools. The Clang Static Analyzer and clang-tidy are tools that 112 - automatically find bugs in your code, and are great examples of the sort 113 - of tools that can be built using the Clang frontend as a library to 114 - parse C/C++ code. 115 - ''; 116 - mainProgram = "clang"; 117 - }; 118 - } // lib.optionalAttrs enableManpages { 119 - pname = "clang-manpages"; 120 - 121 - ninjaFlags = [ "docs-clang-man" ]; 122 - 123 - installPhase = '' 124 - mkdir -p $out/share/man/man1 125 - # Manually install clang manpage 126 - cp docs/man/*.1 $out/share/man/man1/ 127 - ''; 128 - 129 - outputs = [ "out" ]; 130 - 131 - doCheck = false; 132 - 133 - meta = llvm_meta // { 134 - description = "man page for Clang ${version}"; 135 - }; 136 - }); 137 - in self
+13 -3
pkgs/development/compilers/llvm/16/default.nix
··· 1 1 { lowPrio, newScope, pkgs, lib, stdenv, cmake, ninja 2 2 , preLibcCrossHeaders 3 - , libxml2, python3, fetchFromGitHub, overrideCC, wrapCCWith, wrapBintoolsWith 3 + , libxml2, python3, fetchFromGitHub, substituteAll, overrideCC, wrapCCWith, wrapBintoolsWith 4 4 , buildLlvmTools # tools, but from the previous stage, for cross 5 5 , targetLlvmLibraries # libraries, but from the next stage, for cross 6 6 , targetLlvm ··· 85 85 then tools.bintools 86 86 else bootBintools; 87 87 88 - in { 88 + in rec { 89 89 90 90 libllvm = callPackage ./llvm { 91 91 inherit llvm_meta; ··· 95 95 # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* 96 96 llvm = tools.libllvm; 97 97 98 - libclang = callPackage ./clang { 98 + libclang = callPackage ../common/clang { 99 + patches = [ 100 + ./clang/purity.patch 101 + # https://reviews.llvm.org/D51899 102 + ./clang/gnu-install-dirs.patch 103 + ../common/clang/add-nostdlibinc-flag.patch 104 + (substituteAll { 105 + src = ../common/clang/clang-at-least-16-LLVMgold-path.patch; 106 + libllvmLibdir = "${libllvm.lib}/lib"; 107 + }) 108 + ]; 99 109 inherit llvm_meta; 100 110 }; 101 111
-141
pkgs/development/compilers/llvm/17/clang/default.nix
··· 1 - { lib, stdenv, llvm_meta 2 - , monorepoSrc, runCommand 3 - , substituteAll, cmake, ninja, libxml2, libllvm, version, python3 4 - , buildLlvmTools 5 - , fixDarwinDylibNames 6 - , enableManpages ? false 7 - }: 8 - 9 - let 10 - self = stdenv.mkDerivation (finalAttrs: rec { 11 - pname = "clang"; 12 - inherit version; 13 - 14 - src = runCommand "${pname}-src-${version}" {} '' 15 - mkdir -p "$out" 16 - cp -r ${monorepoSrc}/cmake "$out" 17 - cp -r ${monorepoSrc}/${pname} "$out" 18 - cp -r ${monorepoSrc}/clang-tools-extra "$out" 19 - ''; 20 - 21 - sourceRoot = "${src.name}/${pname}"; 22 - 23 - nativeBuildInputs = [ cmake ninja python3 ] 24 - ++ lib.optional enableManpages python3.pkgs.sphinx 25 - ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 26 - 27 - buildInputs = [ libxml2 libllvm ]; 28 - 29 - cmakeFlags = [ 30 - "-DCLANG_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/clang" 31 - "-DCLANGD_BUILD_XPC=OFF" 32 - "-DLLVM_ENABLE_RTTI=ON" 33 - "-DLLVM_INCLUDE_TESTS=OFF" 34 - ] ++ lib.optionals enableManpages [ 35 - "-DCLANG_INCLUDE_DOCS=ON" 36 - "-DLLVM_ENABLE_SPHINX=ON" 37 - "-DSPHINX_OUTPUT_MAN=ON" 38 - "-DSPHINX_OUTPUT_HTML=OFF" 39 - "-DSPHINX_WARNINGS_AS_ERRORS=OFF" 40 - ] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ 41 - "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" 42 - "-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen" 43 - # Added in LLVM15: 44 - # `clang-tidy-confusable-chars-gen`: https://github.com/llvm/llvm-project/commit/c3574ef739fbfcc59d405985a3a4fa6f4619ecdb 45 - # `clang-pseudo-gen`: https://github.com/llvm/llvm-project/commit/cd2292ef824591cc34cc299910a3098545c840c7 46 - "-DCLANG_TIDY_CONFUSABLE_CHARS_GEN=${buildLlvmTools.libclang.dev}/bin/clang-tidy-confusable-chars-gen" 47 - "-DCLANG_PSEUDO_GEN=${buildLlvmTools.libclang.dev}/bin/clang-pseudo-gen" 48 - ]; 49 - 50 - patches = [ 51 - ./purity.patch 52 - # https://reviews.llvm.org/D51899 53 - ./gnu-install-dirs.patch 54 - ../../common/clang/add-nostdlibinc-flag.patch 55 - (substituteAll { 56 - src = ../../common/clang/clang-at-least-16-LLVMgold-path.patch; 57 - libllvmLibdir = "${libllvm.lib}/lib"; 58 - }) 59 - ]; 60 - 61 - postPatch = '' 62 - (cd tools && ln -s ../../clang-tools-extra extra) 63 - '' + lib.optionalString stdenv.hostPlatform.isMusl '' 64 - sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp 65 - ''; 66 - 67 - outputs = [ "out" "lib" "dev" "python" ]; 68 - 69 - postInstall = '' 70 - ln -sv $out/bin/clang $out/bin/cpp 71 - 72 - mkdir -p $lib/lib/clang 73 - mv $lib/lib/17 $lib/lib/clang/17 74 - 75 - # Move libclang to 'lib' output 76 - moveToOutput "lib/libclang.*" "$lib" 77 - moveToOutput "lib/libclang-cpp.*" "$lib" 78 - substituteInPlace $dev/lib/cmake/clang/ClangTargets-release.cmake \ 79 - --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ 80 - --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." 81 - 82 - mkdir -p $python/bin $python/share/clang/ 83 - mv $out/bin/{git-clang-format,scan-view} $python/bin 84 - if [ -e $out/bin/set-xcode-analyzer ]; then 85 - mv $out/bin/set-xcode-analyzer $python/bin 86 - fi 87 - mv $out/share/clang/*.py $python/share/clang 88 - rm $out/bin/c-index-test 89 - patchShebangs $python/bin 90 - 91 - mkdir -p $dev/bin 92 - cp bin/{clang-tblgen,clang-tidy-confusable-chars-gen,clang-pseudo-gen} $dev/bin 93 - ''; 94 - 95 - passthru = { 96 - inherit libllvm; 97 - isClang = true; 98 - hardeningUnsupportedFlags = [ 99 - "fortify3" 100 - ]; 101 - hardeningUnsupportedFlagsByTargetPlatform = targetPlatform: 102 - lib.optional (!(targetPlatform.isx86_64 || targetPlatform.isAarch64)) "zerocallusedregs" 103 - ++ (finalAttrs.passthru.hardeningUnsupportedFlags or []); 104 - }; 105 - 106 - meta = llvm_meta // { 107 - homepage = "https://clang.llvm.org/"; 108 - description = "A C language family frontend for LLVM"; 109 - longDescription = '' 110 - The Clang project provides a language front-end and tooling 111 - infrastructure for languages in the C language family (C, C++, Objective 112 - C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project. 113 - It aims to deliver amazingly fast compiles, extremely useful error and 114 - warning messages and to provide a platform for building great source 115 - level tools. The Clang Static Analyzer and clang-tidy are tools that 116 - automatically find bugs in your code, and are great examples of the sort 117 - of tools that can be built using the Clang frontend as a library to 118 - parse C/C++ code. 119 - ''; 120 - mainProgram = "clang"; 121 - }; 122 - } // lib.optionalAttrs enableManpages { 123 - pname = "clang-manpages"; 124 - 125 - ninjaFlags = [ "docs-clang-man" ]; 126 - 127 - installPhase = '' 128 - mkdir -p $out/share/man/man1 129 - # Manually install clang manpage 130 - cp docs/man/*.1 $out/share/man/man1/ 131 - ''; 132 - 133 - outputs = [ "out" ]; 134 - 135 - doCheck = false; 136 - 137 - meta = llvm_meta // { 138 - description = "man page for Clang ${version}"; 139 - }; 140 - }); 141 - in self
+13 -3
pkgs/development/compilers/llvm/17/default.nix
··· 1 1 { lowPrio, newScope, pkgs, lib, stdenv, cmake, ninja 2 2 , preLibcCrossHeaders 3 - , libxml2, python3, fetchFromGitHub, fetchpatch, overrideCC, wrapCCWith, wrapBintoolsWith 3 + , libxml2, python3, fetchFromGitHub, fetchpatch, substituteAll, overrideCC, wrapCCWith, wrapBintoolsWith 4 4 , buildLlvmTools # tools, but from the previous stage, for cross 5 5 , targetLlvmLibraries # libraries, but from the next stage, for cross 6 6 , targetLlvm ··· 80 80 then tools.bintools 81 81 else bootBintools; 82 82 83 - in { 83 + in rec { 84 84 85 85 libllvm = callPackage ./llvm { 86 86 inherit llvm_meta; ··· 90 90 # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* 91 91 llvm = tools.libllvm; 92 92 93 - libclang = callPackage ./clang { 93 + libclang = callPackage ../common/clang { 94 + patches = [ 95 + ./clang/purity.patch 96 + # https://reviews.llvm.org/D51899 97 + ./clang/gnu-install-dirs.patch 98 + ../common/clang/add-nostdlibinc-flag.patch 99 + (substituteAll { 100 + src = ../common/clang/clang-at-least-16-LLVMgold-path.patch; 101 + libllvmLibdir = "${libllvm.lib}/lib"; 102 + }) 103 + ]; 94 104 inherit llvm_meta; 95 105 }; 96 106
+13 -3
pkgs/development/compilers/llvm/18/default.nix
··· 1 1 { lowPrio, newScope, pkgs, lib, stdenv, cmake, ninja 2 2 , preLibcCrossHeaders 3 - , libxml2, python3, fetchFromGitHub, overrideCC, wrapCCWith, wrapBintoolsWith 3 + , libxml2, python3, fetchFromGitHub, substituteAll, overrideCC, wrapCCWith, wrapBintoolsWith 4 4 , buildLlvmTools # tools, but from the previous stage, for cross 5 5 , targetLlvmLibraries # libraries, but from the next stage, for cross 6 6 , targetLlvm ··· 80 80 then tools.bintools 81 81 else bootBintools; 82 82 83 - in { 83 + in rec { 84 84 85 85 libllvm = callPackage ./llvm { 86 86 inherit llvm_meta; ··· 90 90 # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* 91 91 llvm = tools.libllvm; 92 92 93 - libclang = callPackage ./clang { 93 + libclang = callPackage ../common/clang { 94 + patches = [ 95 + ./clang/purity.patch 96 + # https://reviews.llvm.org/D51899 97 + ./clang/gnu-install-dirs.patch 98 + ../common/clang/add-nostdlibinc-flag.patch 99 + (substituteAll { 100 + src = ../common/clang/clang-at-least-16-LLVMgold-path.patch; 101 + libllvmLibdir = "${libllvm.lib}/lib"; 102 + }) 103 + ]; 94 104 inherit llvm_meta; 95 105 }; 96 106
+201
pkgs/development/compilers/llvm/common/clang/default.nix
··· 1 + { lib 2 + , stdenv 3 + , llvm_meta 4 + , patches ? [] 5 + , src ? null 6 + , monorepoSrc ? null 7 + , runCommand 8 + , substituteAll 9 + , cmake 10 + , ninja 11 + , libxml2 12 + , libllvm 13 + , release_version 14 + , version 15 + , python3 16 + , buildLlvmTools 17 + , fixDarwinDylibNames 18 + , enableManpages ? false 19 + , clang-tools-extra_src ? null 20 + }: 21 + 22 + let 23 + pname = "clang"; 24 + 25 + src' = if monorepoSrc != null then 26 + runCommand "${pname}-src-${version}" {} '' 27 + mkdir -p "$out" 28 + cp -r ${monorepoSrc}/cmake "$out" 29 + cp -r ${monorepoSrc}/${pname} "$out" 30 + cp -r ${monorepoSrc}/clang-tools-extra "$out" 31 + '' else src; 32 + 33 + self = stdenv.mkDerivation (finalAttrs: rec { 34 + inherit pname version patches; 35 + 36 + src = src'; 37 + 38 + sourceRoot = if lib.versionOlder release_version "13" then null 39 + else "${src.name}/${pname}"; 40 + 41 + nativeBuildInputs = [ cmake ] 42 + ++ (lib.optional (lib.versionAtLeast release_version "15") ninja) 43 + ++ [ python3 ] 44 + ++ lib.optional (lib.versionAtLeast version "18" && enableManpages) python3.pkgs.myst-parser 45 + ++ lib.optional enableManpages python3.pkgs.sphinx 46 + ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 47 + 48 + buildInputs = [ libxml2 libllvm ]; 49 + 50 + cmakeFlags = (lib.optionals (lib.versionAtLeast release_version "15") [ 51 + "-DCLANG_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/clang" 52 + ]) ++ [ 53 + "-DCLANGD_BUILD_XPC=OFF" 54 + "-DLLVM_ENABLE_RTTI=ON" 55 + ] ++ lib.optionals (lib.versionAtLeast release_version "17") [ 56 + "-DLLVM_INCLUDE_TESTS=OFF" 57 + ] ++ lib.optionals enableManpages [ 58 + "-DCLANG_INCLUDE_DOCS=ON" 59 + "-DLLVM_ENABLE_SPHINX=ON" 60 + "-DSPHINX_OUTPUT_MAN=ON" 61 + "-DSPHINX_OUTPUT_HTML=OFF" 62 + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" 63 + ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) ([ 64 + "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" 65 + "-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen" 66 + ] ++ lib.optionals (lib.versionAtLeast release_version "15") [ 67 + # Added in LLVM15: 68 + # `clang-tidy-confusable-chars-gen`: https://github.com/llvm/llvm-project/commit/c3574ef739fbfcc59d405985a3a4fa6f4619ecdb 69 + # `clang-pseudo-gen`: https://github.com/llvm/llvm-project/commit/cd2292ef824591cc34cc299910a3098545c840c7 70 + "-DCLANG_TIDY_CONFUSABLE_CHARS_GEN=${buildLlvmTools.libclang.dev}/bin/clang-tidy-confusable-chars-gen" 71 + "-DCLANG_PSEUDO_GEN=${buildLlvmTools.libclang.dev}/bin/clang-pseudo-gen" 72 + ]); 73 + 74 + postPatch = (if lib.versionOlder release_version "13" then '' 75 + sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \ 76 + -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \ 77 + lib/Driver/ToolChains/*.cpp 78 + '' else '' 79 + (cd tools && ln -s ../../clang-tools-extra extra) 80 + '') + lib.optionalString stdenv.hostPlatform.isMusl '' 81 + sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp 82 + ''; 83 + 84 + outputs = [ "out" "lib" "dev" "python" ]; 85 + 86 + postInstall = '' 87 + ln -sv $out/bin/clang $out/bin/cpp 88 + '' + (lib.optionalString (lib.versions.major release_version == "17") '' 89 + 90 + mkdir -p $lib/lib/clang 91 + mv $lib/lib/17 $lib/lib/clang/17 92 + '') + '' 93 + 94 + # Move libclang to 'lib' output 95 + moveToOutput "lib/libclang.*" "$lib" 96 + moveToOutput "lib/libclang-cpp.*" "$lib" 97 + '' + (if lib.versionOlder release_version "15" then '' 98 + substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \ 99 + --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ 100 + --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." 101 + '' else '' 102 + substituteInPlace $dev/lib/cmake/clang/ClangTargets-release.cmake \ 103 + --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ 104 + --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." 105 + '') + '' 106 + 107 + '' + (if lib.versionOlder release_version "15" then '' 108 + mkdir -p $python/bin $python/share/{clang,scan-view} 109 + '' else '' 110 + mkdir -p $python/bin $python/share/clang/ 111 + '') + '' 112 + mv $out/bin/{git-clang-format,scan-view} $python/bin 113 + if [ -e $out/bin/set-xcode-analyzer ]; then 114 + mv $out/bin/set-xcode-analyzer $python/bin 115 + fi 116 + mv $out/share/clang/*.py $python/share/clang 117 + '' + (lib.optionalString (lib.versionOlder release_version "15") '' 118 + mv $out/share/scan-view/*.py $python/share/scan-view 119 + '') + '' 120 + rm $out/bin/c-index-test 121 + patchShebangs $python/bin 122 + 123 + mkdir -p $dev/bin 124 + '' + (if lib.versionOlder release_version "15" then '' 125 + cp bin/clang-tblgen $dev/bin 126 + '' else '' 127 + cp bin/{clang-tblgen,clang-tidy-confusable-chars-gen,clang-pseudo-gen} $dev/bin 128 + ''); 129 + 130 + passthru = { 131 + inherit libllvm; 132 + isClang = true; 133 + } // (lib.optionalAttrs (lib.versionAtLeast release_version "15") { 134 + hardeningUnsupportedFlags = [ 135 + "fortify3" 136 + ]; 137 + hardeningUnsupportedFlagsByTargetPlatform = targetPlatform: 138 + lib.optional (!(targetPlatform.isx86_64 || targetPlatform.isAarch64)) "zerocallusedregs" 139 + ++ (finalAttrs.passthru.hardeningUnsupportedFlags or []); 140 + }) // (lib.optionalAttrs (lib.versionOlder release_version "15") { 141 + hardeningUnsupportedFlags = [ "fortify3" "zerocallusedregs" ]; 142 + }); 143 + 144 + meta = llvm_meta // { 145 + homepage = "https://clang.llvm.org/"; 146 + description = "A C language family frontend for LLVM"; 147 + longDescription = '' 148 + The Clang project provides a language front-end and tooling 149 + infrastructure for languages in the C language family (C, C++, Objective 150 + C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project. 151 + It aims to deliver amazingly fast compiles, extremely useful error and 152 + warning messages and to provide a platform for building great source 153 + level tools. The Clang Static Analyzer and clang-tidy are tools that 154 + automatically find bugs in your code, and are great examples of the sort 155 + of tools that can be built using the Clang frontend as a library to 156 + parse C/C++ code. 157 + ''; 158 + mainProgram = "clang"; 159 + }; 160 + } // lib.optionalAttrs enableManpages ({ 161 + pname = "clang-manpages"; 162 + 163 + installPhase = '' 164 + mkdir -p $out/share/man/man1 165 + # Manually install clang manpage 166 + cp docs/man/*.1 $out/share/man/man1/ 167 + ''; 168 + 169 + outputs = [ "out" ]; 170 + 171 + doCheck = false; 172 + 173 + meta = llvm_meta // { 174 + description = "man page for Clang ${version}"; 175 + }; 176 + } // (if lib.versionOlder release_version "15" then { 177 + buildPhase = '' 178 + make docs-clang-man 179 + ''; 180 + } else { 181 + ninjaFlags = [ "docs-clang-man" ]; 182 + })) // (lib.optionalAttrs (clang-tools-extra_src != null) { inherit clang-tools-extra_src; }) 183 + // (lib.optionalAttrs (lib.versionOlder release_version "13") { 184 + unpackPhase = '' 185 + unpackFile $src 186 + mv clang-* clang 187 + sourceRoot=$PWD/clang 188 + unpackFile ${clang-tools-extra_src} 189 + mv clang-tools-extra-* $sourceRoot/tools/extra 190 + substituteInPlace $sourceRoot/tools/extra/clangd/quality/CompletionModel.cmake \ 191 + --replace ' ''${CMAKE_SOURCE_DIR}/../clang-tools-extra' ' ''${CMAKE_SOURCE_DIR}/tools/extra' 192 + ''; 193 + }) 194 + // (lib.optionalAttrs (lib.versionAtLeast release_version "15") { 195 + env = lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { 196 + # The following warning is triggered with (at least) gcc >= 197 + # 12, but appears to occur only for cross compiles. 198 + NIX_CFLAGS_COMPILE = "-Wno-maybe-uninitialized"; 199 + }; 200 + })); 201 + in self
-139
pkgs/development/compilers/llvm/git/clang/default.nix
··· 1 - { lib, stdenv, llvm_meta 2 - , monorepoSrc, runCommand 3 - , substituteAll, cmake, ninja, libxml2, libllvm, version, python3 4 - , buildLlvmTools 5 - , fixDarwinDylibNames 6 - , enableManpages ? false 7 - }: 8 - 9 - let 10 - self = stdenv.mkDerivation (finalAttrs: rec { 11 - pname = "clang"; 12 - inherit version; 13 - 14 - src = runCommand "${pname}-src-${version}" {} '' 15 - mkdir -p "$out" 16 - cp -r ${monorepoSrc}/cmake "$out" 17 - cp -r ${monorepoSrc}/${pname} "$out" 18 - cp -r ${monorepoSrc}/clang-tools-extra "$out" 19 - ''; 20 - 21 - sourceRoot = "${src.name}/${pname}"; 22 - 23 - nativeBuildInputs = [ cmake ninja python3 ] 24 - ++ lib.optional (lib.versionAtLeast version "18" && enableManpages) python3.pkgs.myst-parser 25 - ++ lib.optional enableManpages python3.pkgs.sphinx 26 - ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 27 - 28 - buildInputs = [ libxml2 libllvm ]; 29 - 30 - cmakeFlags = [ 31 - "-DCLANG_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/clang" 32 - "-DCLANGD_BUILD_XPC=OFF" 33 - "-DLLVM_ENABLE_RTTI=ON" 34 - "-DLLVM_INCLUDE_TESTS=OFF" 35 - ] ++ lib.optionals enableManpages [ 36 - "-DCLANG_INCLUDE_DOCS=ON" 37 - "-DLLVM_ENABLE_SPHINX=ON" 38 - "-DSPHINX_OUTPUT_MAN=ON" 39 - "-DSPHINX_OUTPUT_HTML=OFF" 40 - "-DSPHINX_WARNINGS_AS_ERRORS=OFF" 41 - ] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ 42 - "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" 43 - "-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen" 44 - # Added in LLVM15: 45 - # `clang-tidy-confusable-chars-gen`: https://github.com/llvm/llvm-project/commit/c3574ef739fbfcc59d405985a3a4fa6f4619ecdb 46 - # `clang-pseudo-gen`: https://github.com/llvm/llvm-project/commit/cd2292ef824591cc34cc299910a3098545c840c7 47 - "-DCLANG_TIDY_CONFUSABLE_CHARS_GEN=${buildLlvmTools.libclang.dev}/bin/clang-tidy-confusable-chars-gen" 48 - "-DCLANG_PSEUDO_GEN=${buildLlvmTools.libclang.dev}/bin/clang-pseudo-gen" 49 - ]; 50 - 51 - patches = [ 52 - ./purity.patch 53 - # https://reviews.llvm.org/D51899 54 - ./gnu-install-dirs.patch 55 - ../../common/clang/add-nostdlibinc-flag.patch 56 - (substituteAll { 57 - src = ../../common/clang/clang-at-least-16-LLVMgold-path.patch; 58 - libllvmLibdir = "${libllvm.lib}/lib"; 59 - }) 60 - ]; 61 - 62 - postPatch = '' 63 - (cd tools && ln -s ../../clang-tools-extra extra) 64 - '' + lib.optionalString stdenv.hostPlatform.isMusl '' 65 - sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp 66 - ''; 67 - 68 - outputs = [ "out" "lib" "dev" "python" ]; 69 - 70 - postInstall = '' 71 - ln -sv $out/bin/clang $out/bin/cpp 72 - 73 - # Move libclang to 'lib' output 74 - moveToOutput "lib/libclang.*" "$lib" 75 - moveToOutput "lib/libclang-cpp.*" "$lib" 76 - substituteInPlace $dev/lib/cmake/clang/ClangTargets-release.cmake \ 77 - --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ 78 - --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." 79 - 80 - mkdir -p $python/bin $python/share/clang/ 81 - mv $out/bin/{git-clang-format,scan-view} $python/bin 82 - if [ -e $out/bin/set-xcode-analyzer ]; then 83 - mv $out/bin/set-xcode-analyzer $python/bin 84 - fi 85 - mv $out/share/clang/*.py $python/share/clang 86 - rm $out/bin/c-index-test 87 - patchShebangs $python/bin 88 - 89 - mkdir -p $dev/bin 90 - cp bin/{clang-tblgen,clang-tidy-confusable-chars-gen,clang-pseudo-gen} $dev/bin 91 - ''; 92 - 93 - passthru = { 94 - inherit libllvm; 95 - isClang = true; 96 - hardeningUnsupportedFlags = [ 97 - "fortify3" 98 - ]; 99 - hardeningUnsupportedFlagsByTargetPlatform = targetPlatform: 100 - lib.optional (!(targetPlatform.isx86_64 || targetPlatform.isAarch64)) "zerocallusedregs" 101 - ++ (finalAttrs.passthru.hardeningUnsupportedFlags or []); 102 - }; 103 - 104 - meta = llvm_meta // { 105 - homepage = "https://clang.llvm.org/"; 106 - description = "A C language family frontend for LLVM"; 107 - longDescription = '' 108 - The Clang project provides a language front-end and tooling 109 - infrastructure for languages in the C language family (C, C++, Objective 110 - C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project. 111 - It aims to deliver amazingly fast compiles, extremely useful error and 112 - warning messages and to provide a platform for building great source 113 - level tools. The Clang Static Analyzer and clang-tidy are tools that 114 - automatically find bugs in your code, and are great examples of the sort 115 - of tools that can be built using the Clang frontend as a library to 116 - parse C/C++ code. 117 - ''; 118 - mainProgram = "clang"; 119 - }; 120 - } // lib.optionalAttrs enableManpages { 121 - pname = "clang-manpages"; 122 - 123 - ninjaFlags = [ "docs-clang-man" ]; 124 - 125 - installPhase = '' 126 - mkdir -p $out/share/man/man1 127 - # Manually install clang manpage 128 - cp docs/man/*.1 $out/share/man/man1/ 129 - ''; 130 - 131 - outputs = [ "out" ]; 132 - 133 - doCheck = false; 134 - 135 - meta = llvm_meta // { 136 - description = "man page for Clang ${version}"; 137 - }; 138 - }); 139 - in self
+13 -3
pkgs/development/compilers/llvm/git/default.nix
··· 1 1 { lowPrio, newScope, pkgs, lib, stdenv, cmake, ninja 2 2 , preLibcCrossHeaders 3 - , libxml2, python3, fetchFromGitHub, overrideCC, wrapCCWith, wrapBintoolsWith 3 + , libxml2, python3, fetchFromGitHub, substituteAll, overrideCC, wrapCCWith, wrapBintoolsWith 4 4 , buildLlvmTools # tools, but from the previous stage, for cross 5 5 , targetLlvmLibraries # libraries, but from the next stage, for cross 6 6 , targetLlvm ··· 85 85 then tools.bintools 86 86 else bootBintools; 87 87 88 - in { 88 + in rec { 89 89 90 90 libllvm = callPackage ./llvm { 91 91 inherit llvm_meta; ··· 95 95 # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* 96 96 llvm = tools.libllvm; 97 97 98 - libclang = callPackage ./clang { 98 + libclang = callPackage ../common/clang { 99 + patches = [ 100 + ./clang/purity.patch 101 + # https://reviews.llvm.org/D51899 102 + ./clang/gnu-install-dirs.patch 103 + ../common/clang/add-nostdlibinc-flag.patch 104 + (substituteAll { 105 + src = ../common/clang/clang-at-least-16-LLVMgold-path.patch; 106 + libllvmLibdir = "${libllvm.lib}/lib"; 107 + }) 108 + ]; 99 109 inherit llvm_meta; 100 110 }; 101 111