Compiler Support: All The Details#

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 purely 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.

GNU (gcc/g++)#

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_NATIVE_GNU#

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

LIBRA_OPT_NO_GUARDS_GNU#

If enabled: -fomit-frame-pointer -fno-stack-protector.

LIBRA_OPT_INLINE_GNU#

If enabled: -fno-semantic-interposition, -fvisibility=hidden,-fvisibility-inlines-hidden.

LIBRA_OPT_LINKER_GNU#

If enabled:

-ffunction-sections, -fdata-sections compile flags.

-Wl,--gc-sections link flags.

LIBRA_OPT_NO_EXCEPTIONS_GNU#

If enabled: -fno-exceptions. C++ only.

LIBRA_OPT_NO_RTTI_GNU#

If enabled: -fno-rtti. C++ only.

LIBRA_OPT_FAST_MATH_GNU#

If enabled: -ffast-math.

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 -fprofile-update=prefer-atomic to compiler, -fprofile-generate to linker.

If USE: -fprofile-use to compiler and linker.

LIBRA_COVERAGE_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 at link, both C/C++.

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_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_NATIVE_CLANG#

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

LIBRA_OPT_NO_GUARDS_CLANG#

If enabled: -fomit-frame-pointer -fno-stack-protector.

LIBRA_OPT_INLINE_CLANG#

If enabled: -fno-semantic-interposition, -fvisibility=hidden,-fvisibility-inlines-hidden.

LIBRA_OPT_LINKER_CLANG#

If enabled:

-ffunction-sections, -fdata-sections compile flags.

-Wl,--gc-sections link flags.

LIBRA_OPT_NO_EXCEPTIONS_CLANG#

If enabled: -fno-exceptions. C++ only.

LIBRA_OPT_NO_RTTI_CLANG#

If enabled: -fno-rtti. C++ only.

LIBRA_OPT_FAST_MATH_CLANG#

If enabled: -ffast-math.

LIBRA_SAN_CLANG#

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_COVERAGE_CLANG#

If enabled and LIBRA_COVERAGE_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_CURRENT_SOURCE_DIR (recursively) are included for merging.

If enabled and LIBRA_COVERAGE_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_OPT_NATIVE_INTEL#

If enabled: -xHost.

LIBRA_OPT_NO_GUARDS_INTEL#

If enabled: -fomit-frame-pointer -fno-stack-protector.

LIBRA_OPT_INLINE_INTEL#

If enabled: -fno-semantic-interposition, -fvisibility=hidden,-fvisibility-inlines-hidden.

LIBRA_OPT_LINKER_INTEL#

If enabled:

-ffunction-sections, -fdata-sections compile flags.

-Wl,--gc-sections link flags.

LIBRA_OPT_NO_EXCEPTIONS_INTEL#

If enabled: -fno-exceptions. C++ only.

LIBRA_OPT_NO_RTTI_INTEL#

If enabled: -fno-rtti. C++ only.

LIBRA_OPT_FAST_MATH_INTEL#

If enabled: -ffast-math.

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.