diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -197,9 +197,9 @@ add_subdirectory(utils) if(LLVM_LIBC_FULL_BUILD) - # The loader can potentially depend on the library components so add it - # after the library implementation directories. - add_subdirectory(loader) + # The startup system can potentially depend on the library components so add + # it after the library implementation directories. + add_subdirectory(startup) endif() # The lib and test directories are added at the very end as tests 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 @@ -106,7 +106,7 @@ # machine specific object library. Such a test would be testing internals of # the libc and it is assumed that they will be rare in practice. So, they # can be skipped in the corresponding CMake files using platform specific - # logic. This pattern is followed in the loader tests for example. + # logic. This pattern is followed in the startup tests for example. # # Another pattern that is present currently is to detect machine # capabilities and add entrypoints and tests accordingly. That approach is @@ -377,10 +377,10 @@ endfunction(add_libc_fuzzer) # Rule to add an integration test. An integration test is like a unit test -# but does not use the system libc. Not even the loader from the system libc -# is linked to the final executable. The final exe is fully statically linked. -# The libc that the final exe links to consists of only the object files of -# the DEPENDS targets. +# but does not use the system libc. Not even the startup objects from the +# system libc are linked in to the final executable. The final exe is fully +# statically linked. The libc that the final exe links to consists of only +# the object files of the DEPENDS targets. # # Usage: # add_integration_test( @@ -388,15 +388,15 @@ # SUITE # SRCS [src2.cpp ...] # HDRS [hdr1.cpp ...] -# LOADER +# STARTUP # DEPENDS # ARGS # ENV # COMPILE_OPTIONS # ) # -# The loader target should provide a property named LOADER_OBJECT which is -# the full path to the object file produces when the loader is built. +# 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. @@ -409,7 +409,7 @@ cmake_parse_arguments( "INTEGRATION_TEST" "" # No optional arguments - "SUITE;LOADER" # Single value arguments + "SUITE;STARTUP" # Single value arguments "SRCS;HDRS;DEPENDS;ARGS;ENV;COMPILE_OPTIONS" # Multi-value arguments ${ARGN} ) @@ -417,8 +417,8 @@ if(NOT INTEGRATION_TEST_SUITE) message(FATAL_ERROR "SUITE not specified for ${fq_target_name}") endif() - if(NOT INTEGRATION_TEST_LOADER) - message(FATAL_ERROR "The LOADER to link to the integration test is missing.") + if(NOT INTEGRATION_TEST_STARTUP) + message(FATAL_ERROR "The STARTUP to link to the integration test is missing.") endif() if(NOT INTEGRATION_TEST_SRCS) message(FATAL_ERROR "The SRCS list for add_integration_test is missing.") @@ -456,27 +456,27 @@ file(MAKE_DIRECTORY ${sysroot}/include) set(sysroot_lib ${sysroot}/lib) file(MAKE_DIRECTORY ${sysroot_lib}) - get_target_property(loader_object_file ${INTEGRATION_TEST_LOADER} LOADER_OBJECT) - get_target_property(crti_object_file libc.loader.linux.crti LOADER_OBJECT) - get_target_property(crtn_object_file libc.loader.linux.crtn LOADER_OBJECT) + 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(dummy_archive $/lib$.a) - if(NOT loader_object_file) - message(FATAL_ERROR "Missing LOADER_OBJECT property of ${INTEGRATION_TEST_LOADER}.") + if(NOT startup_object_file) + message(FATAL_ERROR "Missing STARTUP_OBJECT property of ${INTEGRATION_TEST_STARTUP}.") endif() - set(loader_dst ${sysroot_lib}/${LIBC_TARGET_ARCHITECTURE}-linux-gnu/crt1.o) + set(startup_dst ${sysroot_lib}/${LIBC_TARGET_ARCHITECTURE}-linux-gnu/crt1.o) add_custom_command( - OUTPUT ${loader_dst} ${sysroot}/lib/crti.o ${sysroot}/lib/crtn.o ${sysroot}/lib/libm.a ${sysroot}/lib/libc++.a - COMMAND cmake -E copy ${loader_object_file} ${loader_dst} + 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 # 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 - DEPENDS ${INTEGRATION_TEST_LOADER} libc.loader.linux.crti libc.loader.linux.crtn libc_integration_test_dummy + DEPENDS ${INTEGRATION_TEST_STARTUP} libc.startup.linux.crti libc.startup.linux.crtn libc_integration_test_dummy ) add_custom_target( - ${fq_target_name}.__copy_loader__ - DEPENDS ${loader_dst} + ${fq_target_name}.__copy_startup__ + DEPENDS ${startup_dst} ) add_library( @@ -520,7 +520,7 @@ # as is (and not as paths like /usr/lib/.../crtbegin.o). target_link_options(${fq_target_name} PRIVATE --sysroot=${sysroot} -static -stdlib=libc++ --rtlib=compiler-rt) add_dependencies(${fq_target_name} - ${fq_target_name}.__copy_loader__ + ${fq_target_name}.__copy_startup__ ${fq_libc_target_name} libc.utils.IntegrationTest.test ${INTEGRATION_TEST_DEPENDS}) diff --git a/libc/docs/source_tree_layout.rst b/libc/docs/source_tree_layout.rst --- a/libc/docs/source_tree_layout.rst +++ b/libc/docs/source_tree_layout.rst @@ -13,7 +13,7 @@ - fuzzing - include - lib - - loader + - startup - src - test - utils @@ -58,11 +58,11 @@ This directory contains a ``CMakeLists.txt`` file listing the targets for the public libraries ``libc.a``, ``libm.a`` etc. -The ``loader`` directory +The ``startup`` directory ------------------------ -This directory contains the implementations of the application loaders like -``crt1.o`` etc. +This directory contains the implementations of the application startup objects +like ``crt1.o`` etc. The ``src`` directory --------------------- diff --git a/libc/loader/CMakeLists.txt b/libc/startup/CMakeLists.txt rename from libc/loader/CMakeLists.txt rename to libc/startup/CMakeLists.txt diff --git a/libc/loader/linux/CMakeLists.txt b/libc/startup/linux/CMakeLists.txt rename from libc/loader/linux/CMakeLists.txt rename to libc/startup/linux/CMakeLists.txt --- a/libc/loader/linux/CMakeLists.txt +++ b/libc/startup/linux/CMakeLists.txt @@ -1,6 +1,6 @@ -function(add_loader_object name) +function(add_startup_object name) cmake_parse_arguments( - "ADD_LOADER_OBJECT" + "ADD_STARTUP_OBJECT" "ALIAS" # Option argument "SRC" # Single value arguments "DEPENDS;COMPILE_OPTIONS" # Multi value arguments @@ -8,23 +8,23 @@ ) get_fq_target_name(${name} fq_target_name) - get_fq_deps_list(fq_deps_list ${ADD_LOADER_OBJECT_DEPENDS}) - if(ADD_LOADER_OBJECT_ALIAS) - list(LENGTH ADD_LOADER_OBJECT_DEPENDS deps_size) + 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 loader object alias should have exactly one dependency.") + message(FATAL_ERROR "A startup object alias should have exactly one dependency.") endif() - list(GET ADD_LOADER_OBJECT_DEPENDS 0 dep) + 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(loader_object ${fq_dep_name} LOADER_OBJECT) + get_target_property(startup_object ${fq_dep_name} STARTUP_OBJECT) set_target_properties( ${fq_target_name} PROPERTIES "TARGET_TYPE" "${OBJECT_LIBRARY_TARGET_TYPE}" - "LOADER_OBJECT" "${loader_object}" + "STARTUP_OBJECT" "${startup_object}" "OBJECT_FILES" "" "DEPS" "${fq_dep_name}" ) @@ -33,9 +33,9 @@ add_object_library( ${name}.__objects__ - SRCS ${ADD_LOADER_OBJECT_SRC} - DEPENDS ${ADD_LOADER_OBJECT_DEPENDS} - COMPILE_OPTIONS ${ADD_LOADER_OBJECT_COMPILE_OPTIONS} + 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) @@ -52,33 +52,33 @@ ${fq_target_name} PROPERTIES "TARGET_TYPE" "${OBJECT_LIBRARY_TARGET_TYPE}" - "LOADER_OBJECT" "${objfile}" + "STARTUP_OBJECT" "${objfile}" "OBJECT_FILES" "" "DEPS" "${fq_target_name}.__objects__" ) endfunction() if(NOT (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_ARCHITECTURE})) - message(STATUS "Skipping loader for target architecture ${LIBC_TARGET_ARCHITECTURE}") + message(STATUS "Skipping startup for target architecture ${LIBC_TARGET_ARCHITECTURE}") return() endif() add_subdirectory(${LIBC_TARGET_ARCHITECTURE}) -add_loader_object( +add_startup_object( crt1 ALIAS DEPENDS .${LIBC_TARGET_ARCHITECTURE}.crt1 ) -add_loader_object( +add_startup_object( crti SRC crti.cpp ) -add_loader_object( +add_startup_object( crtn SRC crtn.cpp @@ -87,10 +87,10 @@ add_custom_target(libc-startup) set(startup_components crt1 crti crtn) foreach(target IN LISTS startup_components) - set(fq_target_name libc.loader.linux.${target}) + set(fq_target_name libc.startup.linux.${target}) add_dependencies(libc-startup ${fq_target_name}) - get_target_property(loader_object ${fq_target_name} LOADER_OBJECT) - install(FILES ${loader_object} + get_target_property(startup_object ${fq_target_name} STARTUP_OBJECT) + install(FILES ${startup_object} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${LIBC_COMPONENT}) endforeach() diff --git a/libc/loader/linux/aarch64/CMakeLists.txt b/libc/startup/linux/aarch64/CMakeLists.txt rename from libc/loader/linux/aarch64/CMakeLists.txt rename to libc/startup/linux/aarch64/CMakeLists.txt --- a/libc/loader/linux/aarch64/CMakeLists.txt +++ b/libc/startup/linux/aarch64/CMakeLists.txt @@ -1,4 +1,4 @@ -add_loader_object( +add_startup_object( crt1 SRC start.cpp diff --git a/libc/loader/linux/aarch64/start.cpp b/libc/startup/linux/aarch64/start.cpp rename from libc/loader/linux/aarch64/start.cpp rename to libc/startup/linux/aarch64/start.cpp diff --git a/libc/loader/linux/crti.cpp b/libc/startup/linux/crti.cpp rename from libc/loader/linux/crti.cpp rename to libc/startup/linux/crti.cpp diff --git a/libc/loader/linux/crtn.cpp b/libc/startup/linux/crtn.cpp rename from libc/loader/linux/crtn.cpp rename to libc/startup/linux/crtn.cpp diff --git a/libc/loader/linux/x86_64/CMakeLists.txt b/libc/startup/linux/x86_64/CMakeLists.txt rename from libc/loader/linux/x86_64/CMakeLists.txt rename to libc/startup/linux/x86_64/CMakeLists.txt --- a/libc/loader/linux/x86_64/CMakeLists.txt +++ b/libc/startup/linux/x86_64/CMakeLists.txt @@ -1,4 +1,4 @@ -add_loader_object( +add_startup_object( crt1 SRC start.cpp diff --git a/libc/loader/linux/x86_64/start.cpp b/libc/startup/linux/x86_64/start.cpp rename from libc/loader/linux/x86_64/start.cpp rename to libc/startup/linux/x86_64/start.cpp diff --git a/libc/test/integration/CMakeLists.txt b/libc/test/integration/CMakeLists.txt --- a/libc/test/integration/CMakeLists.txt +++ b/libc/test/integration/CMakeLists.txt @@ -15,6 +15,6 @@ ARCHIVE_OUTPUT_NAME dummy ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -add_subdirectory(loader) +add_subdirectory(startup) add_subdirectory(scudo) add_subdirectory(src) diff --git a/libc/test/integration/loader/linux/CMakeLists.txt b/libc/test/integration/loader/linux/CMakeLists.txt deleted file mode 100644 --- a/libc/test/integration/loader/linux/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -if(NOT (EXISTS ${LIBC_SOURCE_DIR}/loader/linux/${LIBC_TARGET_ARCHITECTURE})) - message("Skipping loader integration tests for target architecture ${LIBC_TARGET_ARCHITECTURE}.") - return() -endif() - -add_custom_target(libc-loader-tests) -add_dependencies(libc-integration-tests libc-loader-tests) - -add_integration_test( - loader_args_test - SUITE libc-loader-tests - LOADER - libc.loader.linux.crt1 - SRCS - args_test.cpp - ARGS - 1 2 3 - ENV - FRANCE=Paris - GERMANY=Berlin -) - -add_integration_test( - loader_no_envp_test - SUITE libc-loader-tests - LOADER - libc.loader.linux.crt1 - SRCS - main_without_envp.cpp -) - -add_integration_test( - loader_no_args_test - SUITE libc-loader-tests - LOADER - libc.loader.linux.crt1 - SRCS - main_without_args.cpp -) - -add_integration_test( - loader_tls_test - SUITE libc-loader-tests - LOADER - libc.loader.linux.crt1 - SRCS - tls_test.cpp - DEPENDS - libc.include.errno - libc.include.sys_mman - libc.src.errno.errno - libc.src.sys.mman.mmap -) - -add_integration_test( - init_fini_array_test - SUITE libc-loader-tests - LOADER - libc.loader.linux.crt1 - SRCS - init_fini_array_test.cpp -) diff --git a/libc/test/integration/scudo/CMakeLists.txt b/libc/test/integration/scudo/CMakeLists.txt --- a/libc/test/integration/scudo/CMakeLists.txt +++ b/libc/test/integration/scudo/CMakeLists.txt @@ -5,9 +5,9 @@ # We use a special library consisting of only the SCUDO allocator # functions to link to the integration tests below. We could instead # link to libllvmlibc.a directly, but since libllvmlibc.a contains -# functions which depend on the LLVM libc loader, the integration -# test will have to link to the LLVM libc loader. LLVM libc's loader -# is not complete enough to allow this. It is also desireable to +# functions which depend on the LLVM libc startup system, the integration +# test will have to link to the LLVM libc startup system. LLVM libc's startup +# system is not complete enough to allow this. It is also desireable to # keep the dependencies as minimal as possible. add_entrypoint_library( libc_for_scudo_integration_test diff --git a/libc/test/integration/src/__support/threads/CMakeLists.txt b/libc/test/integration/src/__support/threads/CMakeLists.txt --- a/libc/test/integration/src/__support/threads/CMakeLists.txt +++ b/libc/test/integration/src/__support/threads/CMakeLists.txt @@ -11,8 +11,8 @@ libc-support-threads-integration-tests SRCS thread_detach_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.src.__support.threads.mutex libc.src.__support.threads.thread @@ -24,8 +24,8 @@ libc-support-threads-integration-tests SRCS thread_tls_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.src.__support.threads.thread ) diff --git a/libc/test/integration/src/pthread/CMakeLists.txt b/libc/test/integration/src/pthread/CMakeLists.txt --- a/libc/test/integration/src/pthread/CMakeLists.txt +++ b/libc/test/integration/src/pthread/CMakeLists.txt @@ -6,8 +6,8 @@ libc-pthread-integration-tests SRCS pthread_mutex_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.include.pthread libc.src.errno.errno @@ -25,8 +25,8 @@ libc-pthread-integration-tests SRCS pthread_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.include.pthread libc.src.pthread.pthread_create @@ -39,8 +39,8 @@ libc-pthread-integration-tests SRCS pthread_equal_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.include.pthread libc.src.errno.errno @@ -60,8 +60,8 @@ libc-pthread-integration-tests SRCS pthread_name_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.include.errno libc.include.pthread @@ -83,8 +83,8 @@ libc-pthread-integration-tests SRCS pthread_exit_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.include.pthread libc.src.pthread.pthread_create @@ -98,8 +98,8 @@ libc-pthread-integration-tests SRCS pthread_tss_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.include.pthread libc.src.pthread.pthread_create @@ -117,8 +117,8 @@ libc-pthread-integration-tests SRCS pthread_once_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.include.pthread libc.src.pthread.pthread_once diff --git a/libc/test/integration/src/spawn/CMakeLists.txt b/libc/test/integration/src/spawn/CMakeLists.txt --- a/libc/test/integration/src/spawn/CMakeLists.txt +++ b/libc/test/integration/src/spawn/CMakeLists.txt @@ -26,8 +26,8 @@ spawn-integration-tests SRCS posix_spawn_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc_posix_spawn_test_binary libc.test.integration.src.spawn.test_binary_properties diff --git a/libc/test/integration/src/stdio/CMakeLists.txt b/libc/test/integration/src/stdio/CMakeLists.txt --- a/libc/test/integration/src/stdio/CMakeLists.txt +++ b/libc/test/integration/src/stdio/CMakeLists.txt @@ -9,8 +9,8 @@ stdio-integration-tests SRCS sprintf_size_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.src.stdio.sprintf ARGS @@ -26,8 +26,8 @@ stdio-integration-tests SRCS sprintf_size_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 ARGS "%s %c %d" "First arg" diff --git a/libc/test/integration/src/stdlib/CMakeLists.txt b/libc/test/integration/src/stdlib/CMakeLists.txt --- a/libc/test/integration/src/stdlib/CMakeLists.txt +++ b/libc/test/integration/src/stdlib/CMakeLists.txt @@ -7,8 +7,8 @@ stdlib-integration-tests SRCS getenv_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.src.stdlib.getenv ENV diff --git a/libc/test/integration/src/threads/CMakeLists.txt b/libc/test/integration/src/threads/CMakeLists.txt --- a/libc/test/integration/src/threads/CMakeLists.txt +++ b/libc/test/integration/src/threads/CMakeLists.txt @@ -6,8 +6,8 @@ libc-threads-integration-tests SRCS mtx_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.include.threads libc.src.errno.errno @@ -25,8 +25,8 @@ libc-threads-integration-tests SRCS thrd_equal_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.include.threads libc.src.threads.mtx_destroy @@ -45,8 +45,8 @@ libc-threads-integration-tests SRCS thrd_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.include.threads libc.src.errno.errno @@ -60,8 +60,8 @@ libc-threads-integration-tests SRCS thrd_exit_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.include.threads libc.src.threads.thrd_create @@ -75,8 +75,8 @@ libc-threads-integration-tests SRCS tss_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.include.threads libc.src.threads.thrd_create @@ -94,8 +94,8 @@ libc-threads-integration-tests SRCS call_once_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.include.threads libc.src.threads.call_once @@ -114,8 +114,8 @@ libc-threads-integration-tests SRCS cnd_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.include.threads libc.src.threads.cnd_init diff --git a/libc/test/integration/src/unistd/CMakeLists.txt b/libc/test/integration/src/unistd/CMakeLists.txt --- a/libc/test/integration/src/unistd/CMakeLists.txt +++ b/libc/test/integration/src/unistd/CMakeLists.txt @@ -7,8 +7,8 @@ unistd-integration-tests SRCS getcwd_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.include.errno libc.src.__support.CPP.string_view @@ -22,8 +22,8 @@ unistd-integration-tests SRCS fork_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc.include.errno libc.include.signal @@ -67,8 +67,8 @@ unistd-integration-tests SRCS execv_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc_execv_test_normal_exit libc_execv_test_signal_exit @@ -86,8 +86,8 @@ unistd-integration-tests SRCS execve_test.cpp - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS libc_execv_test_normal_exit libc_execv_test_signal_exit diff --git a/libc/test/integration/loader/CMakeLists.txt b/libc/test/integration/startup/CMakeLists.txt rename from libc/test/integration/loader/CMakeLists.txt rename to libc/test/integration/startup/CMakeLists.txt --- a/libc/test/integration/loader/CMakeLists.txt +++ b/libc/test/integration/startup/CMakeLists.txt @@ -1,17 +1,17 @@ -# A rule to add loader tests. When we have a complete loader, we should -# be able to use the add_libc_unittest rule or an extension of it. But, -# while the loader is getting built, we need to use a special rule like +# A rule to add startup system tests. When we have a complete startup system, +# we should be able to use the add_libc_unittest rule or an extension of it. +# But, while the system is being developed, we need to use a special rule like # this. -function(add_loader_test target_name) +function(add_startup_test target_name) if(NOT CMAKE_HOST_UNIX) message( WARNING - "Loader tests currently assume a POSIX/Unix like environment and " - "may not work on your platform.") + "Test for the startup system currently assume a POSIX/Unix like " + "environment and may not work on your platform.") endif() cmake_parse_arguments( - "ADD_LOADER_TEST" + "ADD_STARTUP_TEST" "" # No option arguments "SRC" # Single value arguments "DEPENDS;ARGS;ENV" # Multivalue arguments. @@ -22,7 +22,7 @@ add_executable( ${fq_target_name} EXCLUDE_FROM_ALL - ${ADD_LOADER_TEST_SRC} + ${ADD_STARTUP_TEST_SRC} ) set_target_properties(${fq_target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) @@ -35,8 +35,8 @@ ${LIBC_BUILD_DIR}/include ) - if(ADD_LOADER_TEST_DEPENDS) - get_fq_deps_list(fq_deps_list ${ADD_LOADER_TEST_DEPENDS}) + if(ADD_STARTUP_TEST_DEPENDS) + get_fq_deps_list(fq_deps_list ${ADD_STARTUP_TEST_DEPENDS}) add_dependencies(${fq_target_name} ${fq_deps_list}) get_object_files_for_test(link_object_files has_skipped_entrypoint_list ${fq_deps_list}) target_link_libraries(${fq_target_name} ${link_object_files}) @@ -51,11 +51,11 @@ add_custom_command( TARGET ${fq_target_name} POST_BUILD - COMMAND ${ADD_LOADER_TEST_ENV} $ ${ADD_LOADER_TEST_ARGS} + COMMAND ${ADD_STARTUP_TEST_ENV} $ ${ADD_STARTUP_TEST_ARGS} ) - add_dependencies(libc_loader_tests ${fq_target_name}) -endfunction(add_loader_test) + add_dependencies(libc_startup_tests ${fq_target_name}) +endfunction(add_startup_test) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS}) add_subdirectory(${LIBC_TARGET_OS}) diff --git a/libc/test/integration/startup/linux/CMakeLists.txt b/libc/test/integration/startup/linux/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/libc/test/integration/startup/linux/CMakeLists.txt @@ -0,0 +1,62 @@ +if(NOT (EXISTS ${LIBC_SOURCE_DIR}/startup/linux/${LIBC_TARGET_ARCHITECTURE})) + message("Skipping startup integration tests for target architecture ${LIBC_TARGET_ARCHITECTURE}.") + return() +endif() + +add_custom_target(libc-startup-tests) +add_dependencies(libc-integration-tests libc-startup-tests) + +add_integration_test( + startup_args_test + SUITE libc-startup-tests + STARTUP + libc.startup.linux.crt1 + SRCS + args_test.cpp + ARGS + 1 2 3 + ENV + FRANCE=Paris + GERMANY=Berlin +) + +add_integration_test( + startup_no_envp_test + SUITE libc-startup-tests + STARTUP + libc.startup.linux.crt1 + SRCS + main_without_envp.cpp +) + +add_integration_test( + startup_no_args_test + SUITE libc-startup-tests + STARTUP + libc.startup.linux.crt1 + SRCS + main_without_args.cpp +) + +add_integration_test( + startup_tls_test + SUITE libc-startup-tests + STARTUP + libc.startup.linux.crt1 + SRCS + tls_test.cpp + DEPENDS + libc.include.errno + libc.include.sys_mman + libc.src.errno.errno + libc.src.sys.mman.mmap +) + +add_integration_test( + init_fini_array_test + SUITE libc-startup-tests + STARTUP + libc.startup.linux.crt1 + SRCS + init_fini_array_test.cpp +) diff --git a/libc/test/integration/loader/linux/args_test.cpp b/libc/test/integration/startup/linux/args_test.cpp rename from libc/test/integration/loader/linux/args_test.cpp rename to libc/test/integration/startup/linux/args_test.cpp diff --git a/libc/test/integration/loader/linux/init_fini_array_test.cpp b/libc/test/integration/startup/linux/init_fini_array_test.cpp rename from libc/test/integration/loader/linux/init_fini_array_test.cpp rename to libc/test/integration/startup/linux/init_fini_array_test.cpp diff --git a/libc/test/integration/loader/linux/main_without_args.cpp b/libc/test/integration/startup/linux/main_without_args.cpp rename from libc/test/integration/loader/linux/main_without_args.cpp rename to libc/test/integration/startup/linux/main_without_args.cpp diff --git a/libc/test/integration/loader/linux/main_without_envp.cpp b/libc/test/integration/startup/linux/main_without_envp.cpp rename from libc/test/integration/loader/linux/main_without_envp.cpp rename to libc/test/integration/startup/linux/main_without_envp.cpp diff --git a/libc/test/integration/loader/linux/tls_test.cpp b/libc/test/integration/startup/linux/tls_test.cpp rename from libc/test/integration/loader/linux/tls_test.cpp rename to libc/test/integration/startup/linux/tls_test.cpp diff --git a/libc/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt --- a/libc/test/src/CMakeLists.txt +++ b/libc/test/src/CMakeLists.txt @@ -103,8 +103,8 @@ libc-api-test SRCS ${public_test} - LOADER - libc.loader.linux.crt1 + STARTUP + libc.startup.linux.crt1 DEPENDS ${api-test-entrypoints} )