Skip to content

Commit

Permalink
toolchain: don't use -fno-builtin.
Browse files Browse the repository at this point in the history
This flag, since it removes builtin function usage entirely, can remove
opportunity for potential compiler optimizations to be applied in some
places, and, more importantly, some extra diagnostic warnings that can
appear when the compiler uses the builtin versions of functions (which
is what happened to point out the issues in [1]).

Unfortunately, removing the flag breaks our build. Using
-fno-builtin-printf is enough to fix it, so a safe assumption is that
when using builtin printf(), the compiler can switch it for different
functions (say, puts()), which we don't have our own implementation for,
meaning the libc version is used and that one requires some extra
functions for the underlying stdio implementation to work.

[1] #125
  • Loading branch information
ericonr committed Apr 8, 2022
1 parent 628113d commit b9052e6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion toolchain/toolchain-arm-none-eabi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ set( CMAKE_OBJCOPY ${TC_PATH}${CROSS_COMPILE}objcopy
set( CMAKE_OBJDUMP ${TC_PATH}${CROSS_COMPILE}objdump
CACHE FILEPATH "The toolchain objdump command " FORCE )

set(COMMON_FLAGS "-fno-common -fno-builtin -ffunction-sections -fdata-sections -fno-strict-aliasing -fmessage-length=0")
set(COMMON_FLAGS "-fno-common -fno-builtin-printf -ffunction-sections -fdata-sections -fno-strict-aliasing -fmessage-length=0")
set(CMAKE_C_FLAGS "${COMMON_FLAGS} -std=gnu99")
set(CMAKE_CXX_FLAGS "${COMMON_FLAGS} -std=gnu++0x")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections,--undefined=uxTopUsedPriority --specs=nosys.specs -nostdlib -static -nostartfiles")

0 comments on commit b9052e6

Please sign in to comment.