Skip to content

Commit 5b1a3de

Browse files
committed
Fixes mpaland#76: Now preventing clang and gcc from replacing our aliased functions with strength-reduced actual standard library functions.
1 parent 957cedd commit 5b1a3de

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ if (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
9393
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
9494
CMAKE_C_COMPILER_ID STREQUAL "Clang")
9595
target_compile_options(printf PRIVATE -Wall -Wextra -pedantic -Wconversion)
96+
if (ALIAS_STANDARD_FUNCTION_NAMES)
97+
# This is important for preventing our aliased implementation
98+
# from being replaced, e.g. printf("%c", 'a') by putchar('a');
99+
# clang and GCC apparently do this as an optimization
100+
target_compile_options(printf PUBLIC -fno-builtin-printf)
101+
endif()
96102
endif()
97103

98104
if (BUILD_TESTS)

0 commit comments

Comments
 (0)