Skip to content

Commit

Permalink
Fix static stack semantics for libcalls; cleanup LTO.
Browse files Browse the repository at this point in the history
  • Loading branch information
mysterymath committed Jul 1, 2022
1 parent 589047b commit 5438ec4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
5 changes: 2 additions & 3 deletions mos-platform/atari8/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ merge_libraries(atari8-crt0
common-zero-bss
common-exit-return
)
target_compile_options(atari8-crt0 PRIVATE -fno-lto)

add_platform_library(atari8-c
abort.c
Expand All @@ -22,5 +21,5 @@ add_platform_library(atari8-c
target_include_directories(atari8-c SYSTEM BEFORE PUBLIC .)

# abort is preemptively included if LTO is used, which pulls in _exit support
# unneccessarily.
set_property(SOURCE abort.c PROPERTY COMPILE_FLAGS -fno-lto)
# unneccessarily. It can be called in an interrupt.
set_property(SOURCE abort.c PROPERTY COMPILE_OPTIONS -fno-lto -fno-static-stack)
5 changes: 2 additions & 3 deletions mos-platform/commodore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ merge_libraries(commodore-crt0
common-zero-bss
common-exit-return
)
target_compile_options(commodore-crt0 PRIVATE -fno-lto)

add_platform_library(commodore-c
abort.c
Expand All @@ -22,6 +21,6 @@ add_platform_library(commodore-c
kernal.S
)
# abort is preemptively included if LTO is used, which pulls in _exit support
# unneccessarily.
set_property(SOURCE abort.c PROPERTY COMPILE_OPTIONS -fno-lto)
# unneccessarily. It can also be called in an interrupt.
set_property(SOURCE abort.c PROPERTY COMPILE_OPTIONS -fno-lto -fno-static-stack)
target_include_directories(commodore-c SYSTEM BEFORE PUBLIC .)
4 changes: 3 additions & 1 deletion mos-platform/common/c/stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ int putchar(int c) {
return c;
}

int puts(const char *s) {
// This can be called by abort(), which can be called in a signal and is not
// included in LTO.
__attribute((interrupt, no_isr)) int puts(const char *s) {
for (; *s; ++s)
__putchar(*s);
__putchar('\n');
Expand Down
3 changes: 2 additions & 1 deletion mos-platform/common/crt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ add_platform_library(common-crt
shift.cc
)
# Don't pull in stack pointer init unnecessarily.
set_property(SOURCE divmod-large.cc PROPERTY COMPILE_OPTIONS -fno-lto)
# This can be called in an interrupt.
set_property(SOURCE divmod-large.cc PROPERTY COMPILE_OPTIONS -fno-lto -fno-static-stack)
1 change: 0 additions & 1 deletion mos-platform/osi-c1p/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ merge_libraries(osi-c1p-crt0
common-zero-bss
common-exit-loop
)
target_compile_options(osi-c1p-crt0 PRIVATE -fno-lto)

add_platform_library(osi-c1p-c
abort.c
Expand Down
1 change: 0 additions & 1 deletion mos-platform/sim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ merge_libraries(sim-crt0
common-exit-custom
common-init-stack
)
target_compile_options(sim-crt0 PRIVATE -fno-lto)

add_platform_library(sim-c
assert.c
Expand Down

0 comments on commit 5438ec4

Please sign in to comment.