Skip to content

Commit 38228d5

Browse files
authored
[libc] Fix GPU tests not running after recent patches (#77248)
Summary: A previous patch added a dependency on the stack protectors, this was not built on the GPU targets so every test was disabled. It turns out that disabled tests still get targets so we need to specifically check if the it is in the target's set of entrypoints before we can use it. Another patch, because the build-bot was down, snuck in that prevented the new math tests from being run. The problem is that the `signal.h` header requires target specific definitions but was being used unconditionally. I have made changes that disable building this header if the file is not defined in the config. This required disbaling the signal_to_string utility, so that will simply be missing from targets that don't define it.
1 parent 92e2431 commit 38228d5

File tree

3 files changed

+54
-41
lines changed

3 files changed

+54
-41
lines changed

libc/cmake/modules/LLVMLibCTestRules.cmake

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,14 @@ function(add_integration_test test_name)
498498
libc.src.string.memcpy
499499
libc.src.string.memmove
500500
libc.src.string.memset
501-
# __stack_chk_fail should always be included to allow building libc with
502-
# stack protector.
503-
libc.src.compiler.__stack_chk_fail
504501
)
502+
503+
if(libc.src.compiler.__stack_chk_fail IN_LIST TARGET_LLVMLIBC_ENTRYPOINTS)
504+
# __stack_chk_fail should always be included if supported to allow building
505+
# libc with the stack protector enabled.
506+
list(APPEND fq_deps_list libc.src.compiler.__stack_chk_fail)
507+
endif()
508+
505509
list(REMOVE_DUPLICATES fq_deps_list)
506510

507511
# TODO: Instead of gathering internal object files from entrypoints,
@@ -668,12 +672,15 @@ function(add_libc_hermetic_test test_name)
668672
libc.src.string.memmove
669673
libc.src.string.memset
670674
libc.src.__support.StringUtil.error_to_string
671-
# __stack_chk_fail should always be included to allow building libc with
672-
# stack protector.
673-
libc.src.compiler.__stack_chk_fail
674675
)
675676

676-
if(TARGET libc.src.time.clock)
677+
if(libc.src.compiler.__stack_chk_fail IN_LIST TARGET_LLVMLIBC_ENTRYPOINTS)
678+
# __stack_chk_fail should always be included if supported to allow building
679+
# libc with the stack protector enabled.
680+
list(APPEND fq_deps_list libc.src.compiler.__stack_chk_fail)
681+
endif()
682+
683+
if(libc.src.time.clock IN_LIST TARGET_LLVMLIBC_ENTRYPOINTS)
677684
# We will link in the 'clock' implementation if it exists for test timing.
678685
list(APPEND fq_deps_list libc.src.time.clock)
679686
endif()

libc/include/CMakeLists.txt

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -184,24 +184,28 @@ add_gen_header(
184184
.llvm-libc-macros.generic_error_number_macros
185185
)
186186

187-
add_gen_header(
188-
signal
189-
DEF_FILE signal.h.def
190-
PARAMS
191-
platform_signal=../config/${LIBC_TARGET_OS}/signal.h.in
192-
GEN_HDR signal.h
193-
DATA_FILES
194-
../config/${LIBC_TARGET_OS}/signal.h.in
195-
DEPENDS
196-
.llvm-libc-macros.signal_macros
197-
.llvm-libc-types.sig_atomic_t
198-
.llvm-libc-types.sigset_t
199-
.llvm-libc-types.struct_sigaction
200-
.llvm-libc-types.union_sigval
201-
.llvm-libc-types.siginfo_t
202-
.llvm-libc-types.stack_t
203-
.llvm-libc-types.pid_t
204-
)
187+
if(EXISTS "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/signal.h.in")
188+
add_gen_header(
189+
signal
190+
DEF_FILE signal.h.def
191+
PARAMS
192+
platform_signal=${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/signal.h.in
193+
GEN_HDR signal.h
194+
DATA_FILES
195+
${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/signal.h.in
196+
DEPENDS
197+
.llvm-libc-macros.signal_macros
198+
.llvm-libc-types.sig_atomic_t
199+
.llvm-libc-types.sigset_t
200+
.llvm-libc-types.struct_sigaction
201+
.llvm-libc-types.union_sigval
202+
.llvm-libc-types.siginfo_t
203+
.llvm-libc-types.stack_t
204+
.llvm-libc-types.pid_t
205+
)
206+
else()
207+
message(STATUS "Skipping header signal.h as the target config is missing")
208+
endif()
205209

206210
add_gen_header(
207211
stdio

libc/src/__support/StringUtil/CMakeLists.txt

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,21 @@ add_object_library(
5151
libc.src.__support.integer_to_string
5252
)
5353

54-
add_object_library(
55-
signal_to_string
56-
HDRS
57-
signal_to_string.h
58-
SRCS
59-
signal_to_string.cpp
60-
DEPENDS
61-
.message_mapper
62-
.platform_signals
63-
libc.include.signal
64-
libc.src.__support.common
65-
libc.src.__support.CPP.span
66-
libc.src.__support.CPP.string_view
67-
libc.src.__support.CPP.stringstream
68-
libc.src.__support.integer_to_string
69-
)
54+
if(TARGET libc.include.signal)
55+
add_object_library(
56+
signal_to_string
57+
HDRS
58+
signal_to_string.h
59+
SRCS
60+
signal_to_string.cpp
61+
DEPENDS
62+
.message_mapper
63+
.platform_signals
64+
libc.include.signal
65+
libc.src.__support.common
66+
libc.src.__support.CPP.span
67+
libc.src.__support.CPP.string_view
68+
libc.src.__support.CPP.stringstream
69+
libc.src.__support.integer_to_string
70+
)
71+
endif()

0 commit comments

Comments
 (0)