[libc-commits] [libc] 9a07780 - [libc][NFC] Rename "loader" to "startup".

Siva Chandra Reddy via libc-commits libc-commits at lists.llvm.org
Thu Dec 15 11:54:31 PST 2022


Author: Siva Chandra Reddy
Date: 2022-12-15T19:54:21Z
New Revision: 9a07780687ab5afd9e1bafe8a7c99f512eb98ce8

URL: https://github.com/llvm/llvm-project/commit/9a07780687ab5afd9e1bafe8a7c99f512eb98ce8
DIFF: https://github.com/llvm/llvm-project/commit/9a07780687ab5afd9e1bafe8a7c99f512eb98ce8.diff

LOG: [libc][NFC] Rename "loader" to "startup".

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D140049

Added: 
    libc/startup/CMakeLists.txt
    libc/startup/linux/CMakeLists.txt
    libc/startup/linux/aarch64/CMakeLists.txt
    libc/startup/linux/aarch64/start.cpp
    libc/startup/linux/crti.cpp
    libc/startup/linux/crtn.cpp
    libc/startup/linux/x86_64/CMakeLists.txt
    libc/startup/linux/x86_64/start.cpp
    libc/test/integration/startup/CMakeLists.txt
    libc/test/integration/startup/linux/CMakeLists.txt
    libc/test/integration/startup/linux/args_test.cpp
    libc/test/integration/startup/linux/init_fini_array_test.cpp
    libc/test/integration/startup/linux/main_without_args.cpp
    libc/test/integration/startup/linux/main_without_envp.cpp
    libc/test/integration/startup/linux/tls_test.cpp

Modified: 
    libc/CMakeLists.txt
    libc/cmake/modules/LLVMLibCTestRules.cmake
    libc/docs/source_tree_layout.rst
    libc/test/integration/CMakeLists.txt
    libc/test/integration/scudo/CMakeLists.txt
    libc/test/integration/src/__support/threads/CMakeLists.txt
    libc/test/integration/src/pthread/CMakeLists.txt
    libc/test/integration/src/spawn/CMakeLists.txt
    libc/test/integration/src/stdio/CMakeLists.txt
    libc/test/integration/src/stdlib/CMakeLists.txt
    libc/test/integration/src/threads/CMakeLists.txt
    libc/test/integration/src/unistd/CMakeLists.txt
    libc/test/src/CMakeLists.txt

Removed: 
    libc/loader/CMakeLists.txt
    libc/loader/linux/CMakeLists.txt
    libc/loader/linux/aarch64/CMakeLists.txt
    libc/loader/linux/aarch64/start.cpp
    libc/loader/linux/crti.cpp
    libc/loader/linux/crtn.cpp
    libc/loader/linux/x86_64/CMakeLists.txt
    libc/loader/linux/x86_64/start.cpp
    libc/test/integration/loader/CMakeLists.txt
    libc/test/integration/loader/linux/CMakeLists.txt
    libc/test/integration/loader/linux/args_test.cpp
    libc/test/integration/loader/linux/init_fini_array_test.cpp
    libc/test/integration/loader/linux/main_without_args.cpp
    libc/test/integration/loader/linux/main_without_envp.cpp
    libc/test/integration/loader/linux/tls_test.cpp


################################################################################
diff  --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index e4ccf0ffdc34..909f5bf618e3 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -197,9 +197,9 @@ add_subdirectory(src)
 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
index bc2f85e928a1..00974c86a08d 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -106,7 +106,7 @@ function(create_libc_unittest fq_target_name)
     # 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 @@ function(add_libc_fuzzer target_name)
 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 @@ endfunction(add_libc_fuzzer)
 #     SUITE <the suite to which the test should belong>
 #     SRCS <src1.cpp> [src2.cpp ...]
 #     HDRS [hdr1.cpp ...]
-#     LOADER <fully qualified loader target name>
+#     STARTUP <fully qualified startup system target name>
 #     DEPENDS <list of entrypoint or other object targets>
 #     ARGS <list of command line arguments to be passed to the test>
 #     ENV <list of environment variables to set before running the test>
 #     COMPILE_OPTIONS <list of special compile options for this target>
 #   )
 #
-# 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 @@ function(add_integration_test test_name)
   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 @@ function(add_integration_test test_name)
   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 @@ function(add_integration_test test_name)
   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 $<TARGET_PROPERTY:libc_integration_test_dummy,ARCHIVE_OUTPUT_DIRECTORY>/lib$<TARGET_PROPERTY:libc_integration_test_dummy,ARCHIVE_OUTPUT_NAME>.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 @@ function(add_integration_test test_name)
   # 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
index a0565cb71308..cd328e769acc 100644
--- a/libc/docs/source_tree_layout.rst
+++ b/libc/docs/source_tree_layout.rst
@@ -13,7 +13,7 @@ directories::
         - fuzzing
         - include
         - lib
-        - loader
+        - startup
         - src
         - test
         - utils
@@ -58,11 +58,11 @@ The ``lib`` directory
 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
