[Openmp-commits] [PATCH] D142484: [LinkerWrapper] Only import static libraries with needed symbols

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Jan 24 09:10:34 PST 2023


jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, JonChesterfield, tra, yaxunl.
Herald added a subscriber: kosarev.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: openmp-commits, cfe-commits, sstefan1.
Herald added projects: clang, OpenMP.

Currently, we pull in every single static archive member as long as we
have an offloading architecture that requires it. This goes against the
standard sematnics of static libraries that only pull in symbols that
define currently undefined symbols. In order to support this we roll
some custom symbol resolution logic to check if a static library is
needed. Because of offloading semantics, this requires an extra check
for externally visibile symbols. E.g. if a static member defines a
kernel we should import it.

The main benefit to this is that we can now link against the
`libomptarget.devicertl.a` library unconditionally. This removes the
requirement for users to specify LTO on the link command. This will also
allow us to stop using the `amdgcn` bitcode versions of the libraries.

  clang foo.c -fopenmp --offload-arch=gfx1030 -foffload-lto -c
  clang foo.o -fopenmp --offload-arch=gfx1030 -foffload-lto


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142484

Files:
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
  openmp/libomptarget/test/offloading/static_linking.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142484.491832.patch
Type: text/x-patch
Size: 9712 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230124/a09d049d/attachment-0001.bin>


More information about the Openmp-commits mailing list