Skip to content

Commit d1d1a89

Browse files
committed
[libc] Make crt1.o available to clang for GPU builds
Summary: We want to provide the `crt1.o` object inside of the current build so that other projects can use it for tests. Because it's currently an object library (as is also required for the dependencies for the hermetic tests) this cannot be renamed and is not emitted by default. Here we simply add an executable that emits bitcode so that CMake will give it a name.
1 parent 4db37a4 commit d1d1a89

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

libc/startup/gpu/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ function(add_startup_object name)
2626
PROPERTIES
2727
OUTPUT_NAME ${name}.o
2828
)
29+
30+
# Make an executable target of relocatable bitcode for clang if needed.
31+
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
32+
add_executable(${fq_target_name}.exe $<TARGET_OBJECTS:${fq_target_name}>)
33+
set_target_properties(${fq_target_name}.exe PROPERTIES
34+
RUNTIME_OUTPUT_DIRECTORY ${LIBC_LIBRARY_DIR}
35+
RUNTIME_OUTPUT_NAME ${name}.o)
36+
target_link_options(${fq_target_name}.exe PRIVATE
37+
"-flto" "-Wl,--lto-emit-llvm" "-march= ")
38+
endif()
2939
endfunction()
3040

3141
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_ARCHITECTURE})

0 commit comments

Comments
 (0)