Skip to content
Closed
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
19 changes: 19 additions & 0 deletions compiler-rt/lib/builtins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -854,11 +854,30 @@ else ()
list(APPEND BUILTIN_CFLAGS_${arch} -fforce-enable-int128)
endif()

set(BUILTIN_OBJECT_LIBS_${arch})
# For WebAssembly, we need to compile the atomic.c with different flags than the rest
# to enable atomics and bulk-memory features only for the object file.
if((arch STREQUAL "wasm32" OR arch STREQUAL "wasm64") AND "atomic.c" IN_LIST ${arch}_SOURCES)
set(BUILTIN_ATOMIC_CFLAGS_${arch} ${BUILTIN_CFLAGS_${arch}})
list(APPEND BUILTIN_ATOMIC_CFLAGS_${arch} -matomics -mbulk-memory)
add_compiler_rt_object_libraries(clang_rt.builtins.${arch}.atomic
ARCHS ${arch}
DEPS ${deps_${arch}}
SOURCES atomic.c
DEFS ${BUILTIN_DEFS}
CFLAGS ${BUILTIN_ATOMIC_CFLAGS_${arch}})
# Include the atomic object file in the builtins archive
list(APPEND BUILTIN_OBJECT_LIBS_${arch} clang_rt.builtins.${arch}.atomic)
# Remove atomic.c from the main list of sources
list(REMOVE_ITEM ${arch}_SOURCES atomic.c)
endif()

add_compiler_rt_runtime(clang_rt.builtins
STATIC
ARCHS ${arch}
DEPS ${deps_${arch}}
SOURCES ${${arch}_SOURCES}
OBJECT_LIBS ${BUILTIN_OBJECT_LIBS_${arch}}
DEFS ${BUILTIN_DEFS}
CFLAGS ${BUILTIN_CFLAGS_${arch}}
PARENT_TARGET builtins)
Expand Down