Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ jobs:
test: true
args: -DMALLOC=emmalloc

- name: Test LTO
os: ubuntu-24.04
clang_version: 19
test: true
args: -DLTO=full -DTARGET_TRIPLE=wasm32-wasip2 -DCHECK_SYMBOLS=OFF

steps:
- uses: actions/checkout@v4.1.7
with:
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ if(LTO)
set(SYSROOT_LIB ${SYSROOT_LIB}/llvm-lto/${clang_version})
if(LTO STREQUAL "thin")
add_compile_options(-flto=thin)
add_link_options(-flto=thin)
elseif(LTO STREQUAL "full")
add_compile_options(-flto)
add_link_options(-flto)
else()
message(FATAL_ERROR "Unknown LTO mode: ${LTO}")
endif()
Expand Down
32 changes: 17 additions & 15 deletions libc-bottom-half/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,21 +195,23 @@ foreach(file crt/crt1-command.c
clang_format_target(${stem})
target_link_libraries(${stem} PRIVATE musl-top-half-interface)
set_pic(${stem})
target_compile_options(${stem} PRIVATE -fvisibility=default)
target_compile_options(${stem} PRIVATE -fvisibility=default -fno-lto)
endforeach()

set(crt_sysroot ${SYSROOT}/lib/${TARGET_TRIPLE})

# crt1-reactor.o is a straight copy of what CMake produces
add_custom_command(
OUTPUT ${SYSROOT_LIB}/crt1-reactor.o
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_OBJECTS:crt1-reactor> ${SYSROOT_LIB}/crt1-reactor.o
OUTPUT ${crt_sysroot}/crt1-reactor.o
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_OBJECTS:crt1-reactor> ${crt_sysroot}/crt1-reactor.o
DEPENDS crt1-reactor $<TARGET_OBJECTS:crt1-reactor>
)

if (WASI STREQUAL "p1")
# wasip1: crt1-command.o is a straight copy of what CMake produces
add_custom_command(
OUTPUT ${SYSROOT_LIB}/crt1-command.o
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_OBJECTS:crt1-command> ${SYSROOT_LIB}/crt1-command.o
OUTPUT ${crt_sysroot}/crt1-command.o
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_OBJECTS:crt1-command> ${crt_sysroot}/crt1-command.o
DEPENDS crt1-command $<TARGET_OBJECTS:crt1-command>
)
elseif (WASI STREQUAL "p2")
Expand All @@ -232,24 +234,24 @@ elseif (WASI STREQUAL "p2")
# please feel free to open an issue or a PR and maintainers can work with you
# on getting that integrated.
add_custom_command(
OUTPUT ${SYSROOT_LIB}/crt1-command.o
OUTPUT ${crt_sysroot}/crt1-command.o
COMMAND
${wasm_tools} component embed
${wasip2_wit_dir}
$<TARGET_OBJECTS:crt1-command>
--world wasi:cli/command@0.2.0
-o ${SYSROOT_LIB}/crt1-command.o
-o ${crt_sysroot}/crt1-command.o
DEPENDS crt1-command wasip2-wits $<TARGET_OBJECTS:crt1-command> wasm-tools
)
elseif (WASI STREQUAL "p3")
add_custom_command(
OUTPUT ${SYSROOT_LIB}/crt1-command.o
OUTPUT ${crt_sysroot}/crt1-command.o
COMMAND
${wasm_tools} component embed
${wasip3_wit_dir}
$<TARGET_OBJECTS:crt1-command>
--world wasi:cli/command@0.3.0-rc-2025-09-16
-o ${SYSROOT_LIB}/crt1-command.o
-o ${crt_sysroot}/crt1-command.o
DEPENDS crt1-command wasip3-wits $<TARGET_OBJECTS:crt1-command> wasm-tools
)
else()
Expand All @@ -259,15 +261,15 @@ endif()
# Provide a plain crt1.o for toolchain compatibility, identical to
# `crt1-command.c`
add_custom_command(
OUTPUT ${SYSROOT_LIB}/crt1.o
COMMAND ${CMAKE_COMMAND} -E copy ${SYSROOT_LIB}/crt1-command.o ${SYSROOT_LIB}/crt1.o
DEPENDS ${SYSROOT_LIB}/crt1-command.o
OUTPUT ${crt_sysroot}/crt1.o
COMMAND ${CMAKE_COMMAND} -E copy ${crt_sysroot}/crt1-command.o ${crt_sysroot}/crt1.o
DEPENDS ${crt_sysroot}/crt1-command.o
)

add_custom_target(sysroot-startup-objects
DEPENDS
${SYSROOT_LIB}/crt1-reactor.o
${SYSROOT_LIB}/crt1-command.o
${SYSROOT_LIB}/crt1.o
${crt_sysroot}/crt1-reactor.o
${crt_sysroot}/crt1-command.o
${crt_sysroot}/crt1.o
)
add_dependencies(sysroot sysroot-startup-objects)
3 changes: 3 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ if (MALLOC STREQUAL "emmalloc")
set_tests_properties(libc_test_functional_search_hsearch.wasm PROPERTIES WILL_FAIL TRUE)
endif()
add_libc_test(functional/search_insque.c)
if (LTO STREQUAL "full")
set_tests_properties(libc_test_functional_search_insque.wasm PROPERTIES WILL_FAIL TRUE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a link to a bug report?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a bug report to link to. This repository does not control the source of this test, nor does this repository have WASI-specific source for insque and other functions. (I barely know what those functions are). If you'd like to open an issue I'd be happy to link it here.

endif()
add_libc_test(functional/search_lsearch.c)
add_libc_test(functional/search_tsearch.c)
add_libc_test(functional/snprintf.c)
Expand Down