From b9052e6e577d2555d1f25f3921ce5f203b4007f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Nogueira?= Date: Fri, 8 Apr 2022 09:50:59 -0300 Subject: [PATCH] toolchain: don't use -fno-builtin. 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] https://github.com/lnls-dig/openMMC/issues/125 --- toolchain/toolchain-arm-none-eabi.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolchain/toolchain-arm-none-eabi.cmake b/toolchain/toolchain-arm-none-eabi.cmake index 2da8c342e..bff6c8bdd 100644 --- a/toolchain/toolchain-arm-none-eabi.cmake +++ b/toolchain/toolchain-arm-none-eabi.cmake @@ -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")