llvm-test-suite.cmake.example: fix optimization level selection#17
llvm-test-suite.cmake.example: fix optimization level selection#17atrosinenko wants to merge 1 commit intomasterfrom
Conversation
@atrosinenko Could you please describe the scenario which was broken in a bit more detail? My understanding of this phrase is "If we were compiling llvm-test-suite with BUILD_TYPE=Release, but custom -Ox option in CMAKE_XXX_FLAGS, we effectively had -O3 instead of -Ox". Is this interpretation correct? |
The `*_FLAGS_RELEASE` options are added after `*_FLAGS` ones by CMake, resulting in `-O3 -DNDEBUG` being added unconditionally. This commit overrides both set of variables (and passes `FORCE` flag to `set`) to prevent hard-to-spot errors.
8eeb9d9 to
7f5eb6b
Compare
|
@kovdan01 I updated the description of this PR, hope the updated version is clearer. The idea is that I use a script along these lines opt_levels=(-O0 -O2 -Oz)
clang=/opt/llvm-pauth/bin/clang
for opt in "${opt_levels[@]}"; do
echo "### Testing at $opt ###"
mkdir -p /path/to/llvm-test-suite/build-tmp
cd /path/to/llvm-test-suite/build-tmp
# recheck before uncommenting # rm -rf * .ninja_* .lit_test_times.txt
cmake .. -G Ninja \
-DCUSTOM_FLAGS="$opt" \
-DTEST_SUITE_RUN_BENCHMARKS=ON \
-DCMAKE_C_COMPILER="$clang" \
-C ../cmake/caches/pauth.cmake
ninja
mkdir -p /tmp/llvmts-results
/path/to/bin/llvm-lit -o "/tmp/llvmts-results/report$opt.json" . > "/tmp/llvmts-results/report$opt.log" 2>&1 || true
doneThe test runs performed with different optimization levels turned out to take almost identical amount of time to complete, which seemed highly unlikely for |
When constructing compiler command lines, the arguments in
*_FLAGS_RELEASEare appended after those in*_FLAGSby CMake. Since-O3 -DNDEBUGwas left intact in*_FLAGS_RELEASE, this resulted in-O3being used instead of any custom-O<level>flag passed viaCUSTOM_FLAGS.This commit overrides both set of variables (and passes
FORCEflag toset) to prevent hard-to-spot errors.