[libc-commits] [libc] 772e37f - [libc] Add ALIAS option to add_object_library rule.
Siva Chandra Reddy via libc-commits
libc-commits at lists.llvm.org
Mon Mar 6 14:11:47 PST 2023
Author: Siva Chandra Reddy
Date: 2023-03-06T22:11:33Z
New Revision: 772e37f8930724eaaa496ae62fabb8ae288b4086
URL: https://github.com/llvm/llvm-project/commit/772e37f8930724eaaa496ae62fabb8ae288b4086
DIFF: https://github.com/llvm/llvm-project/commit/772e37f8930724eaaa496ae62fabb8ae288b4086.diff
LOG: [libc] Add ALIAS option to add_object_library rule.
This ALIAS option is now used with threads/callonce target.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D145409
Added:
Modified:
libc/cmake/modules/LLVMLibCObjectRules.cmake
libc/src/__support/threads/CMakeLists.txt
libc/src/__support/threads/linux/CMakeLists.txt
Removed:
################################################################################
diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake
index 652e97ae27db9..9a522e35f6cec 100644
--- a/libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -198,18 +198,39 @@ endfunction()
# <target_name>
# HDRS <list of header files>
# SRCS <list of source files>
-# DEPENDS <list of dependencies>
+# [ALIAS] <If this object library is an alias for another object library.>
+# DEPENDS <list of dependencies; Should be a single item for ALIAS libraries>
# COMPILE_OPTIONS <optional list of special compile options for this target>
# FLAGS <optional list of flags>
function(create_object_library fq_target_name)
cmake_parse_arguments(
"ADD_OBJECT"
- "NO_GPU_BUNDLE" # No optional arguments
+ "ALIAS;NO_GPU_BUNDLE" # optional arguments
"CXX_STANDARD" # Single value arguments
"SRCS;HDRS;COMPILE_OPTIONS;DEPENDS;FLAGS" # Multivalue arguments
${ARGN}
)
+ get_fq_deps_list(fq_deps_list ${ADD_OBJECT_DEPENDS})
+
+ if(ADD_OBJECT_ALIAS)
+ if(ADD_OBJECT_SRCS OR ADD_OBJECT_HDRS)
+ message(FATAL_ERROR
+ "${fq_target_name}: object library alias cannot have SRCS and/or HDRS.")
+ endif()
+ list(LENGTH fq_deps_list depends_size)
+ if(NOT ${depends_size} EQUAL 1)
+ message(FATAL_ERROR
+ "${fq_targe_name}: object library alias should have exactly one DEPENDS.")
+ endif()
+ add_library(
+ ${fq_target_name}
+ ALIAS
+ ${fq_deps_list}
+ )
+ return()
+ endif()
+
if(NOT ADD_OBJECT_SRCS)
message(FATAL_ERROR "'add_object_library' rule requires SRCS to be specified.")
endif()
@@ -221,7 +242,6 @@ function(create_object_library fq_target_name)
set(internal_target_name ${fq_target_name})
endif()
- get_fq_deps_list(fq_deps_list ${ADD_OBJECT_DEPENDS})
_get_common_compile_options(
compile_options
"${ADD_OBJECT_FLAGS}"
diff --git a/libc/src/__support/threads/CMakeLists.txt b/libc/src/__support/threads/CMakeLists.txt
index e71f436fe1751..b77eb0de0f8c1 100644
--- a/libc/src/__support/threads/CMakeLists.txt
+++ b/libc/src/__support/threads/CMakeLists.txt
@@ -54,16 +54,11 @@ if(TARGET libc.src.__support.threads.${LIBC_TARGET_OS}.thread)
)
endif()
-if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS}/callonce.cpp)
+if(TARGET libc.src.__support.threads.${LIBC_TARGET_OS}.callonce)
add_object_library(
callonce
- SRCS
- ${LIBC_TARGET_OS}/callonce.cpp
- HDRS
- callonce.h
+ ALIAS
DEPENDS
- libc.include.sys_syscall
- libc.src.__support.CPP.atomic
- libc.src.__support.OSUtil.osutil
+ .${LIBC_TARGET_OS}.callonce
)
endif()
diff --git a/libc/src/__support/threads/linux/CMakeLists.txt b/libc/src/__support/threads/linux/CMakeLists.txt
index 62351da5e529a..642eead727726 100644
--- a/libc/src/__support/threads/linux/CMakeLists.txt
+++ b/libc/src/__support/threads/linux/CMakeLists.txt
@@ -40,3 +40,15 @@ add_object_library(
-fno-omit-frame-pointer # This allows us to sniff out the thread args from
# the new thread's stack reliably.
)
+
+add_object_library(
+ callonce
+ SRCS
+ callonce.cpp
+ HDRS
+ ../callonce.h
+ DEPENDS
+ libc.include.sys_syscall
+ libc.src.__support.CPP.atomic
+ libc.src.__support.OSUtil.osutil
+)
More information about the libc-commits
mailing list