[PATCH] D141824: [clang-repl] Add a command to load dynamic libraries

Han Zhu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 6 16:02:54 PDT 2023


zhuhan0 added a comment.

In D141824#4250011 <https://reviews.llvm.org/D141824#4250011>, @sgraenitz wrote:

> In D141824#4247891 <https://reviews.llvm.org/D141824#4247891>, @zhuhan0 wrote:
>
>> This seems to be the first clang test that involves actual linking.
>
> Interesting, I think we all didn't have this on our radars.
>
>> If the intention is to test loading a dynamic library, could you commit the library in the Inputs directory instead of building it from source? cc @ayermolo
>
> Is that something other tests do? Otherwise, I am not sure it's a practical solution.

Yes. You can search for .so files under various /test directories. See this <https://github.com/llvm/llvm-project/blob/main/clang/test/Driver/hip-link-shared-library.hip> and this <https://github.com/llvm/llvm-project/blob/main/lld/test/ELF/corrupted-version-reference.s> as some examples. Admittedly you lose some readability if you replace the cpp source input with a compiled library, but you can simply add the source cpp as comments in the test file. After all if the intention is to test loading a shared library, I think it's better to reduce it to just doing that, so you avoid any flakiness that might come from the compilation.

> We could also consider another requirement like `host-supports-linking` for the test. What do you think?

I don't think this will work. Our platform supports linking. It's just the C startup/finish libraries are at a different path. It might be overly complicated to plumb that down to the test through cmake and llvm-lit.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141824/new/

https://reviews.llvm.org/D141824



More information about the cfe-commits mailing list