[libc-commits] [libc] cab6ac2 - [libc] Add an optional `NAME` argument to `add_entrypoint_object` rule.
Siva Chandra Reddy via libc-commits
libc-commits at lists.llvm.org
Wed Feb 26 21:43:40 PST 2020
Author: Siva Chandra Reddy
Date: 2020-02-26T21:41:58-08:00
New Revision: cab6ac2612b5e4f22fca357a2c0740bc1b995e96
URL: https://github.com/llvm/llvm-project/commit/cab6ac2612b5e4f22fca357a2c0740bc1b995e96
DIFF: https://github.com/llvm/llvm-project/commit/cab6ac2612b5e4f22fca357a2c0740bc1b995e96.diff
LOG: [libc] Add an optional `NAME` argument to `add_entrypoint_object` rule.
This argument can be used to specify the entrypoint name if it is different
from the target name.
Reviewers: gchatelet, abrachet
Differential Revision: https://reviews.llvm.org/D74948
Added:
Modified:
libc/cmake/modules/LLVMLibCRules.cmake
Removed:
################################################################################
diff --git a/libc/cmake/modules/LLVMLibCRules.cmake b/libc/cmake/modules/LLVMLibCRules.cmake
index e807998d0221..3575c7b9db1a 100644
--- a/libc/cmake/modules/LLVMLibCRules.cmake
+++ b/libc/cmake/modules/LLVMLibCRules.cmake
@@ -101,6 +101,7 @@ set(ENTRYPOINT_OBJ_TARGET_TYPE "ENTRYPOINT_OBJ")
# add_entrypoint_object(
# <target_name>
# [REDIRECTED] # Specified if the entrypoint is redirected.
+# [NAME] <the C name of the entrypoint if
diff erent from target_name>
# SRCS <list of .cpp files>
# HDRS <list of .h files>
# DEPENDS <list of dependencies>
@@ -109,7 +110,7 @@ function(add_entrypoint_object target_name)
cmake_parse_arguments(
"ADD_ENTRYPOINT_OBJ"
"REDIRECTED" # Optional argument
- "" # No single value arguments
+ "NAME" # Single value arguments
"SRCS;HDRS;DEPENDS" # Multi value arguments
${ARGN}
)
@@ -120,6 +121,11 @@ function(add_entrypoint_object target_name)
message(FATAL_ERROR "`add_entrypoint_object` rule requires HDRS to be specified.")
endif()
+ set(entrypoint_name ${target_name})
+ if(ADD_ENTRYPOINT_OBJ_NAME)
+ set(entrypoint_name ${ADD_ENTRYPOINT_OBJ_NAME})
+ endif()
+
add_library(
"${target_name}_objects"
# We want an object library as the objects will eventually get packaged into
@@ -168,7 +174,7 @@ function(add_entrypoint_object target_name)
OUTPUT ${object_file}
# We llvm-objcopy here as GNU-binutils objcopy does not support the 'hidden' flag.
DEPENDS ${object_file_raw} ${llvm-objcopy}
- COMMAND $<TARGET_FILE:llvm-objcopy> --add-symbol "${target_name}=.llvm.libc.entrypoint.${target_name}:${alias_attributes}" ${object_file_raw} ${object_file}
+ COMMAND $<TARGET_FILE:llvm-objcopy> --add-symbol "${entrypoint_name}=.llvm.libc.entrypoint.${entrypoint_name}:${alias_attributes}" ${object_file_raw} ${object_file}
)
add_custom_target(
More information about the libc-commits
mailing list