summaryrefslogtreecommitdiffstats
path: root/lld/lib/Driver/DarwinLdDriver.cpp
diff options
context:
space:
mode:
authorNick Kledzik <kledzik@apple.com>2014-08-14 22:20:41 +0000
committerNick Kledzik <kledzik@apple.com>2014-08-14 22:20:41 +0000
commit2d835dad0a4eabd3cbdb2b7d58685835ef9e510e (patch)
treefb4417c013853b3746ece872710d0b0036a311ad /lld/lib/Driver/DarwinLdDriver.cpp
parente8d2a9d755c22ffd3c50e2520963bc8dbe049ba2 (diff)
downloadbcm5719-llvm-2d835dad0a4eabd3cbdb2b7d58685835ef9e510e.tar.gz
bcm5719-llvm-2d835dad0a4eabd3cbdb2b7d58685835ef9e510e.zip
[mach-o] Support -F and -framework options in darwin driver
Darwin has a packaging mechanism for shared libraries and headers called frameworks. A directory Foo.framework contains a shared library binary file "Foo" and a subdirectory "Headers". Most OS frameworks are all in one directory /System/Library/Frameworks/. As a linking convenience, the linker option "-framework Foo" means search the framework directories specified with -F (analogous to -L) looking for a shared library Foo.framework/Foo. llvm-svn: 215680
Diffstat (limited to 'lld/lib/Driver/DarwinLdDriver.cpp')
-rw-r--r--lld/lib/Driver/DarwinLdDriver.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp
index fe255fbc0df..a3452210169 100644
--- a/lld/lib/Driver/DarwinLdDriver.cpp
+++ b/lld/lib/Driver/DarwinLdDriver.cpp
@@ -321,8 +321,14 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
// skipped.
// 3. If the last -syslibroot is "/", all of them are ignored entirely.
// 4. If { syslibroots } x path == {}, the original path is kept.
+ std::vector<StringRef> sysLibRoots;
for (auto syslibRoot : parsedArgs->filtered(OPT_syslibroot)) {
- ctx.addSysLibRoot(syslibRoot->getValue());
+ sysLibRoots.push_back(syslibRoot->getValue());
+ }
+ if (!sysLibRoots.empty()) {
+ // Ignore all if last -syslibroot is "/".
+ if (sysLibRoots.back() != "/")
+ ctx.setSysLibRoots(sysLibRoots);
}
// Paths specified with -L come first, and are not considered system paths for
@@ -331,10 +337,17 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
ctx.addModifiedSearchDir(libPath->getValue());
}
+ // Process -F directories (where to look for frameworks).
+ for (auto fwPath : parsedArgs->filtered(OPT_F)) {
+ ctx.addFrameworkSearchDir(fwPath->getValue());
+ }
+
// -Z suppresses the standard search paths.
if (!parsedArgs->hasArg(OPT_Z)) {
ctx.addModifiedSearchDir("/usr/lib", true);
ctx.addModifiedSearchDir("/usr/local/lib", true);
+ ctx.addFrameworkSearchDir("/Library/Frameworks", true);
+ ctx.addFrameworkSearchDir("/System/Library/Frameworks", true);
}
// Now that we've constructed the final set of search paths, print out what
@@ -344,6 +357,10 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
for (auto path : ctx.searchDirs()) {
diagnostics << " " << path << '\n';
}
+ diagnostics << "Framework search paths:\n";
+ for (auto path : ctx.frameworkDirs()) {
+ diagnostics << " " << path << '\n';
+ }
}
// Handle input files
@@ -370,6 +387,21 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
inputPath = resolvedPath.get();
break;
}
+ case OPT_framework: {
+ ErrorOr<StringRef> fullPath = ctx.findPathForFramework(arg->getValue());
+ if (!fullPath) {
+ diagnostics << "Unable to find -framework " << arg->getValue() << "\n";
+ return false;
+ } else if (ctx.testingLibResolution()) {
+ // Test may be running on Windows. Canonicalize the path
+ // separator to '/' to get consistent outputs for tests.
+ std::string path = fullPath.get();
+ std::replace(path.begin(), path.end(), '\\', '/');
+ diagnostics << "Found framework " << path << '\n';
+ }
+ inputPath = fullPath.get();
+ break;
+ }
}
inputGraph->addInputElement(std::unique_ptr<InputElement>(
new MachOFileNode(inputPath, globalWholeArchive)));
OpenPOWER on IntegriCloud