Unverified Commit 886dd8d2 authored by Tom McLaughlin's avatar Tom McLaughlin Committed by GitHub
Browse files

cling: 0.9 -> 1.0 (#284865)

parent 0dca1905
Loading
Loading
Loading
Loading
+29 −33
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
, git
, lib
, libffi
, llvmPackages_9
, llvmPackages_13
, makeWrapper
, ncurses
, python3
@@ -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 ];
@@ -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"

@@ -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"
  ] else [
    "-I" "${gcc-unwrapped}/include/c++/${gcc-unwrapped.version}"
    "-I" "${gcc-unwrapped}/include/c++/${gcc-unwrapped.version}/x86_64-unknown-linux-gnu"
@@ -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
  ++ [
+0 −24
Original line number Diff line number Diff line
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
+0 −27
Original line number Diff line number Diff line
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<VModuleKey, std::unique_ptr<LinkedObject>> LinkedObjects;
+private:
   bool ProcessAllSections = false;
 };