From c60fc2406ac3844ec924c95652da3ba604c6feed Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Sun, 20 Nov 2022 16:23:00 -0800 Subject: [PATCH 01/12] Working on update to cling 0.9 --- .../interpreters/cling/default.nix | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pkgs/development/interpreters/cling/default.nix b/pkgs/development/interpreters/cling/default.nix index 1ec265f305b6..d73da5cf21b1 100644 --- a/pkgs/development/interpreters/cling/default.nix +++ b/pkgs/development/interpreters/cling/default.nix @@ -1,13 +1,15 @@ -{ lib, stdenv +{ lib +, stdenv , python3 , libffi , git , cmake , zlib , fetchgit +, fetchFromGitHub , makeWrapper , runCommand -, llvmPackages_5 +, llvmPackages_9 , glibc , ncurses }: @@ -15,21 +17,19 @@ let unwrapped = stdenv.mkDerivation rec { pname = "cling-unwrapped"; - version = "0.7"; + version = "0.9"; src = fetchgit { url = "http://root.cern/git/clang.git"; - # This commit has the tag cling-0.7 so we use it, even though cpt.py - # tries to use refs/tags/cling-patches-rrelease_50 - rev = "354b25b5d915ff3b1946479ad07f3f2768ea1621"; - branchName = "cling-patches"; - sha256 = "0q8q2nnvjx3v59ng0q3qqqhzmzf4pmfqqiy3rz1f3drx5w3lgyjg"; + rev = "cling-v0.9"; + sha256 = "sha256-ft1NUIclSiZ9lN3Z3DJCWA0U9q/K1M0TKkZr+PjsFYk="; }; - clingSrc = fetchgit { - url = "http://root.cern/git/cling.git"; - rev = "70163975eee5a76b45a1ca4016bfafebc9b57e07"; - sha256 = "1mv2fhk857kp5rq714bq49iv7gy9fgdwibydj5wy1kq2m3sf3ysi"; + clingSrc = fetchFromGitHub { + owner = "root-project"; + repo = "cling"; + rev = "v0.9"; + sha256 = "0wx3fi19wfjcph5kclf8108i436y79ddwakrcf0lgxnnxhdjyd29"; }; preConfigure = '' @@ -38,8 +38,8 @@ let chmod -R a+w ./tools/cling ''; - nativeBuildInputs = [ python3 git cmake llvmPackages_5.llvm.dev ]; - buildInputs = [ libffi llvmPackages_5.llvm zlib ncurses ]; + nativeBuildInputs = [ python3 git cmake llvmPackages_9.llvm.dev ]; + buildInputs = [ libffi llvmPackages_9.llvm zlib ncurses ]; strictDeps = true; From 838dae41887ef044a93655830d7b563e3acc391b Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Mon, 21 Nov 2022 21:37:41 -0800 Subject: [PATCH 02/12] First clang patch --- pkgs/development/interpreters/cling/default.nix | 8 ++++++++ .../interpreters/cling/no-clang-cpp.patch | 13 +++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 pkgs/development/interpreters/cling/no-clang-cpp.patch diff --git a/pkgs/development/interpreters/cling/default.nix b/pkgs/development/interpreters/cling/default.nix index d73da5cf21b1..5165afb4b9cd 100644 --- a/pkgs/development/interpreters/cling/default.nix +++ b/pkgs/development/interpreters/cling/default.nix @@ -24,6 +24,7 @@ let rev = "cling-v0.9"; sha256 = "sha256-ft1NUIclSiZ9lN3Z3DJCWA0U9q/K1M0TKkZr+PjsFYk="; }; + # src = /home/tom/tools/clang; clingSrc = fetchFromGitHub { owner = "root-project"; @@ -31,6 +32,7 @@ let rev = "v0.9"; sha256 = "0wx3fi19wfjcph5kclf8108i436y79ddwakrcf0lgxnnxhdjyd29"; }; + # clingSrc = /home/tom/tools/cling; preConfigure = '' echo "add_llvm_external_project(cling)" >> tools/CMakeLists.txt @@ -41,6 +43,10 @@ let nativeBuildInputs = [ python3 git cmake llvmPackages_9.llvm.dev ]; buildInputs = [ libffi llvmPackages_9.llvm zlib ncurses ]; + patches = [ + ./no-clang-cpp.patch + ]; + strictDeps = true; cmakeFlags = [ @@ -50,6 +56,8 @@ let # Setting -DCLING_INCLUDE_TESTS=ON causes the cling/tools targets to be built; # see cling/tools/CMakeLists.txt "-DCLING_INCLUDE_TESTS=ON" + "-DCLANG-TOOLS=OFF" + # "--trace-expand" ]; meta = with lib; { diff --git a/pkgs/development/interpreters/cling/no-clang-cpp.patch b/pkgs/development/interpreters/cling/no-clang-cpp.patch new file mode 100644 index 000000000000..6048037cee84 --- /dev/null +++ b/pkgs/development/interpreters/cling/no-clang-cpp.patch @@ -0,0 +1,13 @@ +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}) From 3405841706c4c5c41f35d3fa3a1c5cac42c9ee7b Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Tue, 22 Nov 2022 15:11:46 -0800 Subject: [PATCH 03/12] Bringing over more patches --- .../interpreters/cling/default.nix | 26 +++++++++++--- .../interpreters/cling/use-patched-llvm.patch | 34 +++++++++++++++++++ 2 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 pkgs/development/interpreters/cling/use-patched-llvm.patch diff --git a/pkgs/development/interpreters/cling/default.nix b/pkgs/development/interpreters/cling/default.nix index 5165afb4b9cd..a4f5118db76f 100644 --- a/pkgs/development/interpreters/cling/default.nix +++ b/pkgs/development/interpreters/cling/default.nix @@ -34,19 +34,35 @@ let }; # clingSrc = /home/tom/tools/cling; - preConfigure = '' + llvmSrc = fetchgit { + url = "http://root.cern/git/llvm.git"; + rev = "cling-v0.9"; + sha256 = "sha256-jts7DMnXwZF/pzUfWEQeJmj5XlOb51aXn6KExMbmcXg="; + }; + # llvmSrc = /home/tom/tools/llvm; + + prePatch = '' echo "add_llvm_external_project(cling)" >> tools/CMakeLists.txt + cp -r $clingSrc ./tools/cling chmod -R a+w ./tools/cling + + mkdir ./interpreter + cp -r $llvmSrc ./interpreter/llvm + chmod -R a+w ./interpreter/llvm ''; + patches = [ + # Applied to clang src + ./no-clang-cpp.patch + + # Applied to cling src + ./use-patched-llvm.patch + ]; + nativeBuildInputs = [ python3 git cmake llvmPackages_9.llvm.dev ]; buildInputs = [ libffi llvmPackages_9.llvm zlib ncurses ]; - patches = [ - ./no-clang-cpp.patch - ]; - strictDeps = true; cmakeFlags = [ diff --git a/pkgs/development/interpreters/cling/use-patched-llvm.patch b/pkgs/development/interpreters/cling/use-patched-llvm.patch new file mode 100644 index 000000000000..5f828ae979ad --- /dev/null +++ b/pkgs/development/interpreters/cling/use-patched-llvm.patch @@ -0,0 +1,34 @@ +diff --git a/lib/Interpreter/CMakeLists.txt b/lib/Interpreter/CMakeLists.txt +index 75396717..6a617ab4 100644 +--- a/lib/Interpreter/CMakeLists.txt ++++ b/lib/Interpreter/CMakeLists.txt +@@ -344,3 +344,29 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cling-compiledata.h + + add_file_dependencies(${CMAKE_CURRENT_SOURCE_DIR}/CIFactory.cpp + ${CMAKE_CURRENT_BINARY_DIR}/cling-compiledata.h) ++ ++# If LLVM is external, but Clang is builtin, we must use some files ++# from patched (builtin) version of LLVM ++if ((NOT builtin_llvm) AND builtin_clang) ++ set(FixInclude "${CMAKE_SOURCE_DIR}/interpreter/llvm/src/include") ++ ++ get_property(P SOURCE IncrementalJIT.cpp PROPERTY INCLUDE_DIRECTORIES) ++ list(INSERT P 0 ${FixInclude}) ++ set_property(SOURCE IncrementalJIT.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") ++ ++ get_property(P SOURCE IncrementalExecutor.cpp PROPERTY INCLUDE_DIRECTORIES) ++ list(INSERT P 0 ${FixInclude}) ++ set_property(SOURCE IncrementalExecutor.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") ++ ++ get_property(P SOURCE Interpreter.cpp PROPERTY INCLUDE_DIRECTORIES) ++ list(INSERT P 0 ${FixInclude}) ++ set_property(SOURCE Interpreter.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") ++ ++ get_property(P SOURCE Transaction.cpp PROPERTY INCLUDE_DIRECTORIES) ++ list(INSERT P 0 ${FixInclude}) ++ set_property(SOURCE Transaction.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") ++ ++ get_property(P SOURCE TransactionUnloader.cpp PROPERTY INCLUDE_DIRECTORIES) ++ list(INSERT P 0 ${FixInclude}) ++ set_property(SOURCE TransactionUnloader.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") ++endif() From d395cc96341901d8be4c3d5a3627e44536198a4f Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Tue, 22 Nov 2022 16:15:29 -0800 Subject: [PATCH 04/12] Tweaking LLVM patch --- .../interpreters/cling/use-patched-llvm.patch | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/development/interpreters/cling/use-patched-llvm.patch b/pkgs/development/interpreters/cling/use-patched-llvm.patch index 5f828ae979ad..34c3bdb43876 100644 --- a/pkgs/development/interpreters/cling/use-patched-llvm.patch +++ b/pkgs/development/interpreters/cling/use-patched-llvm.patch @@ -1,16 +1,16 @@ -diff --git a/lib/Interpreter/CMakeLists.txt b/lib/Interpreter/CMakeLists.txt +diff --git a/tools/cling/lib/Interpreter/CMakeLists.txt b/tools/cling/lib/Interpreter/CMakeLists.txt index 75396717..6a617ab4 100644 ---- a/lib/Interpreter/CMakeLists.txt -+++ b/lib/Interpreter/CMakeLists.txt +--- a/tools/cling/lib/Interpreter/CMakeLists.txt ++++ b/tools/cling/lib/Interpreter/CMakeLists.txt @@ -344,3 +344,29 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cling-compiledata.h - + add_file_dependencies(${CMAKE_CURRENT_SOURCE_DIR}/CIFactory.cpp ${CMAKE_CURRENT_BINARY_DIR}/cling-compiledata.h) + +# If LLVM is external, but Clang is builtin, we must use some files +# from patched (builtin) version of LLVM +if ((NOT builtin_llvm) AND builtin_clang) -+ set(FixInclude "${CMAKE_SOURCE_DIR}/interpreter/llvm/src/include") ++ set(FixInclude "${CMAKE_SOURCE_DIR}/interpreter/llvm/include") + + get_property(P SOURCE IncrementalJIT.cpp PROPERTY INCLUDE_DIRECTORIES) + list(INSERT P 0 ${FixInclude}) From d7b1cb48aa8d150f9954a9cce99e95a799b8fd4c Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Tue, 22 Nov 2022 16:21:55 -0800 Subject: [PATCH 05/12] More on cling patch --- .../interpreters/cling/use-patched-llvm.patch | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/pkgs/development/interpreters/cling/use-patched-llvm.patch b/pkgs/development/interpreters/cling/use-patched-llvm.patch index 34c3bdb43876..dc2ee1536997 100644 --- a/pkgs/development/interpreters/cling/use-patched-llvm.patch +++ b/pkgs/development/interpreters/cling/use-patched-llvm.patch @@ -2,33 +2,31 @@ diff --git a/tools/cling/lib/Interpreter/CMakeLists.txt b/tools/cling/lib/Interp index 75396717..6a617ab4 100644 --- a/tools/cling/lib/Interpreter/CMakeLists.txt +++ b/tools/cling/lib/Interpreter/CMakeLists.txt -@@ -344,3 +344,29 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cling-compiledata.h +@@ -344,3 +344,25 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cling-compiledata.h add_file_dependencies(${CMAKE_CURRENT_SOURCE_DIR}/CIFactory.cpp ${CMAKE_CURRENT_BINARY_DIR}/cling-compiledata.h) + +# If LLVM is external, but Clang is builtin, we must use some files +# from patched (builtin) version of LLVM -+if ((NOT builtin_llvm) AND builtin_clang) -+ set(FixInclude "${CMAKE_SOURCE_DIR}/interpreter/llvm/include") ++set(FixInclude "${CMAKE_SOURCE_DIR}/interpreter/llvm/include") + -+ get_property(P SOURCE IncrementalJIT.cpp PROPERTY INCLUDE_DIRECTORIES) -+ list(INSERT P 0 ${FixInclude}) -+ set_property(SOURCE IncrementalJIT.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") ++get_property(P SOURCE IncrementalJIT.cpp PROPERTY INCLUDE_DIRECTORIES) ++list(INSERT P 0 ${FixInclude}) ++set_property(SOURCE IncrementalJIT.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") + -+ get_property(P SOURCE IncrementalExecutor.cpp PROPERTY INCLUDE_DIRECTORIES) -+ list(INSERT P 0 ${FixInclude}) -+ set_property(SOURCE IncrementalExecutor.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") ++get_property(P SOURCE IncrementalExecutor.cpp PROPERTY INCLUDE_DIRECTORIES) ++list(INSERT P 0 ${FixInclude}) ++set_property(SOURCE IncrementalExecutor.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") + -+ get_property(P SOURCE Interpreter.cpp PROPERTY INCLUDE_DIRECTORIES) -+ list(INSERT P 0 ${FixInclude}) -+ set_property(SOURCE Interpreter.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") ++get_property(P SOURCE Interpreter.cpp PROPERTY INCLUDE_DIRECTORIES) ++list(INSERT P 0 ${FixInclude}) ++set_property(SOURCE Interpreter.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") + -+ get_property(P SOURCE Transaction.cpp PROPERTY INCLUDE_DIRECTORIES) -+ list(INSERT P 0 ${FixInclude}) -+ set_property(SOURCE Transaction.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") ++get_property(P SOURCE Transaction.cpp PROPERTY INCLUDE_DIRECTORIES) ++list(INSERT P 0 ${FixInclude}) ++set_property(SOURCE Transaction.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") + -+ get_property(P SOURCE TransactionUnloader.cpp PROPERTY INCLUDE_DIRECTORIES) -+ list(INSERT P 0 ${FixInclude}) -+ set_property(SOURCE TransactionUnloader.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") ++get_property(P SOURCE TransactionUnloader.cpp PROPERTY INCLUDE_DIRECTORIES) ++list(INSERT P 0 ${FixInclude}) +endif() From d77f11a719f78a8ab6dd000a640c5cad79d189a5 Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Sat, 15 Apr 2023 02:45:35 -0700 Subject: [PATCH 06/12] Able to build cling 0.9 --- .../interpreters/cling/default.nix | 38 +++++++++---------- .../interpreters/cling/fix-llvm-include.patch | 27 +++++++++++++ .../interpreters/cling/use-patched-llvm.patch | 32 ---------------- 3 files changed, 46 insertions(+), 51 deletions(-) create mode 100644 pkgs/development/interpreters/cling/fix-llvm-include.patch delete mode 100644 pkgs/development/interpreters/cling/use-patched-llvm.patch diff --git a/pkgs/development/interpreters/cling/default.nix b/pkgs/development/interpreters/cling/default.nix index a4f5118db76f..5ef6614af2a9 100644 --- a/pkgs/development/interpreters/cling/default.nix +++ b/pkgs/development/interpreters/cling/default.nix @@ -15,6 +15,14 @@ }: let + # The LLVM 9 headers have a couple bugs we need to patch + fixedLlvmDev = runCommand "llvm-dev-${llvmPackages_9.llvm.version}" { buildInputs = [git]; } '' + cp -r ${llvmPackages_9.llvm.dev} $out + cd $out + chmod -R u+w include + git apply ${./fix-llvm-include.patch} + ''; + unwrapped = stdenv.mkDerivation rec { pname = "cling-unwrapped"; version = "0.9"; @@ -24,7 +32,6 @@ let rev = "cling-v0.9"; sha256 = "sha256-ft1NUIclSiZ9lN3Z3DJCWA0U9q/K1M0TKkZr+PjsFYk="; }; - # src = /home/tom/tools/clang; clingSrc = fetchFromGitHub { owner = "root-project"; @@ -32,40 +39,33 @@ let rev = "v0.9"; sha256 = "0wx3fi19wfjcph5kclf8108i436y79ddwakrcf0lgxnnxhdjyd29"; }; - # clingSrc = /home/tom/tools/cling; - - llvmSrc = fetchgit { - url = "http://root.cern/git/llvm.git"; - rev = "cling-v0.9"; - sha256 = "sha256-jts7DMnXwZF/pzUfWEQeJmj5XlOb51aXn6KExMbmcXg="; - }; - # llvmSrc = /home/tom/tools/llvm; prePatch = '' echo "add_llvm_external_project(cling)" >> tools/CMakeLists.txt cp -r $clingSrc ./tools/cling chmod -R a+w ./tools/cling - - mkdir ./interpreter - cp -r $llvmSrc ./interpreter/llvm - chmod -R a+w ./interpreter/llvm ''; patches = [ # Applied to clang src ./no-clang-cpp.patch - - # Applied to cling src - ./use-patched-llvm.patch ]; - nativeBuildInputs = [ python3 git cmake llvmPackages_9.llvm.dev ]; - buildInputs = [ libffi llvmPackages_9.llvm zlib ncurses ]; + nativeBuildInputs = [ python3 git cmake ]; + buildInputs = [ libffi zlib ncurses ]; strictDeps = true; cmakeFlags = [ + "-DLLVM_BINARY_DIR=${llvmPackages_9.llvm.out}" # llvm_dir + "-DLLVM_CONFIG=${llvmPackages_9.llvm.dev}/bin/llvm-config" # llvm_config_path + "-DLLVM_LIBRARY_DIR=${llvmPackages_9.llvm.lib}/lib" # os.path.join(llvm_dir, 'lib') + "-DLLVM_MAIN_INCLUDE_DIR=${fixedLlvmDev}/include" # os.path.join(llvm_dir, 'include') + "-DLLVM_TABLEGEN_EXE=${llvmPackages_9.llvm.out}/bin/llvm-tblgen" # os.path.join(llvm_dir, 'bin', 'llvm-tblgen') + "-DLLVM_TOOLS_BINARY_DIR=${llvmPackages_9.llvm.out}/bin" # os.path.join(llvm_dir, 'bin') + "-DLLVM_TOOL_CLING_BUILD=ON" + "-DLLVM_TARGETS_TO_BUILD=host;NVPTX" "-DLLVM_ENABLE_RTTI=ON" @@ -101,7 +101,7 @@ let "-nostdinc++" "-isystem" "${lib.getDev stdenv.cc.libc}/include" "-I" "${lib.getDev unwrapped}/include" - "-I" "${lib.getLib unwrapped}/lib/clang/5.0.2/include" + # "-I" "${lib.getLib unwrapped}/lib/clang/5.0.2/include" ]; # Autodetect the include paths for the compiler used to build Cling, in the same way Cling does at diff --git a/pkgs/development/interpreters/cling/fix-llvm-include.patch b/pkgs/development/interpreters/cling/fix-llvm-include.patch new file mode 100644 index 000000000000..801965d02d3a --- /dev/null +++ b/pkgs/development/interpreters/cling/fix-llvm-include.patch @@ -0,0 +1,27 @@ +diff --git a/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h b/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h +index 16202d8..3afdac3 100644 +--- a/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h ++++ b/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h +@@ -220,7 +220,7 @@ public: + Error removeModule(VModuleKey K) { + auto I = ModuleMap.find(K); + assert(I != ModuleMap.end() && "VModuleKey K not valid here"); +- auto EDM = std::move(I.second); ++ auto EDM = std::move(I->second); + ModuleMap.erase(I); + return EDM->removeModuleFromBaseLayer(BaseLayer); + } +diff --git a/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h b/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h +index d9535ce..4c688c3 100644 +--- a/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h ++++ b/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h +@@ -472,7 +472,9 @@ private: + + // NB! `LinkedObjects` needs to be destroyed before `NotifyFreed` because + // `~ConcreteLinkedObject` calls `NotifyFreed` ++protected: + std::map> LinkedObjects; ++private: + bool ProcessAllSections = false; + }; + diff --git a/pkgs/development/interpreters/cling/use-patched-llvm.patch b/pkgs/development/interpreters/cling/use-patched-llvm.patch deleted file mode 100644 index dc2ee1536997..000000000000 --- a/pkgs/development/interpreters/cling/use-patched-llvm.patch +++ /dev/null @@ -1,32 +0,0 @@ -diff --git a/tools/cling/lib/Interpreter/CMakeLists.txt b/tools/cling/lib/Interpreter/CMakeLists.txt -index 75396717..6a617ab4 100644 ---- a/tools/cling/lib/Interpreter/CMakeLists.txt -+++ b/tools/cling/lib/Interpreter/CMakeLists.txt -@@ -344,3 +344,25 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cling-compiledata.h - - add_file_dependencies(${CMAKE_CURRENT_SOURCE_DIR}/CIFactory.cpp - ${CMAKE_CURRENT_BINARY_DIR}/cling-compiledata.h) -+ -+# If LLVM is external, but Clang is builtin, we must use some files -+# from patched (builtin) version of LLVM -+set(FixInclude "${CMAKE_SOURCE_DIR}/interpreter/llvm/include") -+ -+get_property(P SOURCE IncrementalJIT.cpp PROPERTY INCLUDE_DIRECTORIES) -+list(INSERT P 0 ${FixInclude}) -+set_property(SOURCE IncrementalJIT.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") -+ -+get_property(P SOURCE IncrementalExecutor.cpp PROPERTY INCLUDE_DIRECTORIES) -+list(INSERT P 0 ${FixInclude}) -+set_property(SOURCE IncrementalExecutor.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") -+ -+get_property(P SOURCE Interpreter.cpp PROPERTY INCLUDE_DIRECTORIES) -+list(INSERT P 0 ${FixInclude}) -+set_property(SOURCE Interpreter.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") -+ -+get_property(P SOURCE Transaction.cpp PROPERTY INCLUDE_DIRECTORIES) -+list(INSERT P 0 ${FixInclude}) -+set_property(SOURCE Transaction.cpp PROPERTY INCLUDE_DIRECTORIES "${P}") -+ -+get_property(P SOURCE TransactionUnloader.cpp PROPERTY INCLUDE_DIRECTORIES) -+list(INSERT P 0 ${FixInclude}) -+endif() From fddb69ff3d910a61e091ea8681e509228a29825d Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Sat, 15 Apr 2023 02:48:16 -0700 Subject: [PATCH 07/12] Remove notes and fix clang include in flags --- pkgs/development/interpreters/cling/default.nix | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkgs/development/interpreters/cling/default.nix b/pkgs/development/interpreters/cling/default.nix index 5ef6614af2a9..3e394daf5fd8 100644 --- a/pkgs/development/interpreters/cling/default.nix +++ b/pkgs/development/interpreters/cling/default.nix @@ -58,12 +58,12 @@ let strictDeps = true; cmakeFlags = [ - "-DLLVM_BINARY_DIR=${llvmPackages_9.llvm.out}" # llvm_dir - "-DLLVM_CONFIG=${llvmPackages_9.llvm.dev}/bin/llvm-config" # llvm_config_path - "-DLLVM_LIBRARY_DIR=${llvmPackages_9.llvm.lib}/lib" # os.path.join(llvm_dir, 'lib') - "-DLLVM_MAIN_INCLUDE_DIR=${fixedLlvmDev}/include" # os.path.join(llvm_dir, 'include') - "-DLLVM_TABLEGEN_EXE=${llvmPackages_9.llvm.out}/bin/llvm-tblgen" # os.path.join(llvm_dir, 'bin', 'llvm-tblgen') - "-DLLVM_TOOLS_BINARY_DIR=${llvmPackages_9.llvm.out}/bin" # os.path.join(llvm_dir, 'bin') + "-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_TOOL_CLING_BUILD=ON" "-DLLVM_TARGETS_TO_BUILD=host;NVPTX" @@ -101,7 +101,7 @@ let "-nostdinc++" "-isystem" "${lib.getDev stdenv.cc.libc}/include" "-I" "${lib.getDev unwrapped}/include" - # "-I" "${lib.getLib unwrapped}/lib/clang/5.0.2/include" + "-I" "${lib.getLib unwrapped}/lib/clang/9.0.1/include" ]; # Autodetect the include paths for the compiler used to build Cling, in the same way Cling does at From 978e32e8b56dec34d26fc13d828e21c6c8fc61f8 Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Sat, 15 Apr 2023 15:57:54 -0700 Subject: [PATCH 08/12] Take only the include dir from llvmPackages_9.llvm.dev --- pkgs/development/interpreters/cling/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/interpreters/cling/default.nix b/pkgs/development/interpreters/cling/default.nix index 3e394daf5fd8..427f8caa4361 100644 --- a/pkgs/development/interpreters/cling/default.nix +++ b/pkgs/development/interpreters/cling/default.nix @@ -17,7 +17,8 @@ let # The LLVM 9 headers have a couple bugs we need to patch fixedLlvmDev = runCommand "llvm-dev-${llvmPackages_9.llvm.version}" { buildInputs = [git]; } '' - cp -r ${llvmPackages_9.llvm.dev} $out + mkdir $out + cp -r ${llvmPackages_9.llvm.dev}/include $out cd $out chmod -R u+w include git apply ${./fix-llvm-include.patch} From cfb1293342612966c12a4ed5928ef0005fa0e013 Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Sun, 16 Apr 2023 17:52:36 -0700 Subject: [PATCH 09/12] Patch cling/tools/driver/CMakeLists.txt, it works now! --- .../interpreters/cling/default.nix | 4 +++- .../cling/fix-llvm-dylib-usage.patch | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/interpreters/cling/fix-llvm-dylib-usage.patch diff --git a/pkgs/development/interpreters/cling/default.nix b/pkgs/development/interpreters/cling/default.nix index 427f8caa4361..b09faa63ef2a 100644 --- a/pkgs/development/interpreters/cling/default.nix +++ b/pkgs/development/interpreters/cling/default.nix @@ -49,8 +49,10 @@ let ''; patches = [ - # Applied to clang src ./no-clang-cpp.patch + + # https://github.com/root-project/root/commit/286d96b12aad8688b9d8e4b3b5df843dcfb716a8 + ./fix-llvm-dylib-usage.patch ]; nativeBuildInputs = [ python3 git cmake ]; diff --git a/pkgs/development/interpreters/cling/fix-llvm-dylib-usage.patch b/pkgs/development/interpreters/cling/fix-llvm-dylib-usage.patch new file mode 100644 index 000000000000..df1fba6b4386 --- /dev/null +++ b/pkgs/development/interpreters/cling/fix-llvm-dylib-usage.patch @@ -0,0 +1,24 @@ +diff --git a/tools/cling/tools/driver/CMakeLists.txt b/tools/cling/tools/driver/CMakeLists.txt +--- a/tools/cling/tools/driver/CMakeLists.txt ++++ b/tools/cling/tools/driver/CMakeLists.txt +@@ -9,10 +9,10 @@ + # Keep symbols for JIT resolution + set(LLVM_NO_DEAD_STRIP 1) + ++set(LLVM_LINK_COMPONENTS support) ++ + if(BUILD_SHARED_LIBS) + set(LIBS +- LLVMSupport +- + clangFrontendTool + + clingInterpreter +@@ -25,8 +25,6 @@ if(BUILD_SHARED_LIBS) + ) + else() + set(LIBS +- LLVMSupport +- + clangASTMatchers + clangFrontendTool From fe00f3f4620b28297667403fe7e11ea9c56138cb Mon Sep 17 00:00:00 2001 From: thomasjm Date: Sun, 16 Apr 2023 23:14:26 -0700 Subject: [PATCH 10/12] Force installation of ClingTargets.cmake --- pkgs/development/interpreters/cling/default.nix | 2 ++ .../cling/force-install-cling-targets.patch | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 pkgs/development/interpreters/cling/force-install-cling-targets.patch diff --git a/pkgs/development/interpreters/cling/default.nix b/pkgs/development/interpreters/cling/default.nix index b09faa63ef2a..645b8e10e4c7 100644 --- a/pkgs/development/interpreters/cling/default.nix +++ b/pkgs/development/interpreters/cling/default.nix @@ -53,6 +53,8 @@ let # https://github.com/root-project/root/commit/286d96b12aad8688b9d8e4b3b5df843dcfb716a8 ./fix-llvm-dylib-usage.patch + + ./force-install-cling-targets.patch ]; nativeBuildInputs = [ python3 git cmake ]; diff --git a/pkgs/development/interpreters/cling/force-install-cling-targets.patch b/pkgs/development/interpreters/cling/force-install-cling-targets.patch new file mode 100644 index 000000000000..627e2593298e --- /dev/null +++ b/pkgs/development/interpreters/cling/force-install-cling-targets.patch @@ -0,0 +1,16 @@ +diff --git a/tools/cling/cmake/modules/CMakeLists.txt b/tools/cling/cmake/modules/CMakeLists.txt +--- a/tools/cling/cmake/modules/CMakeLists.txt ++++ b/tools/cling/cmake/modules/CMakeLists.txt +@@ -54,10 +54,8 @@ set(CLING_CONFIG_EXPORTS_FILE) + + if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) + get_property(cling_has_exports GLOBAL PROPERTY CLING_HAS_EXPORTS) +- if(cling_has_exports) +- install(EXPORT ClingTargets DESTINATION ${CLING_INSTALL_PACKAGE_DIR} +- COMPONENT cling-cmake-exports) +- endif() ++ install(EXPORT ClingTargets DESTINATION ${CLING_INSTALL_PACKAGE_DIR} ++ COMPONENT cling-cmake-exports) + + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClingConfig.cmake From 616c81c641b1660f23536275b8b23d2e3af37f31 Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Tue, 18 Apr 2023 17:01:10 -0700 Subject: [PATCH 11/12] Include the Jupyter kernel in $out/share/jupyter --- pkgs/development/interpreters/cling/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/development/interpreters/cling/default.nix b/pkgs/development/interpreters/cling/default.nix index 645b8e10e4c7..c236b0253c4a 100644 --- a/pkgs/development/interpreters/cling/default.nix +++ b/pkgs/development/interpreters/cling/default.nix @@ -81,6 +81,11 @@ let # "--trace-expand" ]; + postInstall = '' + mkdir -p $out/share/Jupyter + cp -r /build/clang/tools/cling/tools/Jupyter/kernel $out/share/Jupyter + ''; + meta = with lib; { description = "The Interactive C++ Interpreter"; homepage = "https://root.cern/cling/"; From 10926ac11988efaf423b0361a2499fd7d9084c3f Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Tue, 9 May 2023 04:00:43 -0600 Subject: [PATCH 12/12] Disable jupyter kernel installation on darwin --- pkgs/development/interpreters/cling/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/interpreters/cling/default.nix b/pkgs/development/interpreters/cling/default.nix index c236b0253c4a..6a2fa5ea50da 100644 --- a/pkgs/development/interpreters/cling/default.nix +++ b/pkgs/development/interpreters/cling/default.nix @@ -81,7 +81,7 @@ let # "--trace-expand" ]; - postInstall = '' + postInstall = lib.optionalString (!stdenv.isDarwin) '' mkdir -p $out/share/Jupyter cp -r /build/clang/tools/cling/tools/Jupyter/kernel $out/share/Jupyter '';