Add -resource-dir option to find lib/swift directory.

This is equivalent to Clang's -fresource-dir; it provides the location of
compiler modules and libraries.

No end-user-visible changes, but the iOS build will no longer have to use
-I to build and test its own standard libraries.

Swift SVN r13888
This commit is contained in:
Jordan Rose
2014-02-14 01:27:15 +00:00
parent 327439f3ab
commit 93b87edcbe
5 changed files with 40 additions and 32 deletions

View File

@@ -110,6 +110,7 @@ static void addCommonFrontendArgs(const ToolChain &TC,
inputArgs.AddAllArgs(arguments, options::OPT_I);
inputArgs.AddLastArg(arguments, options::OPT_g);
inputArgs.AddLastArg(arguments, options::OPT_resource_dir);
// Pass through any -Xllvm flags.
inputArgs.AddAllArgs(arguments, options::OPT_Xllvm);
@@ -431,10 +432,16 @@ Job *darwin::Linker::constructJob(const JobAction &JA,
// FIXME: Duplicated from CompilerInvocation, but in theory the runtime
// library link path and the standard library module import path don't
// need to be the same.
llvm::SmallString<128> RuntimeLibPath(D.getSwiftProgramPath());
llvm::sys::path::remove_filename(RuntimeLibPath); // remove /swift
llvm::sys::path::remove_filename(RuntimeLibPath); // remove /bin
llvm::sys::path::append(RuntimeLibPath, "lib", "swift");
llvm::SmallString<128> RuntimeLibPath;
if (const Arg *A = Args.getLastArg(options::OPT_resource_dir)) {
RuntimeLibPath = A->getValue();
} else {
RuntimeLibPath = D.getSwiftProgramPath();
llvm::sys::path::remove_filename(RuntimeLibPath); // remove /swift
llvm::sys::path::remove_filename(RuntimeLibPath); // remove /bin
llvm::sys::path::append(RuntimeLibPath, "lib", "swift");
}
llvm::sys::path::append(RuntimeLibPath,
getPlatformNameForTriple(TC.getTriple()));
Arguments.push_back("-L");