Tutorial: testing libc in riscv32 qemu

Okay maybe I should re-check what I’m doing wrong, then. I was able to patch some of the add_custom_commands with an explicit CMAKE_CROSSCOMPILING_EMULATOR in libc/cmake/modules/LLVMLibCTestRules.cmake to get the tests running.

Also - I’m running the runtimes cross build / full cross build configuration FWIW.

Yeah… you’ll need https://github.com/llvm/llvm-project/pull/66565 to run the hermetic and integration tests.

(also [libc] Fix pthread_create_test for 32 bit systems by mikhailramalho · Pull Request #66564 · llvm/llvm-project · GitHub to fix one of the integration tests).

Right now the current state of the full cross-build configuration is that we can build libc, but the tests are failing with a linking error:

ld.lld: error: undefined symbol: __udivdi3
>>> referenced by str_to_integer.h:138 (/home/mgadelha/tools/llvm-project/libc/src/__support/str_to_integer.h:138)
>>>               parser.cpp.o:(__llvm_libc::StrToNumResult<int> __llvm_libc::internal::strtointeger<int>(char const*, int)) in archive projects/libc/test/integration/src/stdio/liblibc.test.integration.src.stdio.sprintf_size_test.libc.a
>>> referenced by UInt.h:415 (/home/mgadelha/tools/llvm-project/libc/src/__support/UInt.h:415)
>>>               converter.cpp.o:(__llvm_libc::cpp::BigInt<448u, false>::div_uint32_times_pow_2(unsigned int, unsigned int)) in archive projects/libc/test/integration/src/stdio/liblibc.test.integration.src.stdio.sprintf_size_test.libc.a
>>> referenced by UInt.h:417 (/home/mgadelha/tools/llvm-project/libc/src/__support/UInt.h:417)
>>>               converter.cpp.o:(__llvm_libc::cpp::BigInt<448u, false>::div_uint32_times_pow_2(unsigned int, unsigned int)) in archive projects/libc/test/integration/src/stdio/liblibc.test.integration.src.stdio.sprintf_size_test.libc.a
>>> referenced 2 more times

ld.lld: error: undefined symbol: __umoddi3
>>> referenced by UInt.h:415 (/home/mgadelha/tools/llvm-project/libc/src/__support/UInt.h:415)
>>>               converter.cpp.o:(__llvm_libc::cpp::BigInt<448u, false>::div_uint32_times_pow_2(unsigned int, unsigned int)) in archive projects/libc/test/integration/src/stdio/liblibc.test.integration.src.stdio.sprintf_size_test.libc.a
>>> referenced by UInt.h:417 (/home/mgadelha/tools/llvm-project/libc/src/__support/UInt.h:417)
>>>               converter.cpp.o:(__llvm_libc::cpp::BigInt<448u, false>::div_uint32_times_pow_2(unsigned int, unsigned int)) in archive projects/libc/test/integration/src/stdio/liblibc.test.integration.src.stdio.sprintf_size_test.libc.a
>>> referenced by UInt.h:418 (/home/mgadelha/tools/llvm-project/libc/src/__support/UInt.h:418)
>>>               converter.cpp.o:(__llvm_libc::cpp::BigInt<448u, false>::div_uint32_times_pow_2(unsigned int, unsigned int)) in archive projects/libc/test/integration/src/stdio/liblibc.test.integration.src.stdio.sprintf_size_test.libc.a
>>> referenced 1 more times
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

and

ld.lld: error: undefined symbol: operator delete(void*, std::align_val_t)
>>> referenced by copysignl_test.cpp:13 (/home/mgadelha/tools/llvm-project/libc/test/src/math/copysignl_test.cpp:13)
>>>               projects/libc/test/src/math/CMakeFiles/libc.test.src.math.copysignl_test.__hermetic__.__build__.dir/copysignl_test.cpp.o:(LlvmLibcCopySignTest_SpecialNumbers::~LlvmLibcCopySignTest_SpecialNumbers())
>>> referenced by copysignl_test.cpp:13 (/home/mgadelha/tools/llvm-project/libc/test/src/math/copysignl_test.cpp:13)
>>>               projects/libc/test/src/math/CMakeFiles/libc.test.src.math.copysignl_test.__hermetic__.__build__.dir/copysignl_test.cpp.o:(LlvmLibcCopySignTest_Range::~LlvmLibcCopySignTest_Range())
>>> referenced by FPMatcher.h:24 (/home/mgadelha/tools/llvm-project/libc/test/UnitTest/FPMatcher.h:24)
>>>               projects/libc/test/src/math/CMakeFiles/libc.test.src.math.copysignl_test.__hermetic__.__build__.dir/copysignl_test.cpp.o:(__llvm_libc::testing::FPMatcher<long double, (__llvm_libc::testing::TestCond)0>::~FPMatcher())