[llvm-branch-commits] [clang] 7d30df7 - [VE] Add standard include path and library path for C++
Kazushi Marukawa via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Dec 3 05:26:47 PST 2020
Author: Kazushi (Jam) Marukawa
Date: 2020-12-03T22:22:56+09:00
New Revision: 7d30df7b59973a42a93c86cb501bd3d0fbb07404
URL: https://github.com/llvm/llvm-project/commit/7d30df7b59973a42a93c86cb501bd3d0fbb07404
DIFF: https://github.com/llvm/llvm-project/commit/7d30df7b59973a42a93c86cb501bd3d0fbb07404.diff
LOG: [VE] Add standard include path and library path for C++
We have a plan to add libcxx and libcxxabi for VE. In order to do so,
we need to compile cxx source code with bootstarapped header files.
This patch adds such expected path to make clang++ work, at least
not crash at the startup. Add regression test for that, also.
Reviewed By: simoll
Differential Revision: https://reviews.llvm.org/D92386
Added:
clang/test/Driver/ve-toolchain.cpp
Modified:
clang/lib/Driver/ToolChains/VEToolchain.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/VEToolchain.cpp b/clang/lib/Driver/ToolChains/VEToolchain.cpp
index 6ea405c0269c..e28f340f9aad 100644
--- a/clang/lib/Driver/ToolChains/VEToolchain.cpp
+++ b/clang/lib/Driver/ToolChains/VEToolchain.cpp
@@ -102,14 +102,37 @@ void VEToolChain::addClangTargetOptions(const ArgList &DriverArgs,
void VEToolChain::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
- // TODO upstream VE libc++ patches
- llvm_unreachable("The VE target has no C++ stdlib for Clang yet");
+ if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) ||
+ DriverArgs.hasArg(options::OPT_nostdlibinc) ||
+ DriverArgs.hasArg(options::OPT_nostdincxx))
+ return;
+ if (const char *cl_include_dir = getenv("NCC_CPLUS_INCLUDE_PATH")) {
+ SmallVector<StringRef, 4> Dirs;
+ const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'};
+ StringRef(cl_include_dir).split(Dirs, StringRef(EnvPathSeparatorStr));
+ ArrayRef<StringRef> DirVec(Dirs);
+ addSystemIncludes(DriverArgs, CC1Args, DirVec);
+ } else {
+ SmallString<128> P(getDriver().ResourceDir);
+ llvm::sys::path::append(P, "include/c++/v1");
+ addSystemInclude(DriverArgs, CC1Args, P);
+ }
}
void VEToolChain::AddCXXStdlibLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
- // TODO upstream VE libc++ patches
- llvm_unreachable("The VE target has no C++ stdlib for Clang yet");
+ assert((GetCXXStdlibType(Args) == ToolChain::CST_Libcxx) &&
+ "Only -lc++ (aka libxx) is supported in this toolchain.");
+
+ tools::addArchSpecificRPath(*this, Args, CmdArgs);
+
+ CmdArgs.push_back("-lc++");
+ CmdArgs.push_back("-lc++abi");
+ CmdArgs.push_back("-lunwind");
+ // libc++ requires -lpthread under glibc environment
+ CmdArgs.push_back("-lpthread");
+ // libunwind requires -ldl under glibc environment
+ CmdArgs.push_back("-ldl");
}
llvm::ExceptionHandling
diff --git a/clang/test/Driver/ve-toolchain.cpp b/clang/test/Driver/ve-toolchain.cpp
new file mode 100644
index 000000000000..e056c04456ae
--- /dev/null
+++ b/clang/test/Driver/ve-toolchain.cpp
@@ -0,0 +1,132 @@
+/// Check the behavior of toolchain for NEC Aurora VE
+/// REQUIRES: ve-registered-target
+
+///-----------------------------------------------------------------------------
+/// Checking dwarf-version
+
+// RUN: %clangxx -### -g -target ve %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
+// DWARF_VER: "-dwarf-version=4"
+
+///-----------------------------------------------------------------------------
+/// Checking dynamic-linker
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DYNLINKER %s
+// DYNLINKER: nld{{.*}} "-dynamic-linker" "/opt/nec/ve/lib/ld-linux-ve.so.1"
+
+///-----------------------------------------------------------------------------
+/// Checking VE specific option
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=VENLDOPT %s
+// VENLDOPT: nld{{.*}} "-z" "max-page-size=0x4000000"
+
+///-----------------------------------------------------------------------------
+/// Checking include-path
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFINC %s
+// DEFINC: clang{{.*}} "-cc1"
+// DEFINC: "-nostdsysteminc"
+// DEFINC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// DEFINC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// DEFINC: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nostdlibinc 2>&1 | \
+// RUN: FileCheck -check-prefix=NOSTDLIBINC %s
+// NOSTDLIBINC: clang{{.*}} "-cc1"
+// NOSTDLIBINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// NOSTDLIBINC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// NOSTDLIBINC-NOT: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nobuiltininc 2>&1 | \
+// RUN: FileCheck -check-prefix=NOBUILTININC %s
+// NOBUILTININC: clang{{.*}} "-cc1"
+// NOBUILTININC: "-nobuiltininc"
+// NOBUILTININC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// NOBUILTININC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// NOBUILTININC: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nostdinc 2>&1 | \
+// RUN: FileCheck -check-prefix=NOSTDINC %s
+// NOSTDINC: clang{{.*}} "-cc1"
+// NOSTDINC: "-nobuiltininc"
+// NOSTDINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// NOSTDINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// NOSTDINC-NOT: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nostdinc++ 2>&1 | \
+// RUN: FileCheck -check-prefix=NOSTDINCXX %s
+// NOSTDINCXX: clang{{.*}} "-cc1"
+// NOSTDINCXX: "-nostdinc++"
+// NOSTDINCXX-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// NOSTDINCXX: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// NOSTDINCXX: "-internal-isystem" "/opt/nec/ve/include"
+
+///-----------------------------------------------------------------------------
+/// Checking environment variable NCC_CPLUS_INCLUDE_PATH
+
+// RUN: env NCC_CPLUS_INCLUDE_PATH=/test/test %clangxx -### -target ve %s \
+// RUN: 2>&1 | FileCheck -check-prefix=DEFINCENV %s
+
+// DEFINCENV: clang{{.*}} "-cc1"
+// DEFINCENV: "-nostdsysteminc"
+// DEFINCENV: "-internal-isystem" "/test/test"
+// DEFINCENV: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// DEFINCENV: "-internal-isystem" "/opt/nec/ve/include"
+
+///-----------------------------------------------------------------------------
+/// Checking -fuse-init-array
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFINITARRAY %s
+// DEFINITARRAY: clang{{.*}} "-cc1"
+// DEFINITARRAY-NOT: "-fuse-init-array"
+
+// RUN: %clangxx -### -target ve %s -fno-use-init-array 2>&1 | \
+// RUN: FileCheck -check-prefix=NOTINITARRAY %s
+// NOTINITARRAY: clang{{.*}} "-cc1"
+// NOTINITARRAY: "-fno-use-init-array"
+
+///-----------------------------------------------------------------------------
+/// Checking -faddrsig
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFADDESIG %s
+// DEFADDESIG: clang{{.*}} "-cc1"
+// DEFADDESIG-NOT: "-faddrsig"
+
+// RUN: %clangxx -### -target ve %s -faddrsig 2>&1 | \
+// RUN: FileCheck -check-prefix=ADDRSIG %s
+// ADDRSIG: clang{{.*}} "-cc1"
+// ADDRSIG: "-faddrsig"
+
+// RUN: %clangxx -### -target ve %s -fno-addrsig 2>&1 | \
+// RUN: FileCheck -check-prefix=NOADDRSIG %s
+// NOADDRSIG: clang{{.*}} "-cc1"
+// NOADDRSIG-NOT: "-faddrsig"
+
+///-----------------------------------------------------------------------------
+/// Checking exceptions
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFEXCEPTION %s
+// DEFEXCEPTION: clang{{.*}} "-cc1"
+// DEFEXCEPTION: "-fsjlj-exceptions"
+
+///-----------------------------------------------------------------------------
+/// Passing -fintegrated-as
+
+// RUN: %clangxx -### -target ve -x assembler %s 2>&1 | \
+// RUN: FileCheck -check-prefix=AS_LINK %s
+// RUN: %clangxx -### -target ve -fno-integrated-as -x assembler %s 2>&1 | \
+// RUN: FileCheck -check-prefix=NAS_LINK %s
+
+// AS_LINK: clang{{.*}} "-cc1as"
+// AS_LINK: nld{{.*}}
+
+// NAS_LINK: nas{{.*}}
+// NAS_LINK: nld{{.*}}
+
+///-----------------------------------------------------------------------------
+/// Checking default libraries
+
+// RUN: %clangxx -### -target ve --stdlib=c++ %s 2>&1 | \
+// RUN: FileCheck -check-prefix=LINK %s
+
+// LINK: clang{{.*}} "-cc1"
+// LINK: nld{{.*}} "{{.*}}/crt1.o" "{{.*}}/crti.o"{{.*}}"crtbegin.o"{{.*}}"-lc++" "-lc++abi" "-lunwind" "-lpthread" "-ldl"
More information about the llvm-branch-commits
mailing list