[libc-commits] [PATCH] D131752: [libc] Pack memory functions in the integration test libc.a files.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Fri Aug 12 00:02:59 PDT 2022

sivachandra created this revision.
sivachandra added a reviewer: michaelrj.
Herald added subscribers: libc-commits, ecnelises, tschuett, mgorny.
Herald added projects: libc-project, All.
sivachandra requested review of this revision.

  rG LLVM Github Monorepo



Index: libc/cmake/modules/LLVMLibCTestRules.cmake
--- libc/cmake/modules/LLVMLibCTestRules.cmake
+++ libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -432,6 +432,25 @@
   list(REMOVE_DUPLICATES fq_deps_list)
+  # We don't want memory functions to be dependencies on integration tests.
+  # For, memory functions should be tested using unittests. The main reason
+  # however is that compiler codegen can emit calls to memory functions. So,
+  # we add them explicitly to the integration test libc.a (see below). Adding,
+  # explicit deps on the memory functions can potentially cause duplicate
+  # symbol errors.
+  set(memory_funcs "bcmp;bzero;memcmp;memcpy;memmove;memset")
+  foreach(dep IN LISTS fq_deps_list)
+    get_target_property(name ${dep} ENTRYPOINT_NAME)
+    if(NOT name)
+      continue()
+    endif()
+    list(FIND memory_funcs ${name} loc)
+    if(${loc} GREATER_EQUAL 0)
+      message(FATAL_ERROR "Memory function ${name} cannot be a dependency "
+                          "for integration tests.")
+    endif()
+  endforeach()
   # TODO: Instead of gathering internal object files from entrypoints,
   # collect the object files with public names of entrypoints.
@@ -474,6 +493,16 @@
+    # We add the memory functions objects explicitly. Note that we
+    # are adding objects of the targets which contain the public
+    # C symbols. This is because compiler codegen can emit calls to
+    # the C memory functions.
+    $<TARGET_OBJECTS:libc.src.string.bcmp>
+    $<TARGET_OBJECTS:libc.src.string.bzero>
+    $<TARGET_OBJECTS:libc.src.string.memcmp>
+    $<TARGET_OBJECTS:libc.src.string.memcpy>
+    $<TARGET_OBJECTS:libc.src.string.memmove>
+    $<TARGET_OBJECTS:libc.src.string.memset>
   set_target_properties(${fq_libc_target_name} PROPERTIES ARCHIVE_OUTPUT_NAME c)
   set_target_properties(${fq_libc_target_name} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${sysroot_lib})

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131752.452091.patch
Type: text/x-patch
Size: 2125 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20220812/dae30aca/attachment.bin>

More information about the libc-commits mailing list