nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 126 lines 4.1 kB view raw
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 7let 8 self = stdenv.mkDerivation ({ 9 pname = "clang"; 10 inherit version; 11 12 src = fetch "cfe" "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"; 13 14 unpackPhase = '' 15 unpackFile $src 16 mv cfe-${version}* clang 17 sourceRoot=$PWD/clang 18 unpackFile ${clang-tools-extra_src} 19 mv clang-tools-extra-* $sourceRoot/tools/extra 20 ''; 21 22 nativeBuildInputs = [ cmake python3 ] 23 ++ lib.optional enableManpages python3.pkgs.sphinx 24 ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 25 26 buildInputs = [ libxml2 libllvm ]; 27 28 cmakeFlags = [ 29 "-DCMAKE_CXX_FLAGS=-std=c++11" 30 "-DLLVM_ENABLE_RTTI=ON" 31 "-DLLVM_CONFIG_PATH=${libllvm.dev}/bin/llvm-config${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native"}" 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 ./gnu-install-dirs.patch 46 (substituteAll { 47 src = ../../clang-6-10-LLVMgold-path.patch; 48 libllvmLibdir = "${libllvm.lib}/lib"; 49 }) 50 ]; 51 52 postPatch = '' 53 sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \ 54 -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \ 55 lib/Driver/ToolChains/*.cpp 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 substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \ 68 --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." 69 70 mkdir -p $python/bin $python/share/clang/ 71 mv $out/bin/{git-clang-format,scan-view} $python/bin 72 if [ -e $out/bin/set-xcode-analyzer ]; then 73 mv $out/bin/set-xcode-analyzer $python/bin 74 fi 75 mv $out/share/clang/*.py $python/share/clang 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" ]; 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 }); 126in self