mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-11-10 01:33:11 +01:00
cling: 1.0 -> 1.2
This commit is contained in:
parent
1c3ece86ab
commit
22c7d6a3d7
54
pkgs/by-name/cl/cling/fix-new-parser.patch
Normal file
54
pkgs/by-name/cl/cling/fix-new-parser.patch
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
From cd4d1d8c4963620a6a84834948845df81fbbd70b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jonas Hahnfeld <jonas.hahnfeld@cern.ch>
|
||||||
|
Date: Tue, 17 Dec 2024 14:54:18 +0100
|
||||||
|
Subject: [PATCH] Use single Parser for LookupHelper
|
||||||
|
|
||||||
|
It is the only construction of a temporary parser, and it seems not
|
||||||
|
necessary (anymore).
|
||||||
|
---
|
||||||
|
include/cling/Interpreter/LookupHelper.h | 2 +-
|
||||||
|
lib/Interpreter/Interpreter.cpp | 11 ++++-------
|
||||||
|
2 files changed, 5 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/include/cling/Interpreter/LookupHelper.h b/include/cling/Interpreter/LookupHelper.h
|
||||||
|
index 6e6e281470..cd79b2a65c 100644
|
||||||
|
--- a/include/cling/Interpreter/LookupHelper.h
|
||||||
|
+++ b/include/cling/Interpreter/LookupHelper.h
|
||||||
|
@@ -56,7 +56,7 @@ namespace cling {
|
||||||
|
WithDiagnostics
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
- std::unique_ptr<clang::Parser> m_Parser;
|
||||||
|
+ clang::Parser* m_Parser;
|
||||||
|
Interpreter* m_Interpreter; // we do not own.
|
||||||
|
std::array<const clang::Type*, kNumCachedStrings> m_StringTy = {{}};
|
||||||
|
/// A map containing the hash of the lookup buffer. This allows us to avoid
|
||||||
|
diff --git a/lib/Interpreter/Interpreter.cpp b/lib/Interpreter/Interpreter.cpp
|
||||||
|
index 13c8409cc5..f04695439b 100644
|
||||||
|
--- a/lib/Interpreter/Interpreter.cpp
|
||||||
|
+++ b/lib/Interpreter/Interpreter.cpp
|
||||||
|
@@ -265,13 +265,6 @@ namespace cling {
|
||||||
|
}
|
||||||
|
|
||||||
|
Sema& SemaRef = getSema();
|
||||||
|
- Preprocessor& PP = SemaRef.getPreprocessor();
|
||||||
|
-
|
||||||
|
- m_LookupHelper.reset(new LookupHelper(new Parser(PP, SemaRef,
|
||||||
|
- /*SkipFunctionBodies*/false,
|
||||||
|
- /*isTemp*/true), this));
|
||||||
|
- if (!m_LookupHelper)
|
||||||
|
- return;
|
||||||
|
|
||||||
|
if (!isInSyntaxOnlyMode() && !m_Opts.CompilerOpts.CUDADevice) {
|
||||||
|
m_Executor.reset(new IncrementalExecutor(SemaRef.Diags, *getCI(),
|
||||||
|
@@ -317,6 +310,10 @@ namespace cling {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ m_LookupHelper.reset(new LookupHelper(m_IncrParser->getParser(), this));
|
||||||
|
+ if (!m_LookupHelper)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
// When not using C++ modules, we now have a PCH and we can safely setup
|
||||||
|
// our callbacks without fearing that they get overwritten by clang code.
|
||||||
|
// The modules setup is handled above.
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt
|
|
||||||
index 590d708d83..340ae529d4 100644
|
|
||||||
--- a/tools/driver/CMakeLists.txt
|
|
||||||
+++ b/tools/driver/CMakeLists.txt
|
|
||||||
@@ -63,7 +63,7 @@ endif()
|
|
||||||
add_dependencies(clang clang-resource-headers)
|
|
||||||
|
|
||||||
if(NOT CLANG_LINKS_TO_CREATE)
|
|
||||||
- set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp)
|
|
||||||
+ set(CLANG_LINKS_TO_CREATE clang++ clang-cl)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
foreach(link ${CLANG_LINKS_TO_CREATE})
|
|
||||||
|
|
@ -5,13 +5,13 @@
|
||||||
git,
|
git,
|
||||||
lib,
|
lib,
|
||||||
libffi,
|
libffi,
|
||||||
llvmPackages_13,
|
llvmPackages_18,
|
||||||
makeWrapper,
|
makeWrapper,
|
||||||
ncurses,
|
ncurses,
|
||||||
python3,
|
python3,
|
||||||
zlib,
|
zlib,
|
||||||
|
|
||||||
# *NOT* from LLVM 13!
|
# *NOT* from LLVM 18!
|
||||||
# The compiler used to compile Cling may affect the runtime include and lib
|
# The compiler used to compile Cling may affect the runtime include and lib
|
||||||
# directories it expects to be run with. Cling builds against (a fork of) Clang,
|
# directories it expects to be run with. Cling builds against (a fork of) Clang,
|
||||||
# so we prefer to use Clang as the compiler as well for consistency.
|
# so we prefer to use Clang as the compiler as well for consistency.
|
||||||
|
|
@ -34,42 +34,39 @@
|
||||||
let
|
let
|
||||||
stdenv = clangStdenv;
|
stdenv = clangStdenv;
|
||||||
|
|
||||||
# The patched clang lives in the LLVM megarepo
|
version = "1.2";
|
||||||
clangSrc = fetchFromGitHub {
|
|
||||||
|
clingSrc = fetchFromGitHub {
|
||||||
owner = "root-project";
|
owner = "root-project";
|
||||||
repo = "llvm-project";
|
repo = "cling";
|
||||||
# cling-llvm13 branch
|
rev = "v${version}";
|
||||||
rev = "3610201fbe0352a63efb5cb45f4ea4987702c735";
|
sha256 = "sha256-ay9FXANJmB/+AdnCR4WOKHuPm6P88wLqoOgiKJwJ8JM=";
|
||||||
sha256 = "sha256-Cb7BvV7yobG+mkaYe7zD2KcnPvm8/vmVATNWssklXyk=";
|
|
||||||
sparseCheckout = [ "clang" ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
llvm = llvmPackages_13.llvm.override { enableSharedLibraries = false; };
|
unwrapped = stdenv.mkDerivation {
|
||||||
|
|
||||||
unwrapped = stdenv.mkDerivation rec {
|
|
||||||
pname = "cling-unwrapped";
|
pname = "cling-unwrapped";
|
||||||
version = "1.0";
|
inherit version;
|
||||||
|
|
||||||
src = "${clangSrc}/clang";
|
src = fetchFromGitHub {
|
||||||
|
|
||||||
clingSrc = fetchFromGitHub {
|
|
||||||
owner = "root-project";
|
owner = "root-project";
|
||||||
repo = "cling";
|
repo = "llvm-project";
|
||||||
rev = "v${version}";
|
rev = "cling-llvm18-20250721-01";
|
||||||
sha256 = "sha256-Ye8EINzt+dyNvUIRydACXzb/xEPLm0YSkz08Xxw3xp4=";
|
sha256 = "sha256-JGteapyujU5w81DsfPQfTq76cYHgk5PbAFbdYfYIDo4=";
|
||||||
};
|
};
|
||||||
|
|
||||||
prePatch = ''
|
preConfigure = ''
|
||||||
echo "add_llvm_external_project(cling)" >> tools/CMakeLists.txt
|
cp -r ${clingSrc} cling-source
|
||||||
|
|
||||||
cp -r $clingSrc tools/cling
|
# Patch a bug in version 1.2 by backporting a fix. See
|
||||||
chmod -R a+w tools/cling
|
# https://github.com/root-project/cling/issues/556
|
||||||
|
chmod -R u+w cling-source
|
||||||
|
pushd cling-source
|
||||||
|
patch -p1 < ${./fix-new-parser.patch}
|
||||||
|
popd
|
||||||
|
|
||||||
|
cd llvm
|
||||||
'';
|
'';
|
||||||
|
|
||||||
patches = [
|
|
||||||
./no-clang-cpp.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
python3
|
python3
|
||||||
git
|
git
|
||||||
|
|
@ -84,22 +81,15 @@ let
|
||||||
strictDeps = true;
|
strictDeps = true;
|
||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags = [
|
||||||
"-DLLVM_BINARY_DIR=${llvm.out}"
|
"-DLLVM_EXTERNAL_PROJECTS=cling"
|
||||||
"-DLLVM_CONFIG=${llvm.dev}/bin/llvm-config"
|
"-DLLVM_EXTERNAL_CLING_SOURCE_DIR=../../cling-source"
|
||||||
"-DLLVM_LIBRARY_DIR=${llvm.lib}/lib"
|
"-DLLVM_ENABLE_PROJECTS=clang"
|
||||||
"-DLLVM_MAIN_INCLUDE_DIR=${llvm.dev}/include"
|
|
||||||
"-DLLVM_TABLEGEN_EXE=${llvm.out}/bin/llvm-tblgen"
|
|
||||||
"-DLLVM_TOOLS_BINARY_DIR=${llvm.out}/bin"
|
|
||||||
"-DLLVM_BUILD_TOOLS=Off"
|
|
||||||
"-DLLVM_TOOL_CLING_BUILD=ON"
|
|
||||||
|
|
||||||
"-DLLVM_TARGETS_TO_BUILD=host;NVPTX"
|
"-DLLVM_TARGETS_TO_BUILD=host;NVPTX"
|
||||||
|
"-DLLVM_INCLUDE_TESTS=OFF"
|
||||||
"-DLLVM_ENABLE_RTTI=ON"
|
"-DLLVM_ENABLE_RTTI=ON"
|
||||||
|
]
|
||||||
# Setting -DCLING_INCLUDE_TESTS=ON causes the cling/tools targets to be built;
|
++ lib.optionals (!debug) [
|
||||||
# see cling/tools/CMakeLists.txt
|
"-DCMAKE_BUILD_TYPE=Release"
|
||||||
"-DCLING_INCLUDE_TESTS=ON"
|
|
||||||
"-DCLANG-TOOLS=OFF"
|
|
||||||
]
|
]
|
||||||
++ lib.optionals debug [
|
++ lib.optionals debug [
|
||||||
"-DCMAKE_BUILD_TYPE=Debug"
|
"-DCMAKE_BUILD_TYPE=Debug"
|
||||||
|
|
@ -111,11 +101,13 @@ let
|
||||||
|
|
||||||
CPPFLAGS = if useLLVMLibcxx then [ "-stdlib=libc++" ] else [ ];
|
CPPFLAGS = if useLLVMLibcxx then [ "-stdlib=libc++" ] else [ ];
|
||||||
|
|
||||||
postInstall = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
|
postInstall = ''
|
||||||
mkdir -p $out/share/Jupyter
|
mkdir -p $out/share/Jupyter
|
||||||
cp -r /build/clang/tools/cling/tools/Jupyter/kernel $out/share/Jupyter
|
cp -r ../../cling-source/tools/Jupyter/kernel $out/share/Jupyter
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
buildTargets = [ "cling" ];
|
||||||
|
|
||||||
dontStrip = debug;
|
dontStrip = debug;
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
|
|
@ -147,18 +139,18 @@ let
|
||||||
"-nostdinc++"
|
"-nostdinc++"
|
||||||
|
|
||||||
"-resource-dir"
|
"-resource-dir"
|
||||||
"${llvm.lib}/lib"
|
"${llvmPackages_18.llvm.lib}/lib"
|
||||||
|
|
||||||
"-isystem"
|
"-isystem"
|
||||||
"${lib.getLib unwrapped}/lib/clang/${llvmPackages_13.clang.version}/include"
|
"${lib.getLib unwrapped}/lib/clang/18/include"
|
||||||
]
|
]
|
||||||
++ lib.optionals useLLVMLibcxx [
|
++ lib.optionals useLLVMLibcxx [
|
||||||
"-I"
|
"-I"
|
||||||
"${lib.getDev llvmPackages_13.libcxx}/include/c++/v1"
|
"${lib.getDev llvmPackages_18.libcxx}/include/c++/v1"
|
||||||
"-L"
|
"-L"
|
||||||
"${llvmPackages_13.libcxx}/lib"
|
"${llvmPackages_18.libcxx}/lib"
|
||||||
"-l"
|
"-l"
|
||||||
"${llvmPackages_13.libcxx}/lib/libc++${stdenv.hostPlatform.extensions.sharedLibrary}"
|
"${llvmPackages_18.libcxx}/lib/libc++${stdenv.hostPlatform.extensions.sharedLibrary}"
|
||||||
]
|
]
|
||||||
++ lib.optionals (!useLLVMLibcxx) [
|
++ lib.optionals (!useLLVMLibcxx) [
|
||||||
"-I"
|
"-I"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue