Compiler Support: All The Details

This pages summarizes how the supported compilers interact with the variables described on Configure-Time Actions and project-local.cmake: How To Hook Into LIBRA. The variables in the table are an attempt at a polymorphic interface for supporting different compilers, cmake style. In the compiler-specific sections that follow, the shown variables have suffixes ({_GNU,_CLANG,_INTEL}) which are pure to get the docs to link unambiguously and are not present in the code.

Note

The Intel compilers are less feature-complete than others by design: they are targeted to working with optimized builds/codebases later in the development cycle.

LIBRA Variable

gcc/g++

clang/clang++

icx/icpx

LIBRA_DEBUG_INFO

Yes

Yes

Yes

LIBRA_BUILD_PROF

Yes

Yes

No

LIBRA_FORTIFY

Yes

Yes

No

LIBRA_OPT_LEVEL

Yes

Yes

Yes

LIBRA_NATIVE_OPT

Yes

Yes

Yes

LIBRA_C_DIAG_CANDIDATES

Yes

Yes

Yes

LIBRA_CXX_DIAG_CANDIDATES

Yes

Yes

Yes

LIBRA_SAN

Yes, all types

Yes, all types

Yes, all types

LIBRA_PGO

Yes

Yes

Yes

LIBRA_CODE_COV

Yes

Yes

No

LIBRA_VALGRIND_COMPAT

Yes

Yes

No

LIBRA_STDLIB

Yes

Yes

Yes

LIBRA_OPT_REPORT

No

Yes

Yes

GNU (gcc/g++)

LIBRA_DEBUG_INFO_GNU

If enabled: -g2. If disabled: -g0.

LIBRA_BUILD_PROF_GNU

If enabled: -ftime-report.

LIBRA_FORTIFY_GNU

If STACK: -fstack-protector.

If SOURCE: -D_FORTIFY_SOURCE=2.

If FORMAT: -Wformat-security -Werror=format=2.

LIBRA_OPT_LEVEL_GNU

Set to -O0 on Debug builds and -O3 on release builds, unless overriden.

LIBRA_NATIVE_OPT_GNU

If enabled: -march=native -mtune=native.

LIBRA_SAN_GNU

If MSAN enabled:

-fno-omit-frame-pointer
-fno-optimize-sibling-calls
-fsanitize=leak
-fsanitize-recover=all

If ASAN is enabled:

-fno-omit-frame-pointer
-fno-optimize-sibling-calls
-fsanitize=address
-fsanitize-address-use-after-scope
-fsanitize=pointer-compare
-fsanitize=pointer-subtract
-fsanitize-recover=all

If SSAN is enabled:

-fno-omit-frame-pointer
-fstack-protector-all
-fstack-protector-strong
-fsanitize-recover=all.

If UBSAN is enabled:

-fno-omit-frame-pointer
-fsanitize=undefined
-fsanitize=float-divide-by-zero
-fsanitize=float-cast-overflow
-fsanitize=null
-fsanitize=signed-integer-overflow
-fsanitize=bool
-fsanitize=enum
-fsanitize=builtin
-fsanitize=bounds
-fsanitize=vptr
-fsanitize=pointer-overflow
-fsanitize-recover=all

If TSAN is enabled:

-fno-omit-frame-pointer
-fsanitize=thread
-fsanitize-recover=all
LIBRA_PGO_GNU

If GEN: -fprofile-generate.

If USE: -fprofile-use.

LIBRA_CODE_COV_GNU

If enabled: -fprofile-arcs -ftest-coverage -fno-inline -fprofile-update=atomic to compiler, and -fprofile-arcs to linker.

LIBRA_VALGRIND_COMPAT_CLANG

If enabled: -mno-sse3 to compiler.

LIBRA_STDLIB_GNU

If NONE: -nostdlib during at link, both C/C++.

If STDCXX: N/A.

If CXX: N/A.

Note

LIBRA_OPT_REPORT is isn’t supported for GNU compilers because there is not a clean/easy way to get per-file optimization reports without name collisions.

clang (clang/clang++)

LIBRA_DEBUG_INFO_CLANG

If enabled: -g2. If disabled: -g0.

LIBRA_BUILD_PROF_CLANG

If enabled: -ftime-trace.

LIBRA_FORTIFY_CLANG

If STACK: -fstack-protector.

If SOURCE: -D_FORTIFY_SOURCE=2.

If FORMAT: -Wformat-security -Werror=format=2.

LIBRA_OPT_LEVEL_CLANG

Set to -O0 on Debug builds and -O3 on release builds, unless overriden.

LIBRA_SAN_GNU

If MSAN enabled:

-fno-omit-frame-pointer
-fno-optimize-sibling-calls
-fsanitize=memory
-fsanitize-memory-track-origins

If ASAN is enabled:

-fno-omit-frame-pointer
-fno-optimize-sibling-calls
-fsanitize=address,leak

If SSAN is enabled:

-fno-omit-frame-pointer
-fstack-protector-all
-fstack-protector-strong
-fsanitize=safe-stack

If UBSAN is enabled:

-fno-omit-frame-pointer
-fsanitize=undefined
-fsanitize=float-divide-by-zero
-fsanitize=unsigned-integer-overflow
-fsanitize=local-bounds
-fsanitize=nullability

If TSAN is enabled:

-fno-omit-frame-pointer -fsanitize=thread
LIBRA_PGO_CLANG

If GEN: -fprofile-generate. Also passed as linker options to ${PROJECT_NAME}`.

If USE: -fprofile-use.

LIBRA_CODE_COV_CLANG

If enabled and LIBRA_CODE_COV_NATIVE is true: -fprofile-instr-generate -fcoverage-mapping -fno-inline to compiler, -fprofile-instr-generate`` to linker. This makes clang use its native code coverage format, and enables processing with LLVM tools and the various llvm- targets. Because of the nature of llvm-profdata merging, all executables which have been defined as targets in CMAKE_SOURCE_DIR (recursively) are included for merging.

If enabled and LIBRA_CODE_COV_NATIVE is false: --coverage -fno-inline to compiler, --coverage to linker. This makes clang emit .gcno files which are compatible with gcovr, and therefore with the various gcovr- targets.

LIBRA_VALGRIND_COMPAT_CLANG

If enabled: -mno-sse3 to compiler.

LIBRA_STDLIB_CLANG

If NONE: -nostdlib at link, both C/C++.

If STDCXX: -stdlib=libstdc++ at link, C++ only.

If CXX: -stdlib=libc++ at link, C++ only.

LIBRA_OPT_REPORT_CLANG

If enabled: -Rpass=.* -Rpass-missed=.* -Rpass-analysis=.* -fsave-optimization-record at compile.

Intel LLVM (icx/icpx)

LIBRA_DEBUG_INFO_INTEL

If enabled: -g2. If disabled: -g0.

LIBRA_NATIVE_OPT_INTEL

If enabled: -xHost.

LIBRA_SAN_INTEL

If MSAN enabled:

-fno-omit-frame-pointer
-fno-optimize-sibling-calls
-fsanitize=memory
-fsanitize-memory-track-origins

If ASAN is enabled:

-fno-omit-frame-pointer
-fno-optimize-sibling-calls
-fsanitize=address,leak

If SSAN is enabled:

-fno-omit-frame-pointer
-fstack-protector-all
-fstack-protector-strong
-fstack-security-check

If UBSAN is enabled:

-fno-omit-frame-pointer
-fsanitize=undefined

If TSAN is enabled:

-fno-omit-frame-pointer
-fsanitize=thread
LIBRA_PGO_INTEL

If GEN: -fprofile-generate. Also passed as linker options to ${PROJECT_NAME}`.

If USE: -fprofile-use

This is software PGO. Intel also supports HWPGO experimentally, but it isn’t ready for prime time yet.

LIBRA_STDLIB_INTEL

If NONE: -nostdlib at link, both C/C++.

If STDCXX: -stdlib=libstdc++ at link, C++ only.

If CXX: -stdlib=libc++ at link, C++ only.

LIBRA_OPT_REPORT_INTEL

If enabled: -qopt-report=3 -qopt-report-phase=all at compile.