nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 125 lines 4.1 kB view raw
1{ lib, stdenv, llvm_meta, src, substituteAll, cmake, libxml2, libllvm, version, python3 2, buildLlvmTools 3, fixDarwinDylibNames 4, enableManpages ? false 5}: 6 7let 8 self = stdenv.mkDerivation ({ 9 pname = "clang"; 10 inherit version; 11 12 inherit src; 13 sourceRoot = "source/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 = ../../clang-11-12-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/ 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 rm $out/bin/c-index-test 76 patchShebangs $python/bin 77 78 mkdir -p $dev/bin 79 cp bin/clang-tblgen $dev/bin 80 ''; 81 82 passthru = { 83 inherit libllvm; 84 isClang = true; 85 hardeningUnsupportedFlags = [ "fortify3" ]; 86 }; 87 88 meta = llvm_meta // { 89 homepage = "https://clang.llvm.org/"; 90 description = "A C language family frontend for LLVM"; 91 longDescription = '' 92 The Clang project provides a language front-end and tooling 93 infrastructure for languages in the C language family (C, C++, Objective 94 C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project. 95 It aims to deliver amazingly fast compiles, extremely useful error and 96 warning messages and to provide a platform for building great source 97 level tools. The Clang Static Analyzer and clang-tidy are tools that 98 automatically find bugs in your code, and are great examples of the sort 99 of tools that can be built using the Clang frontend as a library to 100 parse C/C++ code. 101 ''; 102 mainProgram = "clang"; 103 }; 104 } // lib.optionalAttrs enableManpages { 105 pname = "clang-manpages"; 106 107 buildPhase = '' 108 make docs-clang-man 109 ''; 110 111 installPhase = '' 112 mkdir -p $out/share/man/man1 113 # Manually install clang manpage 114 cp docs/man/*.1 $out/share/man/man1/ 115 ''; 116 117 outputs = [ "out" ]; 118 119 doCheck = false; 120 121 meta = llvm_meta // { 122 description = "man page for Clang ${version}"; 123 }; 124 }); 125in self