This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add a convenience CMake function `add_unittest_framework_library`.
ClosedPublic

Authored by sivachandra on May 16 2023, 2:26 PM.

Details

Summary

This function is used to add unit test and hermetic test framework libraries.
It avoids the duplicated code to add compile options to each every test
framework libraries.

Diff Detail

Event Timeline

sivachandra created this revision.May 16 2023, 2:26 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 16 2023, 2:26 PM
sivachandra requested review of this revision.May 16 2023, 2:26 PM

I got the following error when trying to build locally

CMake Error at /home/jhuber/Documents/llvm/llvm-project/libc/test/UnitTest/CMakeLists.txt:10 (message):
  'add_unittest_framework_library' requires SRCS; for header only libraries,
  use 'add_header_library'
Call Stack (most recent call first):
  /home/jhuber/Documents/llvm/llvm-project/libc/test/UnitTest/CMakeLists.txt:78 (add_unittest_framework_library)

Fix the sources of LibcDeathTestExecutors library.

I got the following error when trying to build locally

CMake Error at /home/jhuber/Documents/llvm/llvm-project/libc/test/UnitTest/CMakeLists.txt:10 (message):
  'add_unittest_framework_library' requires SRCS; for header only libraries,
  use 'add_header_library'
Call Stack (most recent call first):
  /home/jhuber/Documents/llvm/llvm-project/libc/test/UnitTest/CMakeLists.txt:78 (add_unittest_framework_library)

Thanks for trying. I messed up the sources of the`LibcDeathTestExecutors` library. It should be fixed now.

ld.lld: error: libc/test/UnitTest/libLibcHermeticTestSupport.hermetic.a(HermeticTestUtils.cpp.o) is incompatible with libc/startup/gpu/amdgpu/CMakeFiles/libc.startup.gpu.amdgpu.crt1.dir/start.cpp.o
clang++: error: ld.lld command failed with exit code 1 (use -v to see invocation)

I get this error now, it happens when the architectures don't line up. So that means HermeticTestUtils.cpp.o is no longer being compiled for the GPU via --target=

Add hermetic test compile options to all hermetic test framework libraries.

So that means HermeticTestUtils.cpp.o is no longer being compiled for the GPU via --target=

Indeed! I the hermetic test compile options were only being added to the main test framework library and not to the other test framework libraries. Hopefully its fixed now.

jhuber6 accepted this revision.May 17 2023, 10:37 AM

Works for me now, thanks

This revision is now accepted and ready to land.May 17 2023, 10:37 AM