Skip to content

Commit

Permalink
Disable LTO and static stacks for all crt builtins
Browse files Browse the repository at this point in the history
These functions can be called from floating point builtins, which
violates the implicit attribute leaf on them. The floating point
builtins shouldn't be brought in summarily to LTO, since they may
reserve ZP and static stack space even if unused. The same logic broadly
applies to all CRT builtins, so until we have a better solution, pull
all of them out of LTO.
  • Loading branch information
mysterymath committed Dec 4, 2023
1 parent a5e0a1c commit 86b9dc2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mos-platform/common/crt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ add_platform_library(common-crt
shift.cc
rotate.cc
)
# Don't pull in stack pointer init unnecessarily.
# This can be called in an interrupt.
set_property(SOURCE divmod-large.cc PROPERTY COMPILE_OPTIONS -fno-lto -fno-static-stack)

# Disable LTO for builtins since they may otherwise take up ZP and static
# spance even if unused. Disable static stacks, since they are not LTOed, and
# they may be called within interrupts.
target_compile_options(common-crt PRIVATE -fno-lto -fno-static-stack)

# Merge the builtins library from llvm-mos into libcrt.
get_filename_component(compiler_dir ${CMAKE_C_COMPILER} DIRECTORY)
Expand Down

0 comments on commit 86b9dc2

Please sign in to comment.