From fa648e8fa5598c477aa0147c7a0f0768130141d6 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Tue, 13 Feb 2024 10:14:22 +0100 Subject: [PATCH] Fix disabling optimizations with CLING_DEBUG As noted in #14593, the build fails during a rootcling execution when setting CLING_DEBUG=1 in the environment with error: invalid integral value '0 -fno-omit-frame-pointer' in '-O0 -fno-omit-frame-pointer' Upon investigation, it only works in the ROOT prompt because TCling turns on basic -O1 unless in rootcling. This overrides the (misformed) "-O0 -fno-omit-frame-pointer". Split the argument in two entries and move it after inserting the user-provided arguments to properly apply also on the prompt by now taking precedence over -O1. Closes #14593 --- lib/Interpreter/CIFactory.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/Interpreter/CIFactory.cpp b/lib/Interpreter/CIFactory.cpp index 9b04287fb0..7d376412ae 100644 --- a/lib/Interpreter/CIFactory.cpp +++ b/lib/Interpreter/CIFactory.cpp @@ -1342,18 +1342,21 @@ namespace { if(COpts.CUDAHost) argvCompile.push_back("--cuda-host-only"); + // argv[0] already inserted, get the rest + argvCompile.insert(argvCompile.end(), argv+1, argv + argc); + #ifdef __linux__ // Keep frame pointer to make JIT stack unwinding reliable for profiling if (profilingEnabled) argvCompile.push_back("-fno-omit-frame-pointer"); #endif - // Disable optimizations and keep frame pointer when debugging - if (debuggingEnabled) - argvCompile.push_back("-O0 -fno-omit-frame-pointer"); - - // argv[0] already inserted, get the rest - argvCompile.insert(argvCompile.end(), argv+1, argv + argc); + // Disable optimizations and keep frame pointer when debugging, overriding + // other optimization options that might be in argv + if (debuggingEnabled) { + argvCompile.push_back("-O0"); + argvCompile.push_back("-fno-omit-frame-pointer"); + } // Add host specific includes, -resource-dir if necessary, and -isysroot std::string ClingBin = GetExecutablePath(argv[0]);