[libc-commits] [PATCH] D148756: [libc] Add rule named `add_libc_hermetic_test` which adds a hermetic test.
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Mon Apr 24 01:47:22 PDT 2023
sivachandra added a comment.
In D148756#4283369 <https://reviews.llvm.org/D148756#4283369>, @jhuber6 wrote:
> Thanks a lot for this work, I think it's getting us pretty close. Getting this to build for the GPU required adding the `UnitTest` and `src` directories in the CMake. Some other issues I've had when trying to build for the GPU.
>
> 1. Including `stdlib.h` in `src/__support/CPP/string.h` causes errors when they include the system headers. Presumably this is because we aren't providing this as a header in the GPU build yet?
I think so.
> 2. The calls to `::free` and `::realloc` in `src/__support/CPP/string.h` did not compile when I tried, they were undefined in the module.
Did not compile or did they produce linker errors? The allocator functions come from the hermetic test framework, just like with the integration test framework.
> 3. I got an LLVM crash when compiling the whole project targeting AMDGPU in LTO mode. This is the recommended way as AMDGPU doesn't have a true "ABI". Turning off LTO hides the crash but is a little more iffy on whether or not it's correct since there's no defined ABI for cross-TU calls.
Is this related to the libc in anyway?
> 4. My build was not picking up `libc.src.__support.OSUtil.osutil` in the final test for some reason, added it to the hermetic test and it worked.
Likely a missing dep somewhere? But, this patch does add `OSUtil.osutil` as a dep.
> 5. We do not have `__cxa_atexit` defined
This comes from the `atexit` implementation. This should be enabled for GPUs in some mannger.
> 6. The `UnitTest` libraries need to have the explicit `--target=` and `-mcpu=` options passed in all cases to match the source.
I have updated this patch to get all the relevant compile options.
> 7. After hacking around all of the above, the test built and runs with a "No tests run." message. I'm assuming this is because we are not handling the global constructors.
>
> I'd appreciate some pointers on how to fix some of the above on the GPU side, I'm not as intimately familiar with the `libc` internals for registering constructors / exit functions.
Likely. I am happy to help/talk about how this works with normal ELF CPU binaries.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148756/new/
https://reviews.llvm.org/D148756
More information about the libc-commits
mailing list