mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-13 03:12:46 +00:00
[WebAssembly] Modernize include path handling
Move include path construction from InitHeaderSearch::AddDefaultIncludePaths in the Driver which appears to be the more modern/correct way of doing things. Differential Revision: https://reviews.llvm.org/D63030 llvm-svn: 363241
This commit is contained in:
parent
51c2fa0e2a
commit
818dd8666a
@ -8,6 +8,7 @@
|
||||
|
||||
#include "WebAssembly.h"
|
||||
#include "CommonArgs.h"
|
||||
#include "clang/Config/config.h"
|
||||
#include "clang/Driver/Compilation.h"
|
||||
#include "clang/Driver/Driver.h"
|
||||
#include "clang/Driver/DriverDiagnostic.h"
|
||||
@ -170,14 +171,39 @@ WebAssembly::GetCXXStdlibType(const ArgList &Args) const {
|
||||
|
||||
void WebAssembly::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
|
||||
ArgStringList &CC1Args) const {
|
||||
if (!DriverArgs.hasArg(options::OPT_nostdinc)) {
|
||||
if (getTriple().getOS() != llvm::Triple::UnknownOS) {
|
||||
const std::string MultiarchTriple =
|
||||
getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot);
|
||||
addSystemInclude(DriverArgs, CC1Args, getDriver().SysRoot + "/include/" + MultiarchTriple);
|
||||
}
|
||||
addSystemInclude(DriverArgs, CC1Args, getDriver().SysRoot + "/include");
|
||||
if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
|
||||
return;
|
||||
|
||||
const Driver &D = getDriver();
|
||||
|
||||
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
|
||||
SmallString<128> P(D.ResourceDir);
|
||||
llvm::sys::path::append(P, "include");
|
||||
addSystemInclude(DriverArgs, CC1Args, P);
|
||||
}
|
||||
|
||||
if (DriverArgs.hasArg(options::OPT_nostdlibinc))
|
||||
return;
|
||||
|
||||
// Check for configure-time C include directories.
|
||||
StringRef CIncludeDirs(C_INCLUDE_DIRS);
|
||||
if (CIncludeDirs != "") {
|
||||
SmallVector<StringRef, 5> dirs;
|
||||
CIncludeDirs.split(dirs, ":");
|
||||
for (StringRef dir : dirs) {
|
||||
StringRef Prefix =
|
||||
llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
|
||||
addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (getTriple().getOS() != llvm::Triple::UnknownOS) {
|
||||
const std::string MultiarchTriple =
|
||||
getMultiarchTriple(D, getTriple(), D.SysRoot);
|
||||
addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/include/" + MultiarchTriple);
|
||||
}
|
||||
addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/include");
|
||||
}
|
||||
|
||||
void WebAssembly::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
||||
@ -188,7 +214,8 @@ void WebAssembly::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
||||
const std::string MultiarchTriple =
|
||||
getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot);
|
||||
addSystemInclude(DriverArgs, CC1Args,
|
||||
getDriver().SysRoot + "/include/" + MultiarchTriple + "/c++/v1");
|
||||
getDriver().SysRoot + "/include/" + MultiarchTriple +
|
||||
"/c++/v1");
|
||||
}
|
||||
addSystemInclude(DriverArgs, CC1Args,
|
||||
getDriver().SysRoot + "/include/c++/v1");
|
||||
|
@ -414,9 +414,11 @@ void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
|
||||
default:
|
||||
break; // Everything else continues to use this routine's logic.
|
||||
|
||||
case llvm::Triple::Emscripten:
|
||||
case llvm::Triple::Linux:
|
||||
case llvm::Triple::Hurd:
|
||||
case llvm::Triple::Solaris:
|
||||
case llvm::Triple::WASI:
|
||||
return;
|
||||
|
||||
case llvm::Triple::Win32:
|
||||
@ -424,6 +426,12 @@ void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
|
||||
triple.isOSBinFormatMachO())
|
||||
return;
|
||||
break;
|
||||
|
||||
case llvm::Triple::UnknownOS:
|
||||
if (triple.getArch() == llvm::Triple::wasm32 ||
|
||||
triple.getArch() == llvm::Triple::wasm64)
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
// All header search logic is handled in the Driver for Darwin.
|
||||
|
@ -45,8 +45,10 @@
|
||||
// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo --stdlib=c++ %s 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=COMPILE %s
|
||||
// COMPILE: clang{{.*}}" "-cc1"
|
||||
// COMPILE: "-resource-dir" "[[RESOURCE_DIR:[^"]*]]"
|
||||
// COMPILE: "-isysroot" "/foo"
|
||||
// COMPILE: "-internal-isystem" "/foo/include/wasm32-wasi/c++/v1"
|
||||
// COMPILE: "-internal-isystem" "/foo/include/c++/v1"
|
||||
// COMPILE: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|\\\\)}}include"
|
||||
// COMPILE: "-internal-isystem" "/foo/include/wasm32-wasi"
|
||||
// COMPILE: "-internal-isystem" "/foo/include"
|
||||
|
Loading…
x
Reference in New Issue
Block a user