root/root-Simplify-creation-of-TargetMachine.patch
Mattias Ellert a08fcbc5ad Update to 6.28.00
ROOT now uses llvm/clang version 13 (updated from version 9)
Clean up specfile by removing EPEL 7 conditionals
Drop dataframe, roofit and tmva-sofieparser on EPEL 8 ppc64le due to
  "pure virtual method called" errors
Split the root-geom sub-package into three separate sub-packages:
  root-geom, root-geom-builder and root-geom-painter
Enable uring support in EPEL 9 (liburing now available)
New sub-packages: root-geom-webviewer, root-roofit-jsoninterface,
  root-testsupport, root-tree-ntuple-utils, root-tree-webviewer,
  root-xroofit
Dropped patches: 31
New patches: 17
Updated patches: 4
2023-03-19 07:53:00 +01:00

94 lines
3.7 KiB
Diff

From 63d16de24e695a847274fa3044127cefffc7b0b6 Mon Sep 17 00:00:00 2001
From: Jonas Hahnfeld <jonas.hahnfeld@cern.ch>
Date: Fri, 3 Feb 2023 11:52:22 +0100
Subject: [PATCH 1/2] [cling] Simplify creation of TargetMachine
We know exactly which target triple and features the CompilerInstance
wants, we don't need to (and probably must not) second-guess that. This
brings us closer to upstream clang-repl and also includes the change of
https://reviews.llvm.org/D128853 which is crucial for RISC-V.
(cherry picked from commit df0905c499a541eaac3be63c0455a07946022983)
---
.../cling/lib/Interpreter/IncrementalJIT.cpp | 34 ++++++-------------
1 file changed, 11 insertions(+), 23 deletions(-)
diff --git a/interpreter/cling/lib/Interpreter/IncrementalJIT.cpp b/interpreter/cling/lib/Interpreter/IncrementalJIT.cpp
index 5342945ed1..80b6761491 100644
--- a/interpreter/cling/lib/Interpreter/IncrementalJIT.cpp
+++ b/interpreter/cling/lib/Interpreter/IncrementalJIT.cpp
@@ -15,6 +15,7 @@
#include "cling/Utils/Output.h"
#include "cling/Utils/Utils.h"
+#include <clang/Basic/TargetInfo.h>
#include <clang/Basic/TargetOptions.h>
#include <clang/Frontend/CompilerInstance.h>
@@ -292,45 +293,32 @@ Error RTDynamicLibrarySearchGenerator::tryToGenerate(
}
static std::unique_ptr<TargetMachine>
-CreateHostTargetMachine(const clang::CompilerInstance& CI) {
- const clang::TargetOptions& TargetOpts = CI.getTargetOpts();
- const clang::CodeGenOptions& CGOpt = CI.getCodeGenOpts();
- const std::string& Triple = TargetOpts.Triple;
-
- std::string Error;
- const Target *TheTarget = TargetRegistry::lookupTarget(Triple, Error);
- if (!TheTarget) {
- cling::errs() << "cling::IncrementalExecutor: unable to find target:\n"
- << Error;
- return std::unique_ptr<TargetMachine>();
- }
-
+CreateTargetMachine(const clang::CompilerInstance& CI) {
CodeGenOpt::Level OptLevel = CodeGenOpt::Default;
- switch (CGOpt.OptimizationLevel) {
+ switch (CI.getCodeGenOpts().OptimizationLevel) {
case 0: OptLevel = CodeGenOpt::None; break;
case 1: OptLevel = CodeGenOpt::Less; break;
case 2: OptLevel = CodeGenOpt::Default; break;
case 3: OptLevel = CodeGenOpt::Aggressive; break;
default: OptLevel = CodeGenOpt::Default;
}
+
using namespace llvm::orc;
- auto JTMB = JITTargetMachineBuilder::detectHost();
- if (!JTMB)
- logAllUnhandledErrors(JTMB.takeError(), llvm::errs(),
- "Error detecting host");
+ auto JTMB = JITTargetMachineBuilder(CI.getTarget().getTriple());
+ JTMB.addFeatures(CI.getTargetOpts().Features);
- JTMB->setCodeGenOptLevel(OptLevel);
+ JTMB.setCodeGenOptLevel(OptLevel);
#ifdef _WIN32
- JTMB->getOptions().EmulatedTLS = false;
+ JTMB.getOptions().EmulatedTLS = false;
#endif // _WIN32
#if defined(__powerpc64__) || defined(__PPC64__)
// We have to use large code model for PowerPC64 because TOC and text sections
// can be more than 2GB apart.
- JTMB->setCodeModel(CodeModel::Large);
+ JTMB.setCodeModel(CodeModel::Large);
#endif
- std::unique_ptr<TargetMachine> TM = cantFail(JTMB->createTargetMachine());
+ std::unique_ptr<TargetMachine> TM = cantFail(JTMB.createTargetMachine());
// Forcefully disable GlobalISel, it might be enabled on AArch64 without
// optimizations. In tests on an Apple M1 after the upgrade to LLVM 9, this
@@ -365,7 +353,7 @@ IncrementalJIT::IncrementalJIT(
std::unique_ptr<llvm::orc::ExecutorProcessControl> EPC, Error& Err,
void *ExtraLibHandle, bool Verbose)
: SkipHostProcessLookup(false),
- TM(CreateHostTargetMachine(CI)),
+ TM(CreateTargetMachine(CI)),
SingleThreadedContext(std::make_unique<LLVMContext>()) {
ErrorAsOutParameter _(&Err);
--
2.39.2