164 changes: 110 additions & 54 deletions libc/cmake/modules/LLVMLibCRules.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include(LLVMLibCTargetNameUtils)

# A rule for self contained header file targets.
# This rule merely copies the header file from the current source directory to
Expand All @@ -12,7 +13,7 @@ function(add_header target_name)
"ADD_HEADER"
"" # No optional arguments
"HDR" # Single value arguments
"DEPENDS" # No multi value arguments
"DEPENDS"
${ARGN}
)
if(NOT ADD_HEADER_HDR)
Expand All @@ -28,15 +29,17 @@ function(add_header target_name)
DEPENDS ${src_file}
)

get_fq_target_name(${target_name} fq_target_name)
add_custom_target(
${target_name}
${fq_target_name}
DEPENDS ${dest_file}
)

if(ADD_HEADER_DEPENDS)
add_dependencies(
${target_name} ${ADD_HEADER_DEPENDS}
)
get_fq_deps_list(fq_deps_list ${ADD_HEADER_DEPENDS})
add_dependencies(
${fq_target_name} ${fq_deps_list}
)
endif()
endfunction(add_header)

Expand Down Expand Up @@ -88,9 +91,13 @@ function(add_gen_header target_name)
DEPENDS ${in_file} ${fq_data_files} ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td libc-hdrgen
)

get_fq_target_name(${target_name} fq_target_name)
if(ADD_GEN_HDR_DEPENDS)
get_fq_deps_list(fq_deps_list ${ADD_GEN_HDR_DEPENDS})
endif()
add_custom_target(
${target_name}
DEPENDS ${out_file} ${ADD_GEN_HDR_DEPENDS}
${fq_target_name}
DEPENDS ${out_file} ${fq_deps_list}
)
endfunction(add_gen_header)

Expand Down Expand Up @@ -118,32 +125,34 @@ function(add_object_library target_name)
message(FATAL_ERROR "'add_object_library' rule requires SRCS to be specified.")
endif()

get_fq_target_name(${target_name} fq_target_name)
add_library(
${target_name}
${fq_target_name}
OBJECT
${ADD_OBJECT_SRCS}
${ADD_OBJECT_HDRS}
)
target_include_directories(
${target_name}
${fq_target_name}
PRIVATE
"${LIBC_BUILD_DIR}/include;${LIBC_SOURCE_DIR};${LIBC_BUILD_DIR}"
)
if(ADD_OBJECT_COMPILE_OPTIONS)
target_compile_options(
${target_name}
${fq_target_name}
PRIVATE ${ADD_OBJECT_COMPILE_OPTIONS}
)
endif()

set(all_object_files $<TARGET_OBJECTS:${target_name}>)
set(all_object_files $<TARGET_OBJECTS:${fq_target_name}>)
if(ADD_OBJECT_DEPENDS)
get_fq_deps_list(fq_deps_list ${ADD_OBJECT_DEPENDS})
add_dependencies(
${target_name}
${ADD_OBJECT_DEPENDS}
${fq_target_name}
${fq_deps_list}
)
foreach(obj_target IN LISTS ADD_OBJECT_DEPENDS)
if(NOT TARGET ${obj_target})
foreach(obj_target IN LISTS fq_deps_list)
if(NOT TARGET obj_target)
# Not all targets will be visible. So, we will ignore those which aren't
# visible yet.
continue()
Expand All @@ -161,7 +170,7 @@ function(add_object_library target_name)
list(REMOVE_DUPLICATES all_object_files)

