nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 137 lines 4.4 kB view raw
1{ lib, stdenv, llvm_meta, fetch, fetchpatch, substituteAll, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3 2, buildLlvmTools 3, fixDarwinDylibNames 4, enableManpages ? false 5, enablePolly ? false 6}: 7 8let 9 self = stdenv.mkDerivation ({ 10 pname = "clang"; 11 inherit version; 12 13 src = fetch "clang" "12sm91qx2m79cvj75a9aazf2x8xybjbd593dv6v7rxficpq8i0ha"; 14 inherit clang-tools-extra_src; 15 16 unpackPhase = '' 17 unpackFile $src 18 mv clang-* clang 19 sourceRoot=$PWD/clang 20 unpackFile ${clang-tools-extra_src} 21 mv clang-tools-extra-* $sourceRoot/tools/extra 22 ''; 23 24 nativeBuildInputs = [ cmake python3 ] 25 ++ lib.optional enableManpages python3.pkgs.sphinx 26 ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 27 28 buildInputs = [ libxml2 libllvm ]; 29 30 cmakeFlags = [ 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.hostPlatform != stdenv.buildPlatform) [ 40 "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" 41 "-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen" 42 ] ++ lib.optionals enablePolly [ 43 "-DWITH_POLLY=ON" 44 "-DLINK_POLLY_INTO_TOOLS=ON" 45 ]; 46 47 48 patches = [ 49 ./purity.patch 50 # https://reviews.llvm.org/D51899 51 ./gnu-install-dirs.patch 52 (substituteAll { 53 src = ../../clang-11-12-LLVMgold-path.patch; 54 libllvmLibdir = "${libllvm.lib}/lib"; 55 }) 56 ]; 57 58 postPatch = '' 59 sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \ 60 -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \ 61 lib/Driver/ToolChains/*.cpp 62 '' + lib.optionalString stdenv.hostPlatform.isMusl '' 63 sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp 64 '' + lib.optionalString stdenv.hostPlatform.isDarwin '' 65 substituteInPlace tools/extra/clangd/CMakeLists.txt \ 66 --replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE 67 ''; 68 69 outputs = [ "out" "lib" "dev" "python" ]; 70 71 postInstall = '' 72 ln -sv $out/bin/clang $out/bin/cpp 73 74 # Move libclang to 'lib' output 75 moveToOutput "lib/libclang.*" "$lib" 76 moveToOutput "lib/libclang-cpp.*" "$lib" 77 substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \ 78 --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \ 79 --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp." 80 81 mkdir -p $python/bin $python/share/clang/ 82 mv $out/bin/{git-clang-format,scan-view} $python/bin 83 if [ -e $out/bin/set-xcode-analyzer ]; then 84 mv $out/bin/set-xcode-analyzer $python/bin 85 fi 86 mv $out/share/clang/*.py $python/share/clang 87 rm $out/bin/c-index-test 88 patchShebangs $python/bin 89 90 mkdir -p $dev/bin 91 cp bin/clang-tblgen $dev/bin 92 ''; 93 94 passthru = { 95 inherit libllvm; 96 isClang = true; 97 hardeningUnsupportedFlags = [ "fortify3" ]; 98 }; 99 100 meta = llvm_meta // { 101 homepage = "https://clang.llvm.org/"; 102 description = "A C language family frontend for LLVM"; 103 longDescription = '' 104 The Clang project provides a language front-end and tooling 105 infrastructure for languages in the C language family (C, C++, Objective 106 C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project. 107 It aims to deliver amazingly fast compiles, extremely useful error and 108 warning messages and to provide a platform for building great source 109 level tools. The Clang Static Analyzer and clang-tidy are tools that 110 automatically find bugs in your code, and are great examples of the sort 111 of tools that can be built using the Clang frontend as a library to 112 parse C/C++ code. 113 ''; 114 mainProgram = "clang"; 115 }; 116 } // lib.optionalAttrs enableManpages { 117 pname = "clang-manpages"; 118 119 buildPhase = '' 120 make docs-clang-man 121 ''; 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 }); 137in self