From 7be783b223eb3da7369f19844ef540c3005d6a42 Mon Sep 17 00:00:00 2001 From: David Abdurachmanov Date: Wed, 26 Oct 2016 15:47:08 +0200 Subject: [PATCH] Set code model to Large for PowerPC64 (aka ppc64le) This is needed because TOC and text sections can be more than 2GB apart. LLVM SectionMemoryManager is not aware of the design limits of ppc64le while allocating memory for JIT'ed sections. DSO limit was set to 2GB by design. While running CMSSW ROOT/Cling puts TOC and .text.func ~2.7GB apart in VA space. Usually was triggered by TFormula in CMSSW. IBM has modified global entry function prologue. TOC is now stored in 64-bit value before global entry to allow addressing beyond 2GB. This was merged to Clang months ago, but is only applicable to large code model. Later IBM propagated this further: - binutils patches are here: https://sourceware.org/ml/binutils/2015-11/msg00232.html https://sourceware.org/ml/binutils/2015-11/msg00233.html and will be available with binutils 2.26 - GCC patch is here: https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00355.html and will be available with GCC 6.0. - LLVM patch is here: http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160111/324454.html and will be available with LLVM 3.8. - Kernel patches (module loader etc.) are here: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=a61674bdfc7c2bf909c4010699607b62b69b7bec https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=2e50c4bef77511b42cc226865d6bc568fa7f8769 and will be available with Linux 4.5. Signed-off-by: David Abdurachmanov --- interpreter/cling/lib/Interpreter/IncrementalExecutor.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/interpreter/cling/lib/Interpreter/IncrementalExecutor.cpp b/interpreter/cling/lib/Interpreter/IncrementalExecutor.cpp index 7e4cb435fc877..b36962f9d4255 100644 --- a/interpreter/cling/lib/Interpreter/IncrementalExecutor.cpp +++ b/interpreter/cling/lib/Interpreter/IncrementalExecutor.cpp @@ -89,7 +89,13 @@ std::unique_ptr std::string FeaturesStr; TargetOptions Options = TargetOptions(); +// We have to use large code model for PowerPC64 because TOC and text sections +// can be more than 2GB apart. +#if defined(__powerpc64__) || defined(__PPC64__) + CodeModel::Model CMModel = CodeModel::Large; +#else CodeModel::Model CMModel = CodeModel::JITDefault; +#endif CodeGenOpt::Level OptLevel = CodeGenOpt::Default; switch (CGOpt.OptimizationLevel) { case 0: OptLevel = CodeGenOpt::None; break;