[LinkerWrapper] Do not extract globals with no offloading language
authorJoseph Huber <jhuber6@vols.utk.edu>
Fri, 17 Mar 2023 20:10:25 +0000 (15:10 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Mon, 27 Mar 2023 16:38:27 +0000 (11:38 -0500)
commitb530e1af62be16ffb06285ddca27a413f5089b7e
treeb2d1fea3d49ac0c1f9f7a7a4683adfa3ac87b203
parente62836e31fb926ff41f91a7597d674a8c76276bc
[LinkerWrapper] Do not extract globals with no offloading language

The linker wrapper needs to reinvent its own special static library
handling for static libraries containing fatbinaries. This is primarily
because offloading languages expect certain global symbols to be visible
to the host so we must consider them used symbols. However we should be
able to remove this requirement if we are linking in "freestanding" code
that was not created by an offloading language.

The motivation for this is to support the work-in-progress `libc` for
GPUs. It is provided as a static library with no offloading language
set. This logic will let us only import used `libc` symbols always.

Reviewed By: yaxunl

Differential Revision: https://reviews.llvm.org/D146326
clang/test/Driver/linker-wrapper-libs.c
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp