Skip to content
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
62 changes: 29 additions & 33 deletions pkgs/development/interpreters/cling/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
, git
, lib
, libffi
, llvmPackages_9
, llvmPackages_13
, makeWrapper
, ncurses
, python3
Expand Down Expand Up @@ -34,46 +34,40 @@
let
stdenv = clangStdenv;

# The LLVM 9 headers have a couple bugs we need to patch
fixedLlvmDev = runCommand "llvm-dev-${llvmPackages_9.llvm.version}" { buildInputs = [git]; } ''
mkdir $out
cp -r ${llvmPackages_9.llvm.dev}/include $out
cd $out
chmod -R u+w include
git apply ${./fix-llvm-include.patch}
'';
# The patched clang lives in the LLVM megarepo
clangSrc = fetchFromGitHub {
owner = "root-project";
repo = "llvm-project";
# cling-llvm13 branch
rev = "3610201fbe0352a63efb5cb45f4ea4987702c735";
sha256 = "sha256-Cb7BvV7yobG+mkaYe7zD2KcnPvm8/vmVATNWssklXyk=";
sparseCheckout = ["clang"];
};

unwrapped = stdenv.mkDerivation rec {
pname = "cling-unwrapped";
version = "0.9";
version = "1.0";

src = fetchgit {
url = "http://root.cern/git/clang.git";
rev = "cling-v0.9";
sha256 = "sha256-ft1NUIclSiZ9lN3Z3DJCWA0U9q/K1M0TKkZr+PjsFYk=";
};
src = "${clangSrc}/clang";

clingSrc = fetchFromGitHub {
owner = "root-project";
repo = "cling";
rev = "v0.9";
sha256 = "0wx3fi19wfjcph5kclf8108i436y79ddwakrcf0lgxnnxhdjyd29";
rev = "v1.0";
sha256 = "sha256-Ye8EINzt+dyNvUIRydACXzb/xEPLm0YSkz08Xxw3xp4=";
};

prePatch = ''
echo "add_llvm_external_project(cling)" >> tools/CMakeLists.txt

cp -r $clingSrc ./tools/cling
chmod -R a+w ./tools/cling
cp -r $clingSrc tools/cling
chmod -R a+w tools/cling
'';

patches = [
./no-clang-cpp.patch

# https://github.com/root-project/root/commit/286d96b12aad8688b9d8e4b3b5df843dcfb716a8
./fix-llvm-dylib-usage.patch

./force-install-cling-targets.patch
# ./force-install-cling-targets.patch
];

nativeBuildInputs = [ python3 git cmake ];
Expand All @@ -82,12 +76,12 @@ let
strictDeps = true;

cmakeFlags = [
"-DLLVM_BINARY_DIR=${llvmPackages_9.llvm.out}"
"-DLLVM_CONFIG=${llvmPackages_9.llvm.dev}/bin/llvm-config"
"-DLLVM_LIBRARY_DIR=${llvmPackages_9.llvm.lib}/lib"
"-DLLVM_MAIN_INCLUDE_DIR=${fixedLlvmDev}/include"
"-DLLVM_TABLEGEN_EXE=${llvmPackages_9.llvm.out}/bin/llvm-tblgen"
"-DLLVM_TOOLS_BINARY_DIR=${llvmPackages_9.llvm.out}/bin"
"-DLLVM_BINARY_DIR=${llvmPackages_13.llvm.out}"
"-DLLVM_CONFIG=${llvmPackages_13.llvm.dev}/bin/llvm-config"
"-DLLVM_LIBRARY_DIR=${llvmPackages_13.llvm.lib}/lib"
"-DLLVM_MAIN_INCLUDE_DIR=${llvmPackages_13.llvm.dev}/include"
"-DLLVM_TABLEGEN_EXE=${llvmPackages_13.llvm.out}/bin/llvm-tblgen"
"-DLLVM_TOOLS_BINARY_DIR=${llvmPackages_13.llvm.out}/bin"
"-DLLVM_BUILD_TOOLS=Off"
"-DLLVM_TOOL_CLING_BUILD=ON"

Expand Down Expand Up @@ -126,9 +120,9 @@ let

# Runtime flags for the C++ standard library
cxxFlags = if useLLVMLibcxx then [
"-I" "${lib.getDev llvmPackages_9.libcxx}/include/c++/v1"
"-L" "${llvmPackages_9.libcxx}/lib"
"-l" "${llvmPackages_9.libcxx}/lib/libc++.so"
"-I" "${lib.getDev llvmPackages_13.libcxx}/include/c++/v1"
"-L" "${llvmPackages_13.libcxx}/lib"
"-l" "${llvmPackages_13.libcxx}/lib/libc++.so"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"-l" "${llvmPackages_13.libcxx}/lib/libc++.so"
"-l" "${llvmPackages_13.libcxx}/lib/libc++${stdenv.hostPlatform.extensions.sharedLibrary}"

] else [
"-I" "${gcc-unwrapped}/include/c++/${gcc-unwrapped.version}"
"-I" "${gcc-unwrapped}/include/c++/${gcc-unwrapped.version}/x86_64-unknown-linux-gnu"
Expand All @@ -149,7 +143,9 @@ let
"-nostdinc"
"-nostdinc++"

"-isystem" "${lib.getLib unwrapped}/lib/clang/9.0.1/include"
"-resource-dir" "${llvmPackages_13.llvm.lib}/lib"

"-isystem" "${lib.getLib unwrapped}/lib/clang/${llvmPackages_13.clang.version}/include"
]
++ cxxFlags
++ [
Expand Down
24 changes: 0 additions & 24 deletions pkgs/development/interpreters/cling/fix-llvm-dylib-usage.patch

This file was deleted.

27 changes: 0 additions & 27 deletions pkgs/development/interpreters/cling/fix-llvm-include.patch

This file was deleted.