From 9aa3548931e90d3a853c0cbf7fe45efe7f3b6a5a Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Fri, 19 May 2017 07:26:05 -0500 Subject: [PATCH 1/3] llvm-4/clang-4: Build and install man pages --- .../compilers/llvm/4/clang/default.nix | 22 +++++++++++++++++-- pkgs/development/compilers/llvm/4/llvm.nix | 13 ++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/pkgs/development/compilers/llvm/4/clang/default.nix b/pkgs/development/compilers/llvm/4/clang/default.nix index c93871592830..7e090f5b57ac 100644 --- a/pkgs/development/compilers/llvm/4/clang/default.nix +++ b/pkgs/development/compilers/llvm/4/clang/default.nix @@ -13,10 +13,15 @@ let mv clang-tools-extra-* $sourceRoot/tools/extra ''; - buildInputs = [ cmake libedit libxml2 llvm python ]; + buildInputs = [ cmake libedit libxml2 llvm python python.pkgs.sphinx ]; cmakeFlags = [ "-DCMAKE_CXX_FLAGS=-std=c++11" + "-DCLANG_INCLUDE_DOCS=ON" + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" ] ++ # Maybe with compiler-rt this won't be needed? (stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}") ++ @@ -24,12 +29,19 @@ let patches = [ ./purity.patch ]; + postBuild = '' + cmake --build . --target docs-clang-man + ''; + postPatch = '' sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp + + # Patch for standalone doc building + sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt ''; - outputs = [ "out" "python" ]; + outputs = [ "out" "man" "python" ]; # Clang expects to find LLVMgold in its own prefix # Clang expects to find sanitizer libraries in its own prefix @@ -46,6 +58,12 @@ let mv $out/share/clang/*.py $python/share/clang rm $out/bin/c-index-test + + # Manually install clang manpage + cp docs/man/*.1 $out/share/man/man1/ + + # Move it and other man pages to 'man' output + moveToOutput "share/man" "$man" ''; enableParallelBuilding = true; diff --git a/pkgs/development/compilers/llvm/4/llvm.nix b/pkgs/development/compilers/llvm/4/llvm.nix index 83a14b7fc4dd..29fd3c1f7a39 100644 --- a/pkgs/development/compilers/llvm/4/llvm.nix +++ b/pkgs/development/compilers/llvm/4/llvm.nix @@ -38,9 +38,9 @@ in stdenv.mkDerivation rec { mv compiler-rt-* $sourceRoot/projects/compiler-rt ''; - outputs = [ "out" ] ++ stdenv.lib.optional enableSharedLibraries "lib"; + outputs = [ "out" "man" ] ++ stdenv.lib.optional enableSharedLibraries "lib"; - buildInputs = [ perl groff cmake libxml2 python libffi ] + buildInputs = [ perl groff cmake libxml2 python libffi python.pkgs.sphinx ] ++ stdenv.lib.optionals stdenv.isDarwin [ libcxxabi ]; propagatedBuildInputs = [ ncurses zlib ]; @@ -80,6 +80,11 @@ in stdenv.mkDerivation rec { "-DLLVM_ENABLE_FFI=ON" "-DLLVM_ENABLE_RTTI=ON" "-DCOMPILER_RT_INCLUDE_TESTS=OFF" # FIXME: requires clang source code + "-DLLVM_BUILD_DOCS=ON" + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" ] ++ stdenv.lib.optional enableSharedLibraries [ "-DLLVM_LINK_LLVM_DYLIB=ON" ] ++ stdenv.lib.optional (!isDarwin) @@ -103,7 +108,9 @@ in stdenv.mkDerivation rec { export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib ''; - postInstall = "" + postInstall = '' + moveToOutput "share/man" "$man" + '' + stdenv.lib.optionalString (enableSharedLibraries) '' moveToOutput "lib/libLLVM-*" "$lib" moveToOutput "lib/libLLVM.${shlib}" "$lib" From 3d1c1c5af3e1d97c2c6d0baf877817d09bb0c444 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Fri, 19 May 2017 12:34:39 -0500 Subject: [PATCH 2/3] llvm-4/*: indicate which build inputs are nativeBuildInputs. --- pkgs/development/compilers/llvm/4/clang/default.nix | 3 ++- pkgs/development/compilers/llvm/4/libc++abi.nix | 3 ++- pkgs/development/compilers/llvm/4/lld.nix | 3 ++- pkgs/development/compilers/llvm/4/lldb.nix | 3 ++- pkgs/development/compilers/llvm/4/llvm.nix | 3 ++- pkgs/development/compilers/llvm/4/openmp.nix | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pkgs/development/compilers/llvm/4/clang/default.nix b/pkgs/development/compilers/llvm/4/clang/default.nix index 7e090f5b57ac..4fa180a2701f 100644 --- a/pkgs/development/compilers/llvm/4/clang/default.nix +++ b/pkgs/development/compilers/llvm/4/clang/default.nix @@ -13,7 +13,8 @@ let mv clang-tools-extra-* $sourceRoot/tools/extra ''; - buildInputs = [ cmake libedit libxml2 llvm python python.pkgs.sphinx ]; + nativeBuildInputs = [ cmake python python.pkgs.sphinx ]; + buildInputs = [ libedit libxml2 llvm ]; cmakeFlags = [ "-DCMAKE_CXX_FLAGS=-std=c++11" diff --git a/pkgs/development/compilers/llvm/4/libc++abi.nix b/pkgs/development/compilers/llvm/4/libc++abi.nix index 559b6b26bc52..3a0e996fb9a0 100644 --- a/pkgs/development/compilers/llvm/4/libc++abi.nix +++ b/pkgs/development/compilers/llvm/4/libc++abi.nix @@ -5,7 +5,8 @@ stdenv.mkDerivation { src = fetch "libcxxabi" "1n416kv27anabg9jsw6331r28ic30xk46p381lx2vbb2jrhwpafw"; - buildInputs = [ cmake ] ++ stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind; + nativeBuildInputs = [ cmake ]; + buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind; postUnpack = '' unpackFile ${libcxx.src} diff --git a/pkgs/development/compilers/llvm/4/lld.nix b/pkgs/development/compilers/llvm/4/lld.nix index 549fa863c151..f9cd72b4200c 100644 --- a/pkgs/development/compilers/llvm/4/lld.nix +++ b/pkgs/development/compilers/llvm/4/lld.nix @@ -12,7 +12,8 @@ stdenv.mkDerivation { src = fetch "lld" "00km1qawk146pyjqa6aphcdzgkzrmg6cgk0ikg4661ffp5bn9q1k"; - buildInputs = [ cmake llvm ]; + nativeBuildInputs = [ cmake ]; + buildInputs = [ llvm ]; outputs = [ "out" "dev" ]; diff --git a/pkgs/development/compilers/llvm/4/lldb.nix b/pkgs/development/compilers/llvm/4/lldb.nix index 6e6fdf012dd6..a0f0a606ad97 100644 --- a/pkgs/development/compilers/llvm/4/lldb.nix +++ b/pkgs/development/compilers/llvm/4/lldb.nix @@ -29,7 +29,8 @@ stdenv.mkDerivation { cmake/modules/LLDBStandalone.cmake ''; - buildInputs = [ cmake python which swig ncurses zlib libedit libxml2 llvm ] + nativeBuildInputs = [ cmake python which swig ]; + buildInputs = [ ncurses zlib libedit libxml2 llvm ] ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc ]; CXXFLAGS = "-fno-rtti"; diff --git a/pkgs/development/compilers/llvm/4/llvm.nix b/pkgs/development/compilers/llvm/4/llvm.nix index 29fd3c1f7a39..1a78d672bfef 100644 --- a/pkgs/development/compilers/llvm/4/llvm.nix +++ b/pkgs/development/compilers/llvm/4/llvm.nix @@ -40,7 +40,8 @@ in stdenv.mkDerivation rec { outputs = [ "out" "man" ] ++ stdenv.lib.optional enableSharedLibraries "lib"; - buildInputs = [ perl groff cmake libxml2 python libffi python.pkgs.sphinx ] + nativeBuildInputs = [ perl groff cmake python python.pkgs.sphinx ]; + buildInputs = [ libxml2 libffi ] ++ stdenv.lib.optionals stdenv.isDarwin [ libcxxabi ]; propagatedBuildInputs = [ ncurses zlib ]; diff --git a/pkgs/development/compilers/llvm/4/openmp.nix b/pkgs/development/compilers/llvm/4/openmp.nix index c8ba770e2411..197e9a784653 100644 --- a/pkgs/development/compilers/llvm/4/openmp.nix +++ b/pkgs/development/compilers/llvm/4/openmp.nix @@ -12,7 +12,8 @@ stdenv.mkDerivation { src = fetch "openmp" "09kf41zgv551fnv628kqhlwgqkd2bkiwii9gqi6q12djgdddhmfv"; - buildInputs = [ cmake llvm perl ]; + nativeBuildInputs = [ cmake perl ]; + buildInputs = [ llvm ]; enableParallelBuilding = true; From 1e23b49f4652915a274781569abb21a07884e858 Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Sun, 21 May 2017 12:40:07 +0200 Subject: [PATCH 3/3] darwin-stdenv: allow clang-unwrapped.man --- pkgs/stdenv/darwin/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index 8a517fddad8a..d733749e5f2a 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -306,7 +306,7 @@ in rec { xz.out xz.bin libcxx libcxxabi icu.out gmp.out gnumake findutils bzip2.out bzip2.bin llvmPackages.llvm llvmPackages.llvm.lib zlib.out zlib.dev libffi.out coreutils ed diffutils gnutar gzip ncurses.out ncurses.dev ncurses.man gnused bash gawk - gnugrep llvmPackages.clang-unwrapped patch pcre.out binutils-raw.out + gnugrep llvmPackages.clang-unwrapped llvmPackages.clang-unwrapped.man patch pcre.out binutils-raw.out binutils-raw.dev binutils gettext ]) ++ (with pkgs.darwin; [ dyld Libsystem CF cctools libiconv locale