set_target_properties(
${target_name}
${fq_target_name}
PROPERTIES
"TARGET_TYPE" ${OBJECT_LIBRARY_TARGET_TYPE}
"OBJECT_FILES" "${all_object_files}"
Expand All @@ -174,7 +183,7 @@ set(ENTRYPOINT_OBJ_TARGET_TYPE "ENTRYPOINT_OBJ")
# Usage:
# add_entrypoint_object(
# <target_name>
# [REDIRECTED] # Specified if the entrypoint is redirected.
# [ALIAS|REDIRECTED] # Specified if the entrypoint is redirected or an alias.
# [NAME] <the C name of the entrypoint if different from target_name>
# SRCS <list of .cpp files>
# HDRS <list of .h files>
Expand All @@ -185,11 +194,48 @@ set(ENTRYPOINT_OBJ_TARGET_TYPE "ENTRYPOINT_OBJ")
function(add_entrypoint_object target_name)
cmake_parse_arguments(
"ADD_ENTRYPOINT_OBJ"
"REDIRECTED" # Optional argument
"ALIAS;REDIRECTED" # Optional argument
"NAME" # Single value arguments
"SRCS;HDRS;DEPENDS;COMPILE_OPTIONS" # Multi value arguments
${ARGN}
)

get_fq_target_name(${target_name} fq_target_name)

if(ADD_ENTRYPOINT_OBJ_ALIAS)
# Alias targets help one add aliases to other entrypoint object targets.
# One can use alias targets setup OS/machine independent entrypoint targets.
list(LENGTH ADD_ENTRYPOINT_OBJ_DEPENDS deps_size)
if(NOT (${deps_size} EQUAL "1"))
message(FATAL_ERROR "An entrypoint alias should have exactly one dependency.")
endif()
list(GET ADD_ENTRYPOINT_OBJ_DEPENDS 0 dep_target)
get_fq_dep_name(fq_dep_name ${dep_target})
if(NOT TARGET ${fq_dep_name})
message(WARNING "Aliasee ${fq_dep_name} for entrypoint alias ${target_name} missing; "
"Target ${target_name} will be ignored.")
return()
endif()

get_target_property(obj_type ${fq_dep_name} "TARGET_TYPE")
if((NOT obj_type) OR (NOT (${obj_type} STREQUAL ${ENTRYPOINT_OBJ_TARGET_TYPE})))
message(FATAL_ERROR "The aliasee of an entrypoint alias should be an entrypoint.")
endif()

add_custom_target(${fq_target_name})
add_dependencies(${fq_target_name} ${fq_dep_name})
get_target_property(all_objects ${fq_dep_name} "OBJECT_FILES")
get_target_property(all_objects_raw ${fq_dep_name} "OBJECT_FILES_RAW")
set_target_properties(
${fq_target_name}
PROPERTIES
"TARGET_TYPE" ${ENTRYPOINT_OBJ_TARGET_TYPE}
"OBJECT_FILES" "${all_objects}"
"OBJECT_FILES_RAW" "${all_objects_raw}"
)
return()
endif()

if(NOT ADD_ENTRYPOINT_OBJ_SRCS)
message(FATAL_ERROR "`add_entrypoint_object` rule requires SRCS to be specified.")
endif()
Expand All @@ -202,36 +248,39 @@ function(add_entrypoint_object target_name)
set(entrypoint_name ${ADD_ENTRYPOINT_OBJ_NAME})
endif()

set(objects_target_name "${fq_target_name}_objects")

add_library(
"${target_name}_objects"
${objects_target_name}
# We want an object library as the objects will eventually get packaged into
# an archive (like libc.a).
OBJECT
${ADD_ENTRYPOINT_OBJ_SRCS}
${ADD_ENTRYPOINT_OBJ_HDRS}
)
target_compile_options(
${target_name}_objects
${objects_target_name}
BEFORE
PRIVATE
-fpie ${LLVM_CXX_STD_default}
)
target_include_directories(
${target_name}_objects
${objects_target_name}
PRIVATE
"${LIBC_BUILD_DIR}/include;${LIBC_SOURCE_DIR};${LIBC_BUILD_DIR}"
)
add_dependencies(
${target_name}_objects
support_common_h
${objects_target_name}
libc.src.__support.common
)
set(dep_objects "")
if(ADD_ENTRYPOINT_OBJ_DEPENDS)
get_fq_deps_list(fq_deps_list ${ADD_ENTRYPOINT_OBJ_DEPENDS})
add_dependencies(
${target_name}_objects
${ADD_ENTRYPOINT_OBJ_DEPENDS}
${objects_target_name}
${fq_deps_list}
)
foreach(dep_target IN LISTS ADD_ENTRYPOINT_OBJ_DEPENDS)
foreach(dep_target IN LISTS fq_deps_list)
if(NOT TARGET ${dep_target})
# Not all targets will be visible. So, we will ignore those which aren't
# visible yet.
Expand All @@ -255,15 +304,15 @@ function(add_entrypoint_object target_name)

if(ADD_ENTRYPOINT_OBJ_COMPILE_OPTIONS)
target_compile_options(
${target_name}_objects
${objects_target_name}
PRIVATE ${ADD_ENTRYPOINT_OBJ_COMPILE_OPTIONS}
)
endif()

set(object_file_raw "${CMAKE_CURRENT_BINARY_DIR}/${target_name}_raw.o")
set(object_file "${CMAKE_CURRENT_BINARY_DIR}/${target_name}.o")

set(input_objects $<TARGET_OBJECTS:${target_name}_objects>)
set(input_objects $<TARGET_OBJECTS:${objects_target_name}>)
add_custom_command(
OUTPUT ${object_file_raw}
DEPENDS ${input_objects}
Expand All @@ -283,7 +332,7 @@ function(add_entrypoint_object target_name)
)

add_custom_target(
${target_name}
${fq_target_name}
ALL
DEPENDS ${object_file}
)
Expand All @@ -292,7 +341,7 @@ function(add_entrypoint_object target_name)
set(all_objects_raw ${object_file_raw})
list(APPEND all_objects_raw ${dep_objects})
set_target_properties(
${target_name}
${fq_target_name}
PROPERTIES
"TARGET_TYPE" ${ENTRYPOINT_OBJ_TARGET_TYPE}
"OBJECT_FILES" "${all_objects}"
Expand Down Expand Up @@ -432,7 +481,8 @@ function(add_libc_unittest target_name)
endif()

set(library_deps "")
foreach(dep IN LISTS LIBC_UNITTEST_DEPENDS)
get_fq_deps_list(fq_deps_list ${LIBC_UNITTEST_DEPENDS})
foreach(dep IN LISTS fq_deps_list)
get_target_property(dep_type ${dep} "TARGET_TYPE")
if(${dep_type} STREQUAL ${ENTRYPOINT_OBJ_TARGET_TYPE})
get_target_property(obj_files ${dep} "OBJECT_FILES_RAW")
Expand All @@ -446,14 +496,15 @@ function(add_libc_unittest target_name)
endforeach(dep)
list(REMOVE_DUPLICATES library_deps)

get_fq_target_name(${target_name} fq_target_name)
add_executable(
${target_name}
${fq_target_name}
EXCLUDE_FROM_ALL
${LIBC_UNITTEST_SRCS}
${LIBC_UNITTEST_HDRS}
)
target_include_directories(
${target_name}
${fq_target_name}
PRIVATE
${LIBC_SOURCE_DIR}
${LIBC_BUILD_DIR}
Expand All @@ -467,27 +518,27 @@ function(add_libc_unittest target_name)
endif()

if(library_deps)
target_link_libraries(${target_name} PRIVATE ${library_deps})
target_link_libraries(${fq_target_name} PRIVATE ${library_deps})
endif()

set_target_properties(${target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_target_properties(${fq_target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

add_dependencies(
${target_name}
${LIBC_UNITTEST_DEPENDS}
${fq_target_name}
${fq_deps_list}
)

target_link_libraries(${target_name} PRIVATE LibcUnitTest libc_test_utils)
target_link_libraries(${fq_target_name} PRIVATE LibcUnitTest libc_test_utils)

add_custom_command(
TARGET ${target_name}
TARGET ${fq_target_name}
POST_BUILD
COMMAND $<TARGET_FILE:${target_name}>
COMMAND $<TARGET_FILE:${fq_target_name}>
)
if(LIBC_UNITTEST_SUITE)
add_dependencies(
${LIBC_UNITTEST_SUITE}
${target_name}
${fq_target_name}
)
endif()
endfunction(add_libc_unittest)
Expand Down Expand Up @@ -520,8 +571,9 @@ function(add_libc_fuzzer target_name)
message(FATAL_ERROR "'add_libc_fuzzer' target requires a DEPENDS list of 'add_entrypoint_object' targets.")
endif()

get_fq_deps_list(fq_deps_list ${LIBC_FUZZER_DEPENDS})
set(library_deps "")
foreach(dep IN LISTS LIBC_FUZZER_DEPENDS)
foreach(dep IN LISTS fq_deps_list)
get_target_property(dep_type ${dep} "TARGET_TYPE")
if (dep_type)
string(COMPARE EQUAL ${dep_type} ${ENTRYPOINT_OBJ_TARGET_TYPE} dep_is_entrypoint)
Expand All @@ -535,31 +587,32 @@ function(add_libc_fuzzer target_name)
# to the list of library_deps.
endforeach(dep)

get_fq_target_name(${target_name} fq_target_name)
add_executable(
${target_name}
${fq_target_name}
EXCLUDE_FROM_ALL
${LIBC_FUZZER_SRCS}
${LIBC_FUZZER_HDRS}
)
target_include_directories(
${target_name}
${fq_target_name}
PRIVATE
${LIBC_SOURCE_DIR}
${LIBC_BUILD_DIR}
${LIBC_BUILD_DIR}/include
)

if(library_deps)
target_link_libraries(${target_name} PRIVATE ${library_deps})
target_link_libraries(${fq_target_name} PRIVATE ${library_deps})
endif()

set_target_properties(${target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_target_properties(${fq_target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

add_dependencies(
${target_name}
${LIBC_FUZZER_DEPENDS}
${fq_target_name}
${fq_deps_list}
)
add_dependencies(libc-fuzzer ${target_name})
add_dependencies(libc-fuzzer ${fq_target_name})
endfunction(add_libc_fuzzer)

# Rule to add header only libraries.
Expand All @@ -582,25 +635,28 @@ function(add_header_library target_name)
message(FATAL_ERROR "'add_header_library' target requires a HDRS list of .h files.")
endif()

get_fq_target_name(${target_name} fq_target_name)

set(FULL_HDR_PATHS "")
# TODO: Remove this foreach block when we can switch to the new
# version of the CMake policy CMP0076.
foreach(hdr IN LISTS ADD_HEADER_HDRS)
list(APPEND FULL_HDR_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/${hdr})
endforeach()

set(interface_target_name "${target_name}_header_library__")
set(interface_target_name "${fq_target_name}_header_library__")

add_library(${interface_target_name} INTERFACE)
target_sources(${interface_target_name} INTERFACE ${FULL_HDR_PATHS})
if(ADD_HEADER_DEPENDS)
add_dependencies(${interface_target_name} ${ADD_HEADER_DEPENDS})
get_fq_deps_list(fq_deps_list ${ADD_HEADER_DEPENDS})
add_dependencies(${interface_target_name} ${fq_deps_list})
endif()

add_custom_target(${target_name})
add_dependencies(${target_name} ${interface_target_name})
add_custom_target(${fq_target_name})
add_dependencies(${fq_target_name} ${interface_target_name})
set_target_properties(
${target_name}
${fq_target_name}
PROPERTIES
"TARGET_TYPE" "HDR_LIBRARY"
)
Expand Down
32 changes: 32 additions & 0 deletions libc/cmake/modules/LLVMLibCTargetNameUtils.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function(get_fq_target_name local_name target_name_var)
file(RELATIVE_PATH rel_path ${LIBC_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
string(REPLACE "/" "." fq_name "libc.${rel_path}.${local_name}")
set(${target_name_var} ${fq_name} PARENT_SCOPE)
endfunction(get_fq_target_name)

function(is_relative_target_name target_name output_var)
string(FIND ${target_name} "." dot_loc)
string(COMPARE EQUAL "0" ${dot_loc} is_relative)
set(${output_var} ${is_relative} PARENT_SCOPE)
endfunction(is_relative_target_name)

function(get_fq_dep_name fq_name name)
is_relative_target_name(${name} "is_relative")
if(is_relative)
# Skip over the first '.' character.
string(SUBSTRING ${name} 1 -1 local_name)
get_fq_target_name(${local_name} fully_qualified_name)
set(${fq_name} ${fully_qualified_name} PARENT_SCOPE)
else()
set(${fq_name} ${name} PARENT_SCOPE)
endif()
endfunction(get_fq_dep_name)

function(get_fq_deps_list output_list)
set(fq_dep_name_list "")
foreach(dep IN LISTS ARGN)
get_fq_dep_name(fq_dep_name ${dep})
list(APPEND fq_dep_name_list ${fq_dep_name})
endforeach(dep)
set(${output_list} ${fq_dep_name_list} PARENT_SCOPE)
endfunction(get_fq_deps_list)
2 changes: 1 addition & 1 deletion libc/config/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ add_gen_header(
DATA_FILES
${LIBC_TARGET_MACHINE}/syscall.h.inc
DEPENDS
support_common_h
libc.src.__support.common
)

add_subdirectory(x86_64)
6 changes: 3 additions & 3 deletions libc/fuzzing/string/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ add_libc_fuzzer(
SRCS
strcpy_fuzz.cpp
DEPENDS
strcpy
strlen
memcpy
libc.src.string.memcpy
libc.src.string.strcpy
libc.src.string.strlen
)
36 changes: 18 additions & 18 deletions libc/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,57 +6,57 @@ add_header(
)

add_header(
libc_posix_types_h
libc_posix_types
HDR
__posix-types.h
)

add_header(
ctype_h
ctype
HDR
ctype.h
DEPENDS
llvm_libc_common_h
.llvm_libc_common_h
)

add_gen_header(
math_h
math
DEF_FILE math.h.def
GEN_HDR math.h
DEPENDS
llvm_libc_common_h
.llvm_libc_common_h
)

add_gen_header(
assert_h
DEF_FILE assert.h.def
GEN_HDR assert.h
DEPENDS
llvm_libc_common_h
.llvm_libc_common_h
)

add_gen_header(
string_h
string
DEF_FILE string.h.def
GEN_HDR string.h
DEPENDS
llvm_libc_common_h
.llvm_libc_common_h
)

add_gen_header(
threads_h
threads
DEF_FILE threads.h.def
GEN_HDR threads.h
PARAMS
platform_threads=../config/${LIBC_TARGET_OS}/threads.h.in
DEPENDS
llvm_libc_common_h
.llvm_libc_common_h
DATA_FILES
../config/${LIBC_TARGET_OS}/threads.h.in
)

add_gen_header(
errno_h
errno
DEF_FILE errno.h.def
PARAMS
platform_errno=../config/${LIBC_TARGET_OS}/errno.h.in
Expand All @@ -66,7 +66,7 @@ add_gen_header(
)

add_gen_header(
signal_h
signal
DEF_FILE signal.h.def
PARAMS
platform_signal=../config/${LIBC_TARGET_OS}/signal.h.in
Expand All @@ -76,11 +76,11 @@ add_gen_header(
)

add_gen_header(
stdlib_h
stdlib
DEF_FILE stdlib.h.def
GEN_HDR stdlib.h
DEPENDS
llvm_libc_common_h
.llvm_libc_common_h
)

# TODO: Not all platforms will have a include/sys directory. Add the sys
Expand All @@ -89,16 +89,16 @@ add_gen_header(
file(MAKE_DIRECTORY "sys")

add_gen_header(
sys_mman_h
sys_mman
DEF_FILE sys/mman.h.def
GEN_HDR sys/mman.h
DEPENDS
libc_posix_types_h
llvm_libc_common_h
.libc_posix_types
.llvm_libc_common_h
)

add_gen_header(
sys_syscall_h
sys_syscall
DEF_FILE sys/syscall.h.def
GEN_HDR sys/syscall.h
PARAMS
Expand Down
50 changes: 25 additions & 25 deletions libc/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,45 @@ add_entrypoint_library(
llvmlibc
DEPENDS
# assert.h entrypoints
__assert_fail
libc.src.assert.__assert_fail

# errno.h entrypoints
__errno_location

# string.h entrypoints
strcpy
strcat
memcpy

# sys/mman.h entrypoints
mmap
munmap
libc.src.errno.__errno_location

# signal.h entrypoints
raise
sigaction
sigaddset
sigemptyset
sigprocmask
signal
libc.src.signal.raise
libc.src.signal.sigaction
libc.src.signal.sigaddset
libc.src.signal.sigemptyset
libc.src.signal.sigprocmask
libc.src.signal.signal

# stdlib.h entrypoints
_Exit
abort
libc.src.stdlib._Exit
libc.src.stdlib.abort

# string.h entrypoints
libc.src.string.memcpy
libc.src.string.strcpy
libc.src.string.strcat

# sys/mman.h entrypoints
libc.src.sys.mman.mmap
libc.src.sys.mman.munmap

# threads.h entrypoints
mtx_init
mtx_lock
mtx_unlock
thrd_create
thrd_join
libc.src.threads.mtx_init
libc.src.threads.mtx_lock
libc.src.threads.mtx_unlock
libc.src.threads.thrd_create
libc.src.threads.thrd_join
)

add_entrypoint_library(
llvmlibm
DEPENDS
# math.h entrypoints
round
libc.src.math.round
)

add_redirector_library(
Expand Down
44 changes: 37 additions & 7 deletions libc/loader/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
function(add_loader_object name)
cmake_parse_arguments(
"ADD_LOADER_OBJECT"
"" # No option arguments
"SRC" # Single value arguments
"ALIAS" # Option argument
"SRC" # Single value arguments
"DEPENDS;COMPILE_OPTIONS" # Multi value arguments
${ARGN}
)

get_fq_target_name(${name} fq_target_name)

if(ADD_LOADER_OBJECT_ALIAS)
list(LENGTH ADD_LOADER_OBJECT_DEPENDS deps_size)
if(NOT (${deps_size} EQUAL "1"))
message(FATAL_ERROR "A loader object alias should have exactly one dependency.")
endif()
list(GET ADD_LOADER_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(dep_objfile ${fq_dep_name} OBJECT_FILES)
set_target_properties(
${fq_target_name}
PROPERTIES
"TARGET_TYPE" "LOADER_OBJECT"
"OBJECT_FILES" ${dep_objfile}
)
return()
endif()

add_object_library(
${name}_object
${name}_objects
SRCS ${ADD_LOADER_OBJECT_SRC}
DEPENDS ${ADD_LOADER_OBJECT_DEPENDS}
COMPILE_OPTIONS ${ADD_LOADER_OBJECT_COMPILE_OPTIONS}
Expand All @@ -16,19 +39,26 @@ function(add_loader_object name)
set(objfile ${LIBC_BUILD_DIR}/lib/${name}.o)
add_custom_command(
OUTPUT ${objfile}
COMMAND cp $<TARGET_OBJECTS:${name}_object> ${objfile}
DEPENDS $<TARGET_OBJECTS:${name}_object>
COMMAND cp $<TARGET_OBJECTS:${fq_target_name}_objects> ${objfile}
DEPENDS $<TARGET_OBJECTS:${fq_target_name}_objects>
)
add_custom_target(
${name}
${fq_target_name}
DEPENDS ${objfile}
)
set_target_properties(
${name}
${fq_target_name}
PROPERTIES
"TARGET_TYPE" "LOADER_OBJECT"
"OBJECT_FILES" ${objfile}
)
endfunction()

add_subdirectory(${LIBC_TARGET_MACHINE})

add_loader_object(
crt1
ALIAS
DEPENDS
.${LIBC_TARGET_MACHINE}.crt1
)
4 changes: 2 additions & 2 deletions libc/loader/linux/x86_64/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ add_loader_object(
SRC
start.cpp
DEPENDS
linux_syscall_h
sys_syscall_h
libc.config.linux.linux_syscall_h
libc.include.sys_syscall
COMPILE_OPTIONS
-fno-omit-frame-pointer
-ffreestanding # To avoid compiler warnings about calling the main function.
Expand Down
2 changes: 1 addition & 1 deletion libc/src/__support/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_gen_header(
support_common_h
common
DEF_FILE common.h.def
PARAMS
platform_defs=../../config/${LIBC_TARGET_OS}/platfrom_defs.h.inc
Expand Down
6 changes: 3 additions & 3 deletions libc/src/assert/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ add_entrypoint_object(
HDRS
assert.h
DEPENDS
abort
# These two dependencies are temporary and should be replaced by fprintf
# later.
sys_syscall_h
linux_syscall_h
libc.config.linux.linux_syscall_h
libc.include.sys_syscall
libc.src.stdlib.abort
)
59 changes: 57 additions & 2 deletions libc/src/signal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,59 @@

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
add_subdirectory(${LIBC_TARGET_OS})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
endif()

add_entrypoint_object(
raise
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.raise
)

add_entrypoint_object(
sigaction
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.sigaction
)

add_entrypoint_object(
sigprocmask
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.sigprocmask
)

add_entrypoint_object(
sigemptyset
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.sigemptyset
)

add_entrypoint_object(
sigaddset
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.sigaddset
)

add_entrypoint_object(
signal
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.signal
)

add_entrypoint_object(
sigfillset
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.sigfillset
)

add_entrypoint_object(
sigdelset
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.sigdelset
)
54 changes: 27 additions & 27 deletions libc/src/signal/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ add_entrypoint_object(
signal.h
../raise.h
DEPENDS
sys_syscall_h
linux_syscall_h
signal_h
libc.config.linux.linux_syscall_h
libc.include.signal
libc.include.sys_syscall
)

add_object_library(
Expand All @@ -25,8 +25,8 @@ add_object_library(
# asan creates asan.module_ctor which uses stack space, causing warnings.
-fno-sanitize=address
DEPENDS
linux_syscall_h
sys_syscall_h
libc.config.linux.linux_syscall_h
libc.include.sys_syscall
)

add_entrypoint_object(
Expand All @@ -37,10 +37,10 @@ add_entrypoint_object(
signal.h
../sigaction.h
DEPENDS
__restore
sys_syscall_h
linux_syscall_h
signal_h
.__restore
libc.config.linux.linux_syscall_h
libc.include.signal
libc.include.sys_syscall
)

add_entrypoint_object(
Expand All @@ -51,10 +51,10 @@ add_entrypoint_object(
signal.h
../sigprocmask.h
DEPENDS
sys_syscall_h
linux_syscall_h
__errno_location
signal_h
libc.config.linux.linux_syscall_h
libc.include.signal
libc.include.sys_syscall
libc.src.errno.__errno_location
)

add_entrypoint_object(
Expand All @@ -65,9 +65,9 @@ add_entrypoint_object(
signal.h
../sigemptyset.h
DEPENDS
__errno_location
errno_h
signal_h
libc.include.errno
libc.include.signal
libc.src.errno.__errno_location
)

add_entrypoint_object(
Expand All @@ -78,9 +78,9 @@ add_entrypoint_object(
signal.h
../sigaddset.h
DEPENDS
__errno_location
errno_h
signal_h
libc.include.errno
libc.include.signal
libc.src.errno.__errno_location
)

add_entrypoint_object(
Expand All @@ -91,8 +91,8 @@ add_entrypoint_object(
signal.h
../signal.h
DEPENDS
sigaction
signal_h
.sigaction
libc.include.signal
)

add_entrypoint_object(
Expand All @@ -103,9 +103,9 @@ add_entrypoint_object(
signal.h
../sigfillset.h
DEPENDS
__errno_location
errno_h
signal_h
libc.include.errno
libc.include.signal
libc.src.errno.__errno_location
)

add_entrypoint_object(
Expand All @@ -116,7 +116,7 @@ add_entrypoint_object(
signal.h
../sigdelset.h
DEPENDS
__errno_location
errno_h
signal_h
libc.include.errno
libc.include.signal
libc.src.errno.__errno_location
)
15 changes: 11 additions & 4 deletions libc/src/stdlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
add_subdirectory(${LIBC_TARGET_OS})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
endif()

add_entrypoint_object(
_Exit
ALIAS
DEPENDS
.${LIBC_TARGET_OS}._Exit
)

add_entrypoint_object(
abort
SRCS
abort.cpp
HDRS
abort.h
DEPENDS
raise
_Exit
stdlib_h
libc.include.stdlib
libc.src.signal.raise
._Exit
)
6 changes: 3 additions & 3 deletions libc/src/stdlib/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ add_entrypoint_object(
HDRS
../_Exit.h
DEPENDS
sys_syscall_h
linux_syscall_h
stdlib_h
libc.include.sys_syscall
libc.config.linux.linux_syscall_h
libc.include.stdlib
)
25 changes: 13 additions & 12 deletions libc/src/string/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ add_entrypoint_object(
HDRS
strcat.h
DEPENDS
strcpy
string_h
strlen
.strcpy
.strlen
libc.include.string
)

add_entrypoint_object(
Expand All @@ -19,9 +19,9 @@ add_entrypoint_object(
HDRS
strcpy.h
DEPENDS
string_h
strlen
memcpy
.memcpy
.strlen
libc.include.string
)

add_entrypoint_object(
Expand All @@ -31,7 +31,7 @@ add_entrypoint_object(
HDRS
strlen.h
DEPENDS
string_h
libc.include.string
)

# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -79,18 +79,19 @@ function(add_memcpy memcpy_name)
SRCS ${LIBC_SOURCE_DIR}/src/string/memcpy.cpp
HDRS ${LIBC_SOURCE_DIR}/src/string/memcpy.h
DEPENDS
string_h
memory_utils
memcpy_arch_specific
.memory_utils.memory_utils
.memcpy_arch_specific
libc.include.string
COMPILE_OPTIONS
-fno-builtin-memcpy
${flags}
)
set_target_properties(${memcpy_name} PROPERTIES REQUIRE_CPU_FEATURES "${ADD_MEMCPY_REQUIRE}")
get_fq_target_name(${memcpy_name} fq_target_name)
set_target_properties(${fq_target_name} PROPERTIES REQUIRE_CPU_FEATURES "${ADD_MEMCPY_REQUIRE}")
get_property(all GLOBAL PROPERTY memcpy_implementations)
list(APPEND all ${memcpy_name})
set_property(GLOBAL PROPERTY memcpy_implementations "${all}")
endfunction()

add_subdirectory(${LIBC_MEMCPY_IMPL_FOLDER})
include(${LIBC_MEMCPY_IMPL_FOLDER}/CMakeLists.txt)
add_memcpy(memcpy MARCH native)
2 changes: 1 addition & 1 deletion libc/src/string/memory_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ add_header_library(
utils.h
memcpy_utils.h
DEPENDS
cacheline_size
.cacheline_size
)
16 changes: 15 additions & 1 deletion libc/src/sys/mman/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
add_subdirectory(${LIBC_TARGET_OS})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
endif()

add_entrypoint_object(
mmap
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.mmap
)

add_entrypoint_object(
munmap
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.munmap
)
16 changes: 8 additions & 8 deletions libc/src/sys/mman/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ add_entrypoint_object(
HDRS
../mmap.h
DEPENDS
sys_mman_h
sys_syscall_h
linux_syscall_h
__errno_location
libc.config.linux.linux_syscall_h
libc.include.sys_mman
libc.include.sys_syscall
libc.src.errno.__errno_location
)

add_entrypoint_object(
Expand All @@ -18,8 +18,8 @@ add_entrypoint_object(
HDRS
../munmap.h
DEPENDS
sys_mman_h
sys_syscall_h
linux_syscall_h
__errno_location
libc.config.linux.linux_syscall_h
libc.include.sys_mman
libc.include.sys_syscall
libc.src.errno.__errno_location
)
35 changes: 35 additions & 0 deletions libc/src/threads/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
add_subdirectory(${LIBC_TARGET_OS})
endif()

add_entrypoint_object(
thrd_create
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.thrd_create
)

add_entrypoint_object(
thrd_join
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.thrd_join
)

add_entrypoint_object(
mtx_init
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.mtx_init
)

add_entrypoint_object(
mtx_lock
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.mtx_lock
)

add_entrypoint_object(
mtx_unlock
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.mtx_unlock
)
50 changes: 25 additions & 25 deletions libc/src/threads/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ add_header_library(
HDRS
thread_utils.h
DEPENDS
thread_start_args_h
.thread_start_args_h
)

add_entrypoint_object(
Expand All @@ -23,14 +23,14 @@ add_entrypoint_object(
HDRS
../thrd_create.h
DEPENDS
errno_h
linux_syscall_h
mmap
support_common_h
sys_syscall_h
threads_h
threads_utils
__errno_location
.threads_utils
libc.config.linux.linux_syscall_h
libc.include.errno
libc.include.sys_syscall
libc.include.threads
libc.src.__support.common
libc.src.errno.__errno_location
libc.src.sys.mman.mmap
COMPILE_OPTIONS
-fno-omit-frame-pointer # This allows us to sniff out the thread args from
# the new thread's stack reliably.
Expand All @@ -43,12 +43,12 @@ add_entrypoint_object(
HDRS
../thrd_join.h
DEPENDS
linux_syscall_h
munmap
support_common_h
sys_syscall_h
threads_h
threads_utils
.threads_utils
libc.config.linux.linux_syscall_h
libc.include.sys_syscall
libc.include.threads
libc.src.sys.mman.mmap
libc.src.__support.common
)

add_entrypoint_object(
Expand All @@ -58,8 +58,8 @@ add_entrypoint_object(
HDRS
../mtx_init.h
DEPENDS
threads_h
threads_utils
.threads_utils
libc.include.threads
)

add_entrypoint_object(
Expand All @@ -69,10 +69,10 @@ add_entrypoint_object(
HDRS
../mtx_lock.h
DEPENDS
linux_syscall_h
sys_syscall_h
threads_h
threads_utils
.threads_utils
libc.config.linux.linux_syscall_h
libc.include.sys_syscall
libc.include.threads
)

add_entrypoint_object(
Expand All @@ -82,8 +82,8 @@ add_entrypoint_object(
HDRS
../mtx_unlock.h
DEPENDS
linux_syscall_h
sys_syscall_h
threads_h
threads_utils
.threads_utils
libc.config.linux.linux_syscall_h
libc.include.sys_syscall
libc.include.threads
)
3 changes: 1 addition & 2 deletions libc/test/config/linux/x86_64/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ add_libc_unittest(
SUITE libc_linux_tests
SRCS syscall_test.cpp
DEPENDS
linux_syscall_h
support_common_h
libc.config.linux.linux_syscall_h
)
22 changes: 12 additions & 10 deletions libc/test/loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ function(add_loader_test target_name)
${ARGN}
)

get_fq_target_name(${target_name} fq_target_name)
add_executable(
${target_name}
${fq_target_name}
EXCLUDE_FROM_ALL
${ADD_LOADER_TEST_SRC}
)

set_target_properties(${target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_target_properties(${fq_target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

set(dep_objects "")
if(ADD_LOADER_TEST_DEPENDS)
add_dependencies(${target_name} ${ADD_LOADER_TEST_DEPENDS})
foreach(dep IN LISTS ADD_LOADER_TEST_DEPENDS)
get_fq_deps_list(fq_deps_list ${ADD_LOADER_TEST_DEPENDS})
add_dependencies(${fq_target_name} ${fq_deps_list})
foreach(dep IN LISTS fq_deps_list)
get_target_property(objfile ${dep} "OBJECT_FILES")
if(NOT objfile)
message(
Expand All @@ -45,28 +47,28 @@ function(add_loader_test target_name)
endif()

target_include_directories(
${target_name}
${fq_target_name}
PRIVATE
${LIBC_SOURCE_DIR}
${LIBC_BUILD_DIR}
${LIBC_BUILD_DIR}/include
)

target_link_libraries(${target_name} ${dep_objects})
target_link_libraries(${fq_target_name} ${dep_objects})

target_link_options(
${target_name}
${fq_target_name}
BEFORE PRIVATE
-nostdlib
)

add_custom_command(
TARGET ${target_name}
TARGET ${fq_target_name}
POST_BUILD
COMMAND ${ADD_LOADER_TEST_ENV} $<TARGET_FILE:${target_name}> ${ADD_LOADER_TEST_ARGS}
COMMAND ${ADD_LOADER_TEST_ENV} $<TARGET_FILE:${fq_target_name}> ${ADD_LOADER_TEST_ARGS}
)

add_dependencies(libc_loader_tests ${target_name})
add_dependencies(libc_loader_tests ${fq_target_name})
endfunction(add_loader_test)

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
Expand Down
14 changes: 7 additions & 7 deletions libc/test/loader/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ add_loader_test(
SRC
args_test.cpp
DEPENDS
__assert_fail
_Exit
abort
crt1
raise
libc.loader.linux.crt1
libc.src.assert.__assert_fail
libc.src.signal.raise
libc.src.stdlib._Exit
libc.src.stdlib.abort
ARGS
1 2 3
ENV
Expand All @@ -20,13 +20,13 @@ add_loader_test(
SRC
main_without_envp.cpp
DEPENDS
crt1
libc.loader.linux.crt1
)

add_loader_test(
loader_no_args_test
SRC
main_without_args.cpp
DEPENDS
crt1
libc.loader.linux.crt1
)
8 changes: 4 additions & 4 deletions libc/test/src/assert/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ add_libc_unittest(
SRCS
assert_test.cpp
DEPENDS
__assert_fail
libc.src.assert.__assert_fail
# These are necessary for now because dependencies are not properly added.
abort
raise
_Exit
libc.src.signal.raise
libc.src.stdlib._Exit
libc.src.stdlib.abort
)
2 changes: 1 addition & 1 deletion libc/test/src/errno/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ add_libc_unittest(
SRCS
errno_test.cpp
DEPENDS
__errno_location
libc.src.errno.__errno_location
)
70 changes: 35 additions & 35 deletions libc/test/src/signal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ add_libc_unittest(
SRCS
raise_test.cpp
DEPENDS
raise
signal_h
libc.include.signal
libc.src.signal.raise
)

add_libc_unittest(
Expand All @@ -18,11 +18,11 @@ add_libc_unittest(
SRCS
sigaction_test.cpp
DEPENDS
sigaction
raise
signal_h
errno_h
__errno_location
libc.src.signal.sigaction
libc.src.signal.raise
libc.include.signal
libc.include.errno
libc.src.errno.__errno_location
)

add_libc_unittest(
Expand All @@ -32,12 +32,12 @@ add_libc_unittest(
SRCS
sigprocmask_test.cpp
DEPENDS
raise
sigprocmask
sigaddset
sigemptyset
signal_h
__errno_location
libc.include.signal
libc.src.errno.__errno_location
libc.src.signal.raise
libc.src.signal.sigprocmask
libc.src.signal.sigaddset
libc.src.signal.sigemptyset
)

add_libc_unittest(
Expand All @@ -47,9 +47,9 @@ add_libc_unittest(
SRCS
sigaddset_test.cpp
DEPENDS
sigaddset
signal_h
__errno_location
libc.include.signal
libc.src.errno.__errno_location
libc.src.signal.sigaddset
)

add_libc_unittest(
Expand All @@ -59,12 +59,12 @@ add_libc_unittest(
SRCS
signal_test.cpp
DEPENDS
signal
signal_h
sigaction
raise
__errno_location
errno_h
libc.include.errno
libc.include.signal
libc.src.errno.__errno_location
libc.src.signal.raise
libc.src.signal.sigaction
libc.src.signal.signal
)

add_libc_unittest(
Expand All @@ -74,12 +74,12 @@ add_libc_unittest(
SRCS
sigfillset_test.cpp
DEPENDS
sigfillset
sigprocmask
signal_h
raise
errno_h
__errno_location
libc.include.errno
libc.include.signal
libc.src.errno.__errno_location
libc.src.signal.raise
libc.src.signal.sigfillset
libc.src.signal.sigprocmask
)

add_libc_unittest(
Expand All @@ -89,11 +89,11 @@ add_libc_unittest(
SRCS
sigdelset_test.cpp
DEPENDS
sigdelset
sigfillset
sigprocmask
signal_h
raise
errno_h
__errno_location
libc.include.errno
libc.include.signal
libc.src.errno.__errno_location
libc.src.signal.raise
libc.src.signal.sigdelset
libc.src.signal.sigfillset
libc.src.signal.sigprocmask
)
14 changes: 7 additions & 7 deletions libc/test/src/stdlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ add_libc_unittest(
SRCS
_Exit_test.cpp
DEPENDS
stdlib_h
_Exit
libc.include.stdlib
libc.src.stdlib._Exit
)

add_libc_unittest(
Expand All @@ -18,9 +18,9 @@ add_libc_unittest(
SRCS
abort_test.cpp
DEPENDS
stdlib_h
signal_h
abort
_Exit
raise
libc.include.stdlib
libc.include.signal
libc.src.stdlib.abort
libc.src.stdlib._Exit
libc.src.signal.raise
)
24 changes: 12 additions & 12 deletions libc/test/src/string/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ add_libc_unittest(
SRCS
strcat_test.cpp
DEPENDS
strcat
strcpy
strlen
# TODO (sivachandra): remove redundant deps.
memcpy
# TODO (sivachandra): remove redundant deps.
libc.src.string.memcpy
libc.src.string.strcat
libc.src.string.strcpy
libc.src.string.strlen
)

add_libc_unittest(
Expand All @@ -23,10 +23,10 @@ add_libc_unittest(
SRCS
strcpy_test.cpp
DEPENDS
strcpy
strlen
# TODO (sivachandra): remove redundant deps.
memcpy
# TODO (sivachandra): remove redundant deps.
libc.src.string.memcpy
libc.src.string.strcpy
libc.src.string.strlen
)

add_libc_unittest(
Expand All @@ -36,13 +36,13 @@ add_libc_unittest(
SRCS
strlen_test.cpp
DEPENDS
strlen
libc.src.string.strlen
)

# Tests all implementations of memcpy that can run on the host.
get_property(memcpy_implementations GLOBAL PROPERTY memcpy_implementations)
foreach(memcpy_config_name IN LISTS memcpy_implementations)
get_target_property(require_cpu_features ${memcpy_config_name} REQUIRE_CPU_FEATURES)
get_target_property(require_cpu_features libc.src.string.${memcpy_config_name} REQUIRE_CPU_FEATURES)
host_supports(can_run "${require_cpu_features}")
if(can_run)
add_libc_unittest(
Expand All @@ -52,7 +52,7 @@ foreach(memcpy_config_name IN LISTS memcpy_implementations)
SRCS
memcpy_test.cpp
DEPENDS
${memcpy_config_name}
libc.src.string.${memcpy_config_name}
)
else()
message(STATUS "Skipping test for '${memcpy_config_name}' insufficient host cpu features")
Expand Down
6 changes: 3 additions & 3 deletions libc/test/src/string/memory_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ add_libc_unittest(
utils_test.cpp
memcpy_utils_test.cpp
DEPENDS
memory_utils
standalone_cpp
libc.src.string.memory_utils.memory_utils
libc.utils.CPP.standalone_cpp
)

target_compile_definitions(
utils_test
libc.test.src.string.memory_utils.utils_test
PRIVATE
LLVM_LIBC_MEMCPY_MONITOR=memcpy_monitor
)
10 changes: 5 additions & 5 deletions libc/test/src/sys/mman/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ add_libc_unittest(
SRCS
mmap_test.cpp
DEPENDS
errno_h
sys_mman_h
mmap
munmap
__errno_location
libc.include.errno
libc.include.sys_mman
libc.src.errno.__errno_location
libc.src.sys.mman.mmap
libc.src.sys.mman.munmap
)
30 changes: 15 additions & 15 deletions libc/test/src/threads/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ add_libc_unittest(
SRCS
thrd_test.cpp
DEPENDS
__errno_location
mmap
munmap
threads_h
thrd_create
thrd_join
libc.include.threads
libc.src.errno.__errno_location
libc.src.sys.mman.munmap
libc.src.sys.mman.mmap
libc.src.threads.thrd_create
libc.src.threads.thrd_join
)

add_libc_unittest(
Expand All @@ -22,13 +22,13 @@ add_libc_unittest(
SRCS
mtx_test.cpp
DEPENDS
__errno_location
mmap
munmap
mtx_init
mtx_lock
mtx_unlock
thrd_create
thrd_join
threads_h
libc.include.threads
libc.src.errno.__errno_location
libc.src.sys.mman.mmap
libc.src.sys.mman.munmap
libc.src.threads.mtx_init
libc.src.threads.mtx_lock
libc.src.threads.mtx_unlock
libc.src.threads.thrd_create
libc.src.threads.thrd_join
)
2 changes: 1 addition & 1 deletion libc/utils/UnitTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ add_llvm_library(
LINK_COMPONENTS Support
)
target_include_directories(LibcUnitTest PUBLIC ${LIBC_SOURCE_DIR})
add_dependencies(LibcUnitTest standalone_cpp)
add_dependencies(LibcUnitTest libc.utils.CPP.standalone_cpp)
target_link_libraries(LibcUnitTest PUBLIC libc_test_utils)