diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake --- a/libc/cmake/modules/LLVMLibCTestRules.cmake +++ b/libc/cmake/modules/LLVMLibCTestRules.cmake @@ -403,9 +403,6 @@ # COMPILE_OPTIONS # ) # -# The startup target should provide a property named STARTUP_OBJECT which is -# the full path to the object file produced when the startup system is built. -# # The DEPENDS list can be empty. If not empty, it should be a list of # targets added with add_entrypoint_object or add_object_library. function(add_integration_test test_name) @@ -464,22 +461,21 @@ file(MAKE_DIRECTORY ${sysroot}/include) set(sysroot_lib ${sysroot}/lib) file(MAKE_DIRECTORY ${sysroot_lib}) - get_target_property(startup_object_file ${INTEGRATION_TEST_STARTUP} STARTUP_OBJECT) - get_target_property(crti_object_file libc.startup.linux.crti STARTUP_OBJECT) - get_target_property(crtn_object_file libc.startup.linux.crtn STARTUP_OBJECT) + set(startup_object_file $) + set(crti_object_file $) + set(crtn_object_file $) set(dummy_archive $/lib$.a) - if(NOT startup_object_file) - message(FATAL_ERROR "Missing STARTUP_OBJECT property of ${INTEGRATION_TEST_STARTUP}.") - endif() - set(startup_dst ${sysroot_lib}/${LIBC_TARGET_ARCHITECTURE}-linux-gnu/crt1.o) + # TODO: Copy the startup files to the correct target-triple directory instead + # of to a partly hard-coded directory. + set(startup_dst ${sysroot_lib}/${LIBC_TARGET_ARCHITECTURE}-linux-gnu) add_custom_command( OUTPUT ${startup_dst} ${sysroot}/lib/crti.o ${sysroot}/lib/crtn.o ${sysroot}/lib/libm.a ${sysroot}/lib/libc++.a - COMMAND cmake -E copy ${startup_object_file} ${startup_dst} - COMMAND cmake -E copy ${crti_object_file} ${sysroot}/lib - COMMAND cmake -E copy ${crtn_object_file} ${sysroot}/lib + COMMAND cmake -E copy ${startup_object_file} ${startup_dst}/$ + COMMAND cmake -E copy ${crti_object_file} ${sysroot_lib}/$ + COMMAND cmake -E copy ${crtn_object_file} ${sysroot_lib}/$ # We copy the dummy archive as libm.a and libc++.a as the compiler drivers expect them. - COMMAND cmake -E copy ${dummy_archive} ${sysroot}/lib/libm.a - COMMAND cmake -E copy ${dummy_archive} ${sysroot}/lib/libc++.a + COMMAND cmake -E copy ${dummy_archive} ${sysroot_lib}/libm.a + COMMAND cmake -E copy ${dummy_archive} ${sysroot_lib}/libc++.a DEPENDS ${INTEGRATION_TEST_STARTUP} libc.startup.linux.crti libc.startup.linux.crtn libc_integration_test_dummy ) add_custom_target( diff --git a/libc/startup/linux/CMakeLists.txt b/libc/startup/linux/CMakeLists.txt --- a/libc/startup/linux/CMakeLists.txt +++ b/libc/startup/linux/CMakeLists.txt @@ -8,53 +8,22 @@ ) get_fq_target_name(${name} fq_target_name) - get_fq_deps_list(fq_deps_list ${ADD_STARTUP_OBJECT_DEPENDS}) if(ADD_STARTUP_OBJECT_ALIAS) - list(LENGTH ADD_STARTUP_OBJECT_DEPENDS deps_size) - if(NOT (${deps_size} EQUAL "1")) - message(FATAL_ERROR "A startup object alias should have exactly one dependency.") - endif() - list(GET ADD_STARTUP_OBJECT_DEPENDS 0 dep) - get_fq_dep_name(fq_dep_name ${dep}) - - add_custom_target(${fq_target_name}) - add_dependencies(${fq_target_name} ${fq_dep_name}) - get_target_property(startup_object ${fq_dep_name} STARTUP_OBJECT) - set_target_properties( - ${fq_target_name} - PROPERTIES - "TARGET_TYPE" "${OBJECT_LIBRARY_TARGET_TYPE}" - "STARTUP_OBJECT" "${startup_object}" - "OBJECT_FILES" "" - "DEPS" "${fq_dep_name}" - ) + get_fq_deps_list(fq_dep_list ${ADD_STARTUP_OBJECT_DEPENDS}) + add_library(${fq_target_name} ALIAS ${fq_dep_list}) return() endif() add_object_library( - ${name}.__objects__ + ${name} SRCS ${ADD_STARTUP_OBJECT_SRC} DEPENDS ${ADD_STARTUP_OBJECT_DEPENDS} COMPILE_OPTIONS ${ADD_STARTUP_OBJECT_COMPILE_OPTIONS} ) - - set(objfile ${LIBC_BUILD_DIR}/lib/${name}.o) - add_custom_command( - OUTPUT ${objfile} - COMMAND cp $ ${objfile} - DEPENDS $ - ) - add_custom_target( - ${fq_target_name} - DEPENDS ${objfile} - ) set_target_properties( ${fq_target_name} PROPERTIES - "TARGET_TYPE" "${OBJECT_LIBRARY_TARGET_TYPE}" - "STARTUP_OBJECT" "${objfile}" - "OBJECT_FILES" "" - "DEPS" "${fq_target_name}.__objects__" + OUTPUT_NAME ${name}.o ) endfunction() @@ -89,8 +58,8 @@ foreach(target IN LISTS startup_components) set(fq_target_name libc.startup.linux.${target}) add_dependencies(libc-startup ${fq_target_name}) - get_target_property(startup_object ${fq_target_name} STARTUP_OBJECT) - install(FILES ${startup_object} + install(FILES $ DESTINATION ${CMAKE_INSTALL_LIBDIR} + RENAME $ COMPONENT libc) endforeach()