Skip to content

Commit 0adcbc0

Browse files
authored
[libc] Disable LlvmLibcTimespecGet.Monotonic for baremetal targets (#152290)
This test was caught by our hermetic testing downstream. The baremetal implementation does not support monotonic, so we disable it.
1 parent 2d7b55a commit 0adcbc0

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

libc/cmake/modules/LLVMLibCCompileOptionRules.cmake

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,31 @@ function(_get_compile_options_from_config output_var)
115115
set(${output_var} ${config_options} PARENT_SCOPE)
116116
endfunction(_get_compile_options_from_config)
117117

118+
function(_get_compile_options_from_arch output_var)
119+
# Set options that are not found in src/__support/macros/properties/architectures.h
120+
# and src/__support/macros/properties/os.h
121+
# TODO: we probably want to unify these at some point for consistency
122+
set(config_options "")
123+
124+
if (LIBC_TARGET_OS_IS_BAREMETAL)
125+
list(APPEND config_options "-DLIBC_TARGET_OS_IS_BAREMETAL")
126+
endif()
127+
if (LIBC_TARGET_OS_IS_GPU)
128+
list(APPEND config_options "-DLIBC_TARGET_OS_IS_GPU")
129+
endif()
130+
if (LIBC_TARGET_OS_IS_UEFI)
131+
list(APPEND config_options "-DLIBC_TARGET_OS_IS_UEFI")
132+
endif()
133+
134+
set(${output_var} ${config_options} PARENT_SCOPE)
135+
endfunction(_get_compile_options_from_arch)
136+
118137
function(_get_common_compile_options output_var flags)
119138
_get_compile_options_from_flags(compile_flags ${flags})
120139
_get_compile_options_from_config(config_flags)
140+
_get_compile_options_from_arch(arch_flags)
121141

122-
set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT} ${compile_flags} ${config_flags})
142+
set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT} ${compile_flags} ${config_flags} ${arch_flags})
123143

124144
if(LLVM_LIBC_COMPILER_IS_GCC_COMPATIBLE)
125145
list(APPEND compile_options "-fpie")

libc/cmake/modules/LLVMLibCTestRules.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
function(_get_common_test_compile_options output_var c_test flags)
22
_get_compile_options_from_flags(compile_flags ${flags})
33
_get_compile_options_from_config(config_flags)
4+
_get_compile_options_from_arch(arch_flags)
45

56
# Remove -fno-math-errno if it was added.
67
if(LIBC_ADD_FNO_MATH_ERRNO)
@@ -16,7 +17,8 @@ function(_get_common_test_compile_options output_var c_test flags)
1617
${LIBC_COMPILE_OPTIONS_DEFAULT}
1718
${LIBC_TEST_COMPILE_OPTIONS_DEFAULT}
1819
${compile_flags}
19-
${config_flags})
20+
${config_flags}
21+
${arch_flags})
2022

2123
if(LLVM_LIBC_COMPILER_IS_GCC_COMPATIBLE)
2224
list(APPEND compile_options "-fpie")

libc/test/src/time/timespec_get_test.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ TEST(LlvmLibcTimespecGet, Utc) {
2424
#endif
2525
}
2626

27+
// Baremetal implementation currently only supports TIME_UTC
28+
#ifndef LIBC_TARGET_OS_IS_BAREMETAL
2729
TEST(LlvmLibcTimespecGet, Monotonic) {
2830
timespec ts1, ts2;
2931
int result;
@@ -37,6 +39,7 @@ TEST(LlvmLibcTimespecGet, Monotonic) {
3739
ASSERT_GE(ts2.tv_nsec, ts1.tv_nsec);
3840
}
3941
}
42+
#endif
4043

4144
TEST(LlvmLibcTimespecGet, Unknown) {
4245
timespec ts;

0 commit comments

Comments
 (0)