Skip to content

Commit 0f5b4b4

Browse files
committed
hacks to make tests build/pass - DO NOT MERGE
These are all useful for making the build / tests pass but need some official resolution. * explicit CMAKE_CROSSCOMPILING_EMULATOR - normally this shouldn't be required * missing `wint_t` typedef. known/outstanding issue #63510 ? * workaround for missing `-nolibc` in the toolchain * adjust timeouts for LibcDeathTestExecutors - test under emulation takes longer
1 parent 1d83962 commit 0f5b4b4

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

libc/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ if(LLVM_LIBC_ENABLE_LINTING)
269269
endif()
270270
endif()
271271

272+
if(LIBC_TARGET_ARCHITECTURE STREQUAL "hexagon")
273+
add_compile_options(-mlong-calls)
274+
endif()
275+
276+
272277
option(LLVM_LIBC_INCLUDE_SCUDO "Include the SCUDO standalone as the allocator for LLVM libc" OFF)
273278
if(LLVM_LIBC_INCLUDE_SCUDO)
274279
if (NOT ("compiler-rt" IN_LIST LLVM_ENABLE_PROJECTS OR "compiler-rt" IN_LIST LLVM_ENABLE_RUNTIMES))

libc/cmake/modules/LLVMLibCTestRules.cmake

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ function(create_libc_unittest fq_target_name)
212212
if(NOT LIBC_UNITTEST_NO_RUN_POSTBUILD)
213213
add_custom_target(
214214
${fq_target_name}
215-
COMMAND ${fq_build_target_name}
215+
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} ${fq_build_target_name}
216216
COMMENT "Running unit test ${fq_target_name}"
217217
)
218218
endif()
@@ -538,9 +538,12 @@ function(add_integration_test test_name)
538538

539539
if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
540540
target_link_options(${fq_build_target_name} PRIVATE -nostdlib -static)
541+
elseif(LIBC_TARGET_ARCHITECTURE_IS_HEXAGON)
542+
target_link_options(${fq_build_target_name} PRIVATE -nostdlib -static -lclang_rt.builtins-hexagon)
541543
else()
542544
target_link_options(${fq_build_target_name} PRIVATE -nolibc -nostartfiles -nostdlib++ -static)
543545
endif()
546+
544547
target_link_libraries(
545548
${fq_build_target_name}
546549
# The NVIDIA 'nvlink' linker does not currently support static libraries.
@@ -571,7 +574,7 @@ function(add_integration_test test_name)
571574
$<TARGET_FILE:${fq_build_target_name}> ${INTEGRATION_TEST_ARGS})
572575
add_custom_target(
573576
${fq_target_name}
574-
COMMAND ${test_cmd}
577+
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} ${test_cmd}
575578
COMMAND_EXPAND_LISTS
576579
COMMENT "Running integration test ${fq_target_name}"
577580
)
@@ -737,7 +740,7 @@ function(add_libc_hermetic_test test_name)
737740
$<TARGET_FILE:${fq_build_target_name}> ${HERMETIC_TEST_ARGS})
738741
add_custom_target(
739742
${fq_target_name}
740-
COMMAND ${test_cmd}
743+
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} ${test_cmd}
741744
COMMAND_EXPAND_LISTS
742745
COMMENT "Running hermetic test ${fq_target_name}"
743746
${LIBC_HERMETIC_TEST_JOB_POOL}

libc/include/llvm-libc-types/wint_t.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
// Since __need_wint_t is defined, we get the definition of wint_t from the
1313
// standalone C header stddef.h. Also, because __need_wint_t is defined,
1414
// including stddef.h will pull only the type wint_t and nothing else.
15+
#if defined(__hexagon__)
16+
typedef int wint_t;
17+
#endif
18+
1519
#define __need_wint_t
1620
#include <stddef.h>
1721
#undef __need_wint_t

libc/test/UnitTest/LibcDeathTestExecutors.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace testing {
1919
bool Test::testProcessKilled(testutils::FunctionCaller *Func, int Signal,
2020
const char *LHSStr, const char *RHSStr,
2121
internal::Location Loc) {
22-
testutils::ProcessStatus Result = testutils::invoke_in_subprocess(Func, 500);
22+
testutils::ProcessStatus Result = testutils::invoke_in_subprocess(Func, 5000);
2323

2424
if (const char *error = Result.get_error()) {
2525
Ctx->markFail();
@@ -31,7 +31,7 @@ bool Test::testProcessKilled(testutils::FunctionCaller *Func, int Signal,
3131
if (Result.timed_out()) {
3232
Ctx->markFail();
3333
tlog << Loc;
34-
tlog << "Process timed out after " << 500 << " milliseconds.\n";
34+
tlog << "Process timed out after " << 5000 << " milliseconds.\n";
3535
return false;
3636
}
3737

@@ -62,7 +62,7 @@ bool Test::testProcessKilled(testutils::FunctionCaller *Func, int Signal,
6262
bool Test::testProcessExits(testutils::FunctionCaller *Func, int ExitCode,
6363
const char *LHSStr, const char *RHSStr,
6464
internal::Location Loc) {
65-
testutils::ProcessStatus Result = testutils::invoke_in_subprocess(Func, 500);
65+
testutils::ProcessStatus Result = testutils::invoke_in_subprocess(Func, 5000);
6666

6767
if (const char *error = Result.get_error()) {
6868
Ctx->markFail();
@@ -74,7 +74,7 @@ bool Test::testProcessExits(testutils::FunctionCaller *Func, int ExitCode,
7474
if (Result.timed_out()) {
7575
Ctx->markFail();
7676
tlog << Loc;
77-
tlog << "Process timed out after " << 500 << " milliseconds.\n";
77+
tlog << "Process timed out after " << 5000 << " milliseconds.\n";
7878
return false;
7979
}
8080

0 commit comments

Comments
 (0)