Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llvmPackages: Clean up outputs #111487

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkgs/applications/blockchains/electrs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ rustPlatform.buildRustPackage rec {

# needed for librocksdb-sys
nativeBuildInputs = [ llvmPackages.clang ];
LIBCLANG_PATH = "${llvmPackages.libclang}/lib";
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";

cargoSha256 = "1rqpadlr9r4z2z825li6vi5a21hivc3bsn5ibxshrdrwiycyyxz8";

Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/blockchains/openethereum/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ rustPlatform.buildRustPackage rec {

cargoSha256 = "1gm02pcfll362add8a0dcb0sk0mag8z0q23b87yb6fs870bqvhib";

LIBCLANG_PATH = "${llvmPackages.libclang}/lib";
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
nativeBuildInputs = [
cmake
llvmPackages.clang
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/blockchains/polkadot/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ rustPlatform.buildRustPackage rec {

nativeBuildInputs = [ clang ];

LIBCLANG_PATH = "${llvmPackages.libclang}/lib";
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
PROTOC = "${protobuf}/bin/protoc";

# NOTE: We don't build the WASM runtimes since this would require a more
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/editors/jucipp/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ stdenv.mkDerivation rec {
e = "\");";
v = lib.getVersion llvmPackages.clang;
in
p+llvmPackages.libcxx+"/include/c++/v1"+e
+p+llvmPackages.clang-unwrapped+"/lib/clang/"+v+"/include/"+e
p+llvmPackages.libcxx.dev+"/include/c++/v1"+e
+p+llvmPackages.clang-unwrapped.lib+"/lib/clang/"+v+"/include/"+e
+p+glibc.dev+"/include"+e;

preConfigure = ''
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/editors/kdevelop5/kdevelop.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mkDerivation rec {

buildInputs = [
kdevelop-pg-qt
llvmPackages.llvm llvmPackages.clang-unwrapped
llvmPackages.llvm llvmPackages.libclang
];

propagatedBuildInputs = [
Expand All @@ -37,7 +37,7 @@ mkDerivation rec {
# https://cgit.kde.org/kdevelop.git/commit/?id=716372ae2e8dff9c51e94d33443536786e4bd85b
# required as nixos seems to be unable to find CLANG_BUILTIN_DIR
cmakeFlags = [
"-DCLANG_BUILTIN_DIR=${llvmPackages.clang-unwrapped}/lib/clang/${lib.getVersion llvmPackages.clang}/include"
"-DCLANG_BUILTIN_DIR=${llvmPackages.libclang.lib}/lib/clang/${lib.getVersion llvmPackages.clang}/include"
];

dontWrapQtApps = true;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/editors/rstudio/clang-location.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ index ec12a3a1ff..8c81b633ae 100644
// we need to add in the associated libclang headers as
// they are not discovered / used by default during compilation
- FilePath llvmPath = s_libraryPath.parent().parent();
+ FilePath llvmPath("@clang@");
+ FilePath llvmPath("@libclang@");
boost::format fmt("%1%/lib/clang/%2%/include");
fmt % llvmPath.absolutePath() % version.asString();
std::string includePath = fmt.str();
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/editors/rstudio/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ mkDerivation rec {
postPatch = ''
substituteInPlace src/cpp/core/r_util/REnvironmentPosix.cpp --replace '@R@' ${R}
substituteInPlace src/cpp/core/libclang/LibClang.cpp \
--replace '@clang@' ${llvmPackages.clang.cc} \
--replace '@libclang.so@' ${llvmPackages.clang.cc.lib}/lib/libclang.so
--replace '@libclang@' ${llvmPackages.libclang.lib} \
--replace '@libclang.so@' ${llvmPackages.libclang.lib}/lib/libclang.so
'';

ginSrc = fetchurl {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/misc/clipcat/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rustPlatform.buildRustPackage rec {

cargoSha256 = "1ffgvhkdj8wkhlgi0cj0njdm9ycxq2qda4b5qn8bmaygzr2zkwpd";

LIBCLANG_PATH = "${llvmPackages.libclang}/lib";
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";

# needed for internal protobuf c wrapper library
PROTOC = "${protobuf}/bin/protoc";
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/misc/imag/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ rustPlatform.buildRustPackage rec {
++ lib.optional stdenv.isDarwin Security;
checkInputs = [ gitMinimal util-linuxMinimal ];

LIBCLANG_PATH = "${llvmPackages.libclang}/lib";
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";

cargoSha256 = "0n8cw70qh8g4hfwfaxwwxbrrx5hm2z037z8kdhvdpqkxljl9189x";

Expand Down
6 changes: 3 additions & 3 deletions pkgs/applications/networking/browsers/firefox/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ buildStdenv.mkDerivation ({
$(< ${buildStdenv.cc}/nix-support/libc-cflags) \
$(< ${buildStdenv.cc}/nix-support/cc-cflags) \
$(< ${buildStdenv.cc}/nix-support/libcxx-cxxflags) \
${lib.optionalString buildStdenv.cc.isClang "-idirafter ${buildStdenv.cc.cc}/lib/clang/${lib.getVersion buildStdenv.cc.cc}/include"} \
${lib.optionalString buildStdenv.cc.isGNU "-isystem ${buildStdenv.cc.cc}/include/c++/${lib.getVersion buildStdenv.cc.cc} -isystem ${buildStdenv.cc.cc}/include/c++/${lib.getVersion buildStdenv.cc.cc}/${buildStdenv.hostPlatform.config}"} \
${lib.optionalString buildStdenv.cc.isClang "-idirafter ${buildStdenv.cc.cc.lib}/lib/clang/${lib.getVersion buildStdenv.cc.cc}/include"} \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the getLib here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since cc is defined as libllvm.out, the output is "predetermined" and stuff like lib.getLib won't work. it's a bummer but the only solution I can think of is to do "out" and "bin" instead of "out" and "lib" (i.e change the default output).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I wonder if this behavior of lib.get* is actually necessary, but it is probably not a thing we should include here if it is at all possible since it would need additional testing.

${lib.optionalString buildStdenv.cc.isGNU "-isystem ${lib.getDev buildStdenv.cc.cc}/include/c++/${lib.getVersion buildStdenv.cc.cc} -isystem ${buildStdenv.cc.cc}/include/c++/${lib.getVersion buildStdenv.cc.cc}/${buildStdenv.hostPlatform.config}"} \
$NIX_CFLAGS_COMPILE"

echo "ac_add_options BINDGEN_CFLAGS='$BINDGEN_CFLAGS'" >> $MOZCONFIG
Expand Down Expand Up @@ -282,7 +282,7 @@ buildStdenv.mkDerivation ({
"--disable-updater"
"--enable-jemalloc"
"--enable-default-toolkit=${default-toolkit}"
"--with-libclang-path=${llvmPackages.libclang}/lib"
"--with-libclang-path=${llvmPackages.libclang.lib}/lib"
"--with-system-nspr"
"--with-system-nss"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ stdenv.mkDerivation rec {
"--enable-strip"
]) ++ lib.optionals (!stdenv.hostPlatform.isi686) [
# on i686-linux: --with-libclang-path is not available in this configuration
"--with-libclang-path=${llvmPackages.libclang}/lib"
"--with-libclang-path=${llvmPackages.libclang.lib}/lib"
"--with-clang-path=${llvmPackages.clang}/bin/clang"
] ++ lib.optional alsaSupport "--enable-alsa"
++ lib.optional calendarSupport "--enable-calendar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ stdenv.mkDerivation rec {
"--enable-strip"
]) ++ lib.optionals (!stdenv.hostPlatform.isi686) [
# on i686-linux: --with-libclang-path is not available in this configuration
"--with-libclang-path=${llvmPackages.libclang}/lib"
"--with-libclang-path=${llvmPackages.libclang.lib}/lib"
"--with-clang-path=${llvmPackages.clang}/bin/clang"
] ++ lib.optional alsaSupport "--enable-alsa"
++ lib.optional calendarSupport "--enable-calendar"
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/science/math/R/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ stdenv.mkDerivation rec {
'' + lib.optionalString stdenv.isDarwin ''
--disable-R-framework
OBJC="clang"
CPPFLAGS="-isystem ${libcxx}/include/c++/v1"
LDFLAGS="-L${libcxx}/lib"
CPPFLAGS="-isystem ${lib.getDev libcxx}/include/c++/v1"
LDFLAGS="-L${lib.getLib libcxx}/lib"
'' + ''
)
echo >>etc/Renviron.in "TCLLIBPATH=${tk}/lib"
Expand Down
4 changes: 2 additions & 2 deletions pkgs/build-support/cc-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ stdenv.mkDerivation {
done
''
+ optionalString (libcxx.isLLVM or false) (''
echo "-isystem ${libcxx}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags
echo "-isystem ${lib.getDev libcxx}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags
echo "-stdlib=libc++" >> $out/nix-support/libcxx-ldflags
'' + lib.optionalString stdenv.targetPlatform.isLinux ''
echo "-lc++abi" >> $out/nix-support/libcxx-ldflags
Expand Down Expand Up @@ -404,7 +404,7 @@ stdenv.mkDerivation {
echo "$ccLDFlags" >> $out/nix-support/cc-ldflags
echo "$ccCFlags" >> $out/nix-support/cc-cflags
'' + optionalString (targetPlatform.isDarwin && (libcxx != null) && (cc.isClang or false)) ''
echo " -L${libcxx}/lib" >> $out/nix-support/cc-ldflags
echo " -L${lib.getLib libcxx}/lib" >> $out/nix-support/cc-ldflags
''

##
Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/rust/default-crate-overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ in
nettle-sys = attrs: {
nativeBuildInputs = [ pkg-config ];
buildInputs = [ nettle clang ];
LIBCLANG_PATH = "${llvmPackages.libclang}/lib";
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
};

openssl = attrs: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let
inherit spirv-llvm-translator;
};
inherit (llvmPkgs) llvm;
inherit (if buildWithPatches then opencl-clang else llvmPkgs) clang clang-unwrapped spirv-llvm-translator;
inherit (if buildWithPatches then opencl-clang else llvmPkgs) clang libclang spirv-llvm-translator;
inherit (lib) getVersion optional optionals versionOlder versions;
in

Expand Down Expand Up @@ -55,7 +55,7 @@ stdenv.mkDerivation rec {
ln -s ${clang}/bin/clang $out/
ln -s clang $out/clang-${versions.major (getVersion clang)}
ln -s ${opencl-clang}/lib/* $out/
ln -s ${clang-unwrapped}/lib/clang/${getVersion clang}/include/opencl-c.h $out/
ln -s ${lib.getLib libclang}/lib/clang/${getVersion clang}/include/opencl-c.h $out/
'';
};

Expand Down
23 changes: 16 additions & 7 deletions pkgs/development/compilers/llvm/10/clang/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ lib, stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
{ lib, stdenv, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3
, buildLlvmTools
, fixDarwinDylibNames
, enableManpages ? false
}:
Expand All @@ -18,28 +19,33 @@ let
mv clang-tools-extra-* $sourceRoot/tools/extra
'';

nativeBuildInputs = [ cmake python3 lld ]
nativeBuildInputs = [ cmake python3 ]
++ lib.optional enableManpages python3.pkgs.sphinx
++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;

buildInputs = [ libxml2 llvm ];
buildInputs = [ libxml2 libllvm ];

cmakeFlags = [
"-DCMAKE_CXX_FLAGS=-std=c++14"
"-DCLANGD_BUILD_XPC=OFF"
"-DLLVM_ENABLE_RTTI=ON"
"-DLLVM_CONFIG_PATH=${libllvm.dev}/bin/llvm-config${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native"}"
] ++ lib.optionals enableManpages [
"-DCLANG_INCLUDE_DOCS=ON"
"-DLLVM_ENABLE_SPHINX=ON"
"-DSPHINX_OUTPUT_MAN=ON"
"-DSPHINX_OUTPUT_HTML=OFF"
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
"-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen"
];

patches = [
./purity.patch
# https://reviews.llvm.org/D51899
./compiler-rt-baremetal.patch
./gnu-install-dirs.patch
];

postPatch = ''
Expand All @@ -56,12 +62,12 @@ let
--replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE
'';

outputs = [ "out" "lib" "python" ];
outputs = [ "out" "lib" "dev" "python" ];

# Clang expects to find LLVMgold in its own prefix
postInstall = ''
if [ -e ${llvm}/lib/LLVMgold.so ]; then
ln -sv ${llvm}/lib/LLVMgold.so $out/lib
if [ -e ${libllvm.lib}/lib/LLVMgold.so ]; then
ln -sv ${libllvm.lib}/lib/LLVMgold.so $lib/lib
fi

ln -sv $out/bin/clang $out/bin/cpp
Expand All @@ -80,11 +86,14 @@ let
fi
mv $out/share/clang/*.py $python/share/clang
rm $out/bin/c-index-test

mkdir -p $dev/bin
cp bin/clang-tblgen $dev/bin
'';

passthru = {
isClang = true;
inherit llvm;
inherit libllvm;
};

meta = {
Expand Down
Loading