Skip to content

[Clang][VE] Correct rpath handling on VE #67671

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 1 commit into from
Sep 29, 2023
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
5 changes: 1 addition & 4 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,11 +902,8 @@ void tools::addOpenMPRuntimeLibraryPath(const ToolChain &TC,

void tools::addArchSpecificRPath(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs) {
// Enable -frtlib-add-rpath by default for the case of VE.
const bool IsVE = TC.getTriple().isVE();
bool DefaultValue = IsVE;
if (!Args.hasFlag(options::OPT_frtlib_add_rpath,
options::OPT_fno_rtlib_add_rpath, DefaultValue))
options::OPT_fno_rtlib_add_rpath, false))
return;

for (const auto &CandidateRPath : TC.getArchSpecificLibPaths()) {
Expand Down
8 changes: 8 additions & 0 deletions clang/lib/Driver/ToolChains/VEToolchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ VEToolChain::VEToolChain(const Driver &D, const llvm::Triple &Triple,
// These are OK.

// Default file paths are following:
// ${RESOURCEDIR}/lib/ve-unknown-linux-gnu, (== getArchSpecificLibPaths)
// ${RESOURCEDIR}/lib/linux/ve, (== getArchSpecificLibPaths)
// /lib/../lib64,
// /usr/lib/../lib64,
Expand All @@ -46,6 +47,7 @@ VEToolChain::VEToolChain(const Driver &D, const llvm::Triple &Triple,

// Add library directories:
// ${BINPATH}/../lib/ve-unknown-linux-gnu, (== getStdlibPath)
// ${RESOURCEDIR}/lib/ve-unknown-linux-gnu, (== getArchSpecificLibPaths)
// ${RESOURCEDIR}/lib/linux/ve, (== getArchSpecificLibPaths)
// ${SYSROOT}/opt/nec/ve/lib,
if (std::optional<std::string> Path = getStdlibPath())
Expand Down Expand Up @@ -141,6 +143,12 @@ void VEToolChain::AddCXXStdlibLibArgs(const ArgList &Args,

tools::addArchSpecificRPath(*this, Args, CmdArgs);

// Add paths for libc++.so and other shared libraries.
if (std::optional<std::string> Path = getStdlibPath()) {
CmdArgs.push_back("-rpath");
CmdArgs.push_back(Args.MakeArgString(*Path));
}

CmdArgs.push_back("-lc++");
if (Args.hasArg(options::OPT_fexperimental_library))
CmdArgs.push_back("-lc++experimental");
Expand Down
8 changes: 4 additions & 4 deletions clang/test/Driver/ve-toolchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
// DEF-SAME: "[[SYSROOT]]/opt/nec/ve/lib/crt1.o"
// DEF-SAME: "[[SYSROOT]]/opt/nec/ve/lib/crti.o"
// DEF-SAME: "-z" "max-page-size=0x4000000"
// DEF-SAME: "[[RESOURCE_DIR]]/lib/linux/clang_rt.crtbegin-ve.o"
// DEF-SAME: "[[RESOURCE_DIR]]/lib/linux/libclang_rt.builtins-ve.a" "-lc"
// DEF-SAME: "[[RESOURCE_DIR]]/lib/linux/libclang_rt.builtins-ve.a"
// DEF-SAME: "[[RESOURCE_DIR]]/lib/linux/clang_rt.crtend-ve.o"
// DEF-SAME: "[[RESOURCE_DIR]]/lib/ve-unknown-linux-gnu/clang_rt.crtbegin.o"
// DEF-SAME: "[[RESOURCE_DIR]]/lib/ve-unknown-linux-gnu/libclang_rt.builtins.a" "-lc"
// DEF-SAME: "[[RESOURCE_DIR]]/lib/ve-unknown-linux-gnu/libclang_rt.builtins.a"
// DEF-SAME: "[[RESOURCE_DIR]]/lib/ve-unknown-linux-gnu/clang_rt.crtend.o"
// DEF-SAME: "[[SYSROOT]]/opt/nec/ve/lib/crtn.o"
10 changes: 6 additions & 4 deletions clang/test/Driver/ve-toolchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
// DEFINC-SAME: "-internal-isystem" "{{.*}}/bin/../include/c++/v1"
// DEFINC-SAME: "-internal-isystem" "[[RESOURCE_DIR]]/include"
// DEFINC-SAME: "-internal-isystem" "[[SYSROOT]]/opt/nec/ve/include"
// DEFINC: nld"
// DEFINC-SAME: "-rpath" "[[SYSROOT]]/bin/../lib/ve-unknown-linux-gnu"

// RUN: %clangxx -### --target=ve-unknown-linux-gnu \
// RUN: --sysroot %S/Inputs/basic_ve_tree %s \
Expand Down Expand Up @@ -146,9 +148,9 @@
// DEF-SAME: "[[SYSROOT]]/opt/nec/ve/lib/crt1.o"
// DEF-SAME: "[[SYSROOT]]/opt/nec/ve/lib/crti.o"
// DEF-SAME: "-z" "max-page-size=0x4000000"
// DEF-SAME: "[[RESOURCE_DIR]]/lib/linux/clang_rt.crtbegin-ve.o"
// DEF-SAME: "[[RESOURCE_DIR]]/lib/ve-unknown-linux-gnu/clang_rt.crtbegin.o"
// DEF-SAME: "-lc++" "-lc++abi" "-lunwind" "-lpthread" "-ldl"
// DEF-SAME: "[[RESOURCE_DIR]]/lib/linux/libclang_rt.builtins-ve.a" "-lc"
// DEF-SAME: "[[RESOURCE_DIR]]/lib/linux/libclang_rt.builtins-ve.a"
// DEF-SAME: "[[RESOURCE_DIR]]/lib/linux/clang_rt.crtend-ve.o"
// DEF-SAME: "[[RESOURCE_DIR]]/lib/ve-unknown-linux-gnu/libclang_rt.builtins.a" "-lc"
// DEF-SAME: "[[RESOURCE_DIR]]/lib/ve-unknown-linux-gnu/libclang_rt.builtins.a"
// DEF-SAME: "[[RESOURCE_DIR]]/lib/ve-unknown-linux-gnu/clang_rt.crtend.o"
// DEF-SAME: "[[SYSROOT]]/opt/nec/ve/lib/crtn.o"