Skip to content

Commit

Permalink
[libc] Small improvements to libc cmake
Browse files Browse the repository at this point in the history
This patch includes:
1. Better error message when cmake finds incompatible triple
2. Added missing header dependencies libc/include/CMakeLists.txt as per
   app.td
3. Removed unused $LLVM_LIBC_INCLUDE_DIRS cmake variable

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D145496
  • Loading branch information
mikhailramalho committed Mar 8, 2023
1 parent e510d0b commit 0ffea21
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 32 deletions.
4 changes: 2 additions & 2 deletions libc/cmake/modules/LLVMLibCArchitectures.cmake
Expand Up @@ -178,8 +178,8 @@ if(explicit_target_triple AND
set(LIBC_CROSSBUILD TRUE)
if(CMAKE_COMPILER_IS_GNUCXX)
message(FATAL_ERROR
"GCC target triple and the explicity specified target triple do "
"not match.")
"GCC target triple (${libc_compiler_triple}) and the explicity "
"specified target triple (${explicit_target_triple}) do not match.")
else()
list(APPEND
LIBC_COMPILE_OPTIONS_DEFAULT "--target=${explicit_target_triple}")
Expand Down
9 changes: 4 additions & 5 deletions libc/config/linux/api.td
Expand Up @@ -108,9 +108,6 @@ def SchedAPI : PublicAPI<"sched.h"> {

def SysMManAPI : PublicAPI<"sys/mman.h"> {
let Types = ["off_t", "size_t"];
let Macros = [
];

}

def SignalAPI : PublicAPI<"signal.h"> {
Expand Down Expand Up @@ -177,15 +174,17 @@ def DirentAPI : PublicAPI<"dirent.h"> {
}

def UniStdAPI : PublicAPI<"unistd.h"> {
let Types = ["__exec_argv_t", "__exec_envp_t", "off_t", "pid_t", "size_t", "ssize_t", "uid_t", "__getoptargv_t"];
let Types = ["__exec_argv_t", "__exec_envp_t", "off_t", "pid_t", "size_t",
"ssize_t", "uid_t", "__getoptargv_t"];
}

def SysRandomAPI : PublicAPI<"sys/random.h"> {
let Types = ["size_t", "ssize_t"];
}

def SysSelectAPI : PublicAPI<"sys/select.h"> {
let Types = ["fd_set", "sigset_t", "suseconds_t", "time_t", "struct timespec", "struct timeval"];
let Types = ["fd_set", "sigset_t", "suseconds_t", "time_t", "struct timespec",
"struct timeval"];
}

def SysResourceAPI : PublicAPI<"sys/resource.h"> {
Expand Down
57 changes: 35 additions & 22 deletions libc/include/CMakeLists.txt
Expand Up @@ -24,8 +24,8 @@ add_gen_header(
GEN_HDR dirent.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.DIR
.llvm-libc-types.ino_t
.llvm-libc-types.DIR
.llvm-libc-types.struct_dirent
)

Expand Down Expand Up @@ -124,12 +124,12 @@ add_gen_header(
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.time_macros
.llvm-libc-types.time_t
.llvm-libc-types.clock_t
.llvm-libc-types.clockid_t
.llvm-libc-types.time_t
.llvm-libc-types.struct_tm
.llvm-libc-types.struct_timespec
.llvm-libc-types.struct_timeval
.llvm-libc-types.clockid_t
)

add_gen_header(
Expand All @@ -139,11 +139,11 @@ add_gen_header(
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.__call_once_func_t
.llvm-libc-types.once_flag
.llvm-libc-types.cnd_t
.llvm-libc-types.mtx_t
.llvm-libc-types.once_flag
.llvm-libc-types.thrd_start_t
.llvm-libc-types.thrd_t
.llvm-libc-types.thrd_start_t
.llvm-libc-types.tss_t
.llvm-libc-types.tss_dtor_t
)
Expand All @@ -166,11 +166,12 @@ add_gen_header(
../config/${LIBC_TARGET_OS}/signal.h.in
DEPENDS
.llvm-libc-macros.signal_macros
.llvm-libc-types.__sighandler_t
.llvm-libc-types.sigset_t
.llvm-libc-types.sig_atomic_t
.llvm-libc-types.stack_t
.llvm-libc-types.sigset_t
.llvm-libc-types.struct_sigaction
.llvm-libc-types.union_sigval
.llvm-libc-types.siginfo_t
.llvm-libc-types.stack_t
.llvm-libc-types.pid_t
)

Expand All @@ -182,10 +183,9 @@ add_gen_header(
.llvm_libc_common_h
.llvm-libc-macros.file_seek_macros
.llvm-libc-macros.stdio_macros
.llvm-libc-types.cookie_io_functions_t
.llvm-libc-types.FILE
.llvm-libc-types.off_t
.llvm-libc-types.size_t
.llvm-libc-types.FILE
.llvm-libc-types.cookie_io_functions_t
)

add_gen_header(
Expand All @@ -195,12 +195,12 @@ add_gen_header(
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.stdlib_macros
.llvm-libc-types.__bsearchcompare_t
.llvm-libc-types.__qsortcompare_t
.llvm-libc-types.div_t
.llvm-libc-types.ldiv_t
.llvm-libc-types.lldiv_t
.llvm-libc-types.size_t
.llvm-libc-types.__bsearchcompare_t
.llvm-libc-types.__qsortcompare_t
.llvm-libc-types.__atexithandler_t
)

Expand Down Expand Up @@ -229,15 +229,15 @@ add_gen_header(
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.__atfork_callback_t
.llvm-libc-types.__pthread_once_func_t
.llvm-libc-types.__pthread_start_t
.llvm-libc-types.__pthread_tss_dtor_t
.llvm-libc-types.pthread_attr_t
.llvm-libc-types.pthread_key_t
.llvm-libc-types.pthread_mutex_t
.llvm-libc-types.pthread_mutexattr_t
.llvm-libc-types.pthread_once_t
.llvm-libc-types.__pthread_once_func_t
.llvm-libc-types.pthread_t
.llvm-libc-types.pthread_key_t
.llvm-libc-types.pthread_once_t
)

add_gen_header(
Expand All @@ -246,8 +246,10 @@ add_gen_header(
GEN_HDR sched.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.cpu_set_t
.llvm-libc-macros.sched_macros
.llvm-libc-types.pid_t
.llvm-libc-types.size_t
.llvm-libc-types.cpu_set_t
)

add_gen_header(
Expand Down Expand Up @@ -291,9 +293,9 @@ add_gen_header(
GEN_HDR sys/mman.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.sys_mman_macros
.llvm-libc-types.off_t
.llvm-libc-types.ssize_t
.llvm-libc-macros.sys_mman_macros
)

add_gen_header(
Expand All @@ -311,8 +313,8 @@ add_gen_header(
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.sys_random_macros
.llvm-libc-types.ssize_t
.llvm-libc-types.size_t
.llvm-libc-types.ssize_t
)

add_gen_header(
Expand All @@ -334,6 +336,16 @@ add_gen_header(
.llvm_libc_common_h
.llvm-libc-macros.sys_stat_macros
.llvm-libc-types.mode_t
.llvm-libc-types.dev_t
.llvm-libc-types.ino_t
.llvm-libc-types.nlink_t
.llvm-libc-types.uid_t
.llvm-libc-types.gid_t
.llvm-libc-types.off_t
.llvm-libc-types.struct_timespec
.llvm-libc-types.struct_timeval
.llvm-libc-types.blksize_t
.llvm-libc-types.blkcnt_t
.llvm-libc-types.struct_stat
)

Expand All @@ -346,11 +358,10 @@ add_gen_header(
.llvm-libc-macros.sys_select_macros
.llvm-libc-types.fd_set
.llvm-libc-types.sigset_t
.llvm-libc-types.struct_timespec
.llvm-libc-types.struct_timeval
.llvm-libc-types.suseconds_t
.llvm-libc-types.time_t
.llvm-libc-types.ssize_t
.llvm-libc-types.struct_timespec
.llvm-libc-types.struct_timeval
)

add_gen_header(
Expand All @@ -360,6 +371,7 @@ add_gen_header(
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.off_t
.llvm-libc-types.size_t
.llvm-libc-types.ssize_t
)

Expand Down Expand Up @@ -449,6 +461,7 @@ add_gen_header(
.llvm_libc_common_h
.llvm-libc-macros.termios_macros
.llvm-libc-types.cc_t
.llvm-libc-types.pid_t
.llvm-libc-types.speed_t
.llvm-libc-types.struct_termios
.llvm-libc-types.tcflag_t
Expand Down
2 changes: 1 addition & 1 deletion libc/src/stdlib/linux/CMakeLists.txt
Expand Up @@ -19,5 +19,5 @@ add_entrypoint_object(
DEPENDS
libc.include.stdlib
libc.src.signal.raise
._Exit
libc.src.stdlib._Exit
)
2 changes: 1 addition & 1 deletion libc/utils/HdrGen/CMakeLists.txt
Expand Up @@ -14,7 +14,7 @@ add_tablegen(libc-hdrgen LIBC
PublicAPICommand.h
)

target_include_directories(libc-hdrgen PRIVATE ${LIBC_SOURCE_DIR} ${LLVM_LIBC_INCLUDE_DIRS})
target_include_directories(libc-hdrgen PRIVATE ${LIBC_SOURCE_DIR})
target_link_libraries(libc-hdrgen PRIVATE LibcTableGenUtil)

add_subdirectory(PrototypeTestGen)
2 changes: 1 addition & 1 deletion libc/utils/LibcTableGenUtil/CMakeLists.txt
Expand Up @@ -4,4 +4,4 @@ add_llvm_library(
APIIndexer.h
LINK_COMPONENTS Support TableGen
)
target_include_directories(LibcTableGenUtil PUBLIC ${LIBC_SOURCE_DIR} ${LLVM_LIBC_INCLUDE_DIRS})
target_include_directories(LibcTableGenUtil PUBLIC ${LIBC_SOURCE_DIR})

0 comments on commit 0ffea21

Please sign in to comment.