Skip to content

[Driver][SYCL] Improve handling of linker inputs for static lib proce… #1851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2605,12 +2605,10 @@ static SmallVector<const char *, 16> getLinkerArgs(Compilation &C,
continue;
}
}
if (A->getOption().hasFlag(options::LinkerInput)) {
// Do not add any libraries that are not fully named static libs
if (A->getOption().matches(options::OPT_l) ||
A->getOption().matches(options::OPT_reserved_lib_Group) ||
A->getOption().hasFlag(options::NoArgumentUnused))
continue;
if (A->getOption().matches(options::OPT_Wl_COMMA) ||
A->getOption().matches(options::OPT_Xlinker)) {
// Parse through additional linker arguments that are meant to go
// directly to the linker.
std::string PrevArg;
for (const std::string &Value : A->getValues()) {
auto addKnownValues = [&](const StringRef &V) {
Expand Down
8 changes: 4 additions & 4 deletions clang/test/Driver/sycl-offload-static-lib-2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@
// WHOLE_STATIC_LIB_1: ld{{.*}} "[[INPUTO]]" "--whole-archive" "[[INPUTA]]" "[[INPUTB]]" "--no-whole-archive"
// WHOLE_STATIC_LIB_2: ld{{.*}} "[[INPUTO]]" "@[[ARGFILE]]"

/// test -Wl,<arg> behaviors for special case handling of -z and -rpath
// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -L/dummy/dir %t.o -Wl,-rpath,nopass -Wl,-z,nopass %t.a %t_2.a -### 2>&1 \
/// test behaviors for special case handling of -z and -rpath
// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -z anystring -L/dummy/dir %t.o -Wl,-rpath,nopass -Wl,-z,nopass %t.a %t_2.a -### 2>&1 \
// RUN: | FileCheck %s -check-prefixes=WL_CHECK
// WL_CHECK-NOT: ld{{(.exe)?}}" "-r" {{.*}} "{{.*}}crt1.o" "{{.*}}crti.o" "-L/dummy/dir" {{.*}} "nopass" {{.*}} "{{.*}}crtn.o"
// WL_CHECK: ld{{.*}}" "-rpath" "nopass" "-z" "nopass"
// WL_CHECK-NOT: ld{{.*}} "-r" {{.*}} "anystring"
// WL_CHECK: ld{{.*}} "-z" "anystring" {{.*}} "-rpath" "nopass" "-z" "nopass"

/// ###########################################################################

Expand Down