[PATCH] D76653: [clang] Allow -DDEFAULT_SYSROOT to be a relative path
Sam Clegg via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 23 17:26:47 PDT 2020
sbc100 created this revision.
Herald added subscribers: cfe-commits, sunfish, aheejin, mgorny, dschuff.
Herald added a project: clang.
sbc100 retitled this revision from "Allow -DDEFAULT_SYSROOT to be a relative path" to "[clang] Allow -DDEFAULT_SYSROOT to be a relative path".
sbc100 added reviewers: sunfish, phosek.
In this case we interpret the path as relative the llvm installation
root.
This allows SDKs to be build that include clang along with a custom
sysroot without requiring users to specify --sysroot to point to the
directory where they install the SDK.
See https://github.com/WebAssembly/wasi-sdk/issues/58
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D76653
Files:
clang/CMakeLists.txt
clang/lib/Driver/Driver.cpp
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -136,6 +136,10 @@
if (!this->VFS)
this->VFS = llvm::vfs::getRealFileSystem();
+ if (llvm::sys::path::is_relative(SysRoot)) {
+ SysRoot = GetResourcesPath(ClangExecutable, SysRoot);
+ }
+
Name = std::string(llvm::sys::path::filename(ClangExecutable));
Dir = std::string(llvm::sys::path::parent_path(ClangExecutable));
InstalledDir = Dir; // Provide a sensible default installed dir.
Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -226,7 +226,7 @@
"Colon separated list of directories clang will search for headers.")
set(GCC_INSTALL_PREFIX "" CACHE PATH "Directory where gcc is installed." )
-set(DEFAULT_SYSROOT "" CACHE PATH
+set(DEFAULT_SYSROOT "" CACHE STRING
"Default <path> to all compiler invocations for --sysroot=<path>." )
set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76653.252179.patch
Type: text/x-patch
Size: 1107 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200324/ecc7ca22/attachment.bin>
More information about the cfe-commits
mailing list