[PATCH] D85992: [lld-macho] Fall back to raw path if we don't find anything under syslibroot
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 26 19:27:04 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3e7a86e3664a: [lld-macho] Fall back to raw path if we don't find anything under syslibroot (authored by int3).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85992/new/
https://reviews.llvm.org/D85992
Files:
lld/MachO/Driver.cpp
lld/test/MachO/syslibroot.test
Index: lld/test/MachO/syslibroot.test
===================================================================
--- lld/test/MachO/syslibroot.test
+++ lld/test/MachO/syslibroot.test
@@ -18,6 +18,10 @@
CHECK-ABSOLUTE-PATH-REROOTED: [[ROOT]]/Library/libxml2-development
CHECK-ABSOLUTE-PATH-REROOTED: [[ROOT]]/usr/lib
+RUN: lld -flavor darwinnew -v -Z -syslibroot %t -L %t/Library/libxml2-development | FileCheck %s -check-prefix CHECK-PATH-WITHOUT-REROOT -DPATH=%t/Library/libxml2-development
+CHECK-PATH-WITHOUT-REROOT: Library search paths:
+CHECK-PATH-WITHOUT-REROOT-NEXT: [[PATH]]
+
# NOTE: the match here is fuzzy because the default search paths exist on Linux
# and macOS, but not on Windows (that is we ignore `/var/empty`). This allows
# us to run the test uniformly on all the platforms.
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -148,7 +148,7 @@
}
}
-static bool isDirectory(StringRef option, StringRef path) {
+static bool warnIfNotDirectory(StringRef option, StringRef path) {
if (!fs::exists(path)) {
warn("directory not found for option -" + option + path);
return false;
@@ -163,21 +163,23 @@
opt::InputArgList &args,
const std::vector<StringRef> &roots,
const SmallVector<StringRef, 2> &systemPaths) {
- StringRef optionLetter{(optionCode == OPT_F ? "F" : "L")};
- for (auto const &path : args::getStrings(args, optionCode)) {
+ StringRef optionLetter{optionCode == OPT_F ? "F" : "L"};
+ for (StringRef path : args::getStrings(args, optionCode)) {
// NOTE: only absolute paths are re-rooted to syslibroot(s)
- if (llvm::sys::path::is_absolute(path, llvm::sys::path::Style::posix)) {
+ bool found = false;
+ if (path::is_absolute(path, path::Style::posix)) {
for (StringRef root : roots) {
SmallString<261> buffer(root);
- llvm::sys::path::append(buffer, path);
+ path::append(buffer, path);
// Do not warn about paths that are computed via the syslib roots
- if (llvm::sys::fs::is_directory(buffer))
+ if (fs::is_directory(buffer)) {
paths.push_back(saver.save(buffer.str()));
+ found = true;
+ }
}
- } else {
- if (isDirectory(optionLetter, path))
- paths.push_back(path);
}
+ if (!found && warnIfNotDirectory(optionLetter, path))
+ paths.push_back(path);
}
// `-Z` suppresses the standard "system" search paths.
@@ -187,8 +189,8 @@
for (auto const &path : systemPaths) {
for (auto root : roots) {
SmallString<261> buffer(root);
- llvm::sys::path::append(buffer, path);
- if (isDirectory(optionLetter, buffer))
+ path::append(buffer, path);
+ if (warnIfNotDirectory(optionLetter, buffer))
paths.push_back(saver.save(buffer.str()));
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85992.288162.patch
Type: text/x-patch
Size: 2962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200827/c14991f4/attachment.bin>
More information about the llvm-commits
mailing list