similarity index 100%
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
similarity index 64%
rename from libc/loader/linux/CMakeLists.txt
rename to libc/startup/linux/CMakeLists.txt
index 92ff8965b206..f043ec54950a 100644
--- 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 @@ function(add_loader_object name)
   )
 
   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 @@ function(add_loader_object name)
 
   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 @@ function(add_loader_object name)
     ${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_loader_object(
 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
similarity index 95%
rename from libc/loader/linux/aarch64/CMakeLists.txt
rename to libc/startup/linux/aarch64/CMakeLists.txt
index 054df0b1fa21..14d6409af6cc 100644
--- 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
similarity index 100%
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
similarity index 100%
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
similarity index 100%
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
similarity index 96%
rename from libc/loader/linux/x86_64/CMakeLists.txt
rename to libc/startup/linux/x86_64/CMakeLists.txt
index f62ad0ad8326..75c8296ee9e6 100644
--- 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
similarity index 100%
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
index 675f4c47c878..f891ed3fede9 100644
--- a/libc/test/integration/CMakeLists.txt
+++ b/libc/test/integration/CMakeLists.txt
@@ -15,6 +15,6 @@ set_target_properties(libc_integration_test_dummy
       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
index 5138f7a54748..000000000000
--- 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
index 2e90c8406e5f..ca3e2c83e513 100644
--- a/libc/test/integration/scudo/CMakeLists.txt
+++ b/libc/test/integration/scudo/CMakeLists.txt
@@ -5,9 +5,9 @@ endif()
 # 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
index 48e0e2c0eb0f..592c0b31261f 100644
--- a/libc/test/integration/src/__support/threads/CMakeLists.txt
+++ b/libc/test/integration/src/__support/threads/CMakeLists.txt
@@ -11,8 +11,8 @@ add_integration_test(
     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 @@ add_integration_test(
     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
index 7215893d0869..a6a1690f609b 100644
--- a/libc/test/integration/src/pthread/CMakeLists.txt
+++ b/libc/test/integration/src/pthread/CMakeLists.txt
@@ -6,8 +6,8 @@ add_integration_test(
     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 @@ add_integration_test(
     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 @@ add_integration_test(
     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 @@ add_integration_test(
     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 @@ add_integration_test(
     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 @@ add_integration_test(
     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 @@ add_integration_test(
     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
index dd0e8a383d7b..d6307cb2ad88 100644
--- a/libc/test/integration/src/spawn/CMakeLists.txt
+++ b/libc/test/integration/src/spawn/CMakeLists.txt
@@ -26,8 +26,8 @@ add_integration_test(
     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
index f0de50f019da..ed9af297257b 100644
--- a/libc/test/integration/src/stdio/CMakeLists.txt
+++ b/libc/test/integration/src/stdio/CMakeLists.txt
@@ -9,8 +9,8 @@ add_integration_test(
     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 @@ add_integration_test(
     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
index 01f5f6a4f1b0..1f600f8dfa5c 100644
--- a/libc/test/integration/src/stdlib/CMakeLists.txt
+++ b/libc/test/integration/src/stdlib/CMakeLists.txt
@@ -7,8 +7,8 @@ add_integration_test(
     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
index 4dc82da58e05..5f9e49ed5a8d 100644
--- a/libc/test/integration/src/threads/CMakeLists.txt
+++ b/libc/test/integration/src/threads/CMakeLists.txt
@@ -6,8 +6,8 @@ add_integration_test(
     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 @@ add_integration_test(
     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 @@ add_integration_test(
     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 @@ add_integration_test(
     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 @@ add_integration_test(
     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 @@ add_integration_test(
     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 @@ add_integration_test(
     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
index 7631f5bd4a3a..1abe01697ab5 100644
--- a/libc/test/integration/src/unistd/CMakeLists.txt
+++ b/libc/test/integration/src/unistd/CMakeLists.txt
@@ -7,8 +7,8 @@ add_integration_test(
     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 @@ add_integration_test(
     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 @@ add_integration_test(
     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 @@ add_integration_test(
     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
similarity index 59%
rename from libc/test/integration/loader/CMakeLists.txt
rename to libc/test/integration/startup/CMakeLists.txt
index 49f7eb71a99f..fb5d6bc787cc 100644
--- 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 @@ function(add_loader_test target_name)
   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 @@ function(add_loader_test target_name)
       ${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 @@ function(add_loader_test target_name)
   add_custom_command(
     TARGET ${fq_target_name}
     POST_BUILD
-    COMMAND ${ADD_LOADER_TEST_ENV} $<TARGET_FILE:${fq_target_name}> ${ADD_LOADER_TEST_ARGS}
+    COMMAND ${ADD_STARTUP_TEST_ENV} $<TARGET_FILE:${fq_target_name}> ${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
index 000000000000..675e8e3d1540
--- /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
similarity index 100%
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
similarity index 100%
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
similarity index 100%
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
similarity index 100%
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
similarity index 100%
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
index 426ab66a54c1..6a9ab8ff3ed8 100644
--- a/libc/test/src/CMakeLists.txt
+++ b/libc/test/src/CMakeLists.txt
@@ -103,8 +103,8 @@ add_integration_test(
     libc-api-test
   SRCS
     ${public_test}
-  LOADER
-    libc.loader.linux.crt1
+  STARTUP
+    libc.startup.linux.crt1
   DEPENDS
     ${api-test-entrypoints}
 )


        


More information about the libc-commits mailing list