mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 13:35:38 +08:00
[Driver][GNULD] Lookup .so files and default to dynamic output.
llvm-svn: 175572
This commit is contained in:
@@ -115,6 +115,8 @@ public:
|
||||
std::unique_ptr<llvm::opt::DerivedArgList> newArgs(
|
||||
new llvm::opt::DerivedArgList(*_inputArgs));
|
||||
|
||||
bool isOutputDynamic = false;
|
||||
|
||||
if (llvm::opt::Arg *A = _inputArgs->getLastArg(ld::OPT_target)) {
|
||||
newArgs->AddSeparateArg( A, _core.getOption(core::OPT_target)
|
||||
, A->getValue());
|
||||
@@ -134,6 +136,15 @@ public:
|
||||
newArgs->AddJoinedArg(nullptr, _core.getOption(core::OPT_output),
|
||||
"a.out");
|
||||
|
||||
if (llvm::opt::Arg *A = _inputArgs->getLastArg(ld::OPT_static))
|
||||
newArgs->AddJoinedArg(A, _core.getOption(core::OPT_output_type),
|
||||
newArgs->MakeArgString("static"));
|
||||
else {
|
||||
newArgs->AddJoinedArg(nullptr, _core.getOption(core::OPT_output_type),
|
||||
newArgs->MakeArgString("dynamic"));
|
||||
isOutputDynamic = true;
|
||||
}
|
||||
|
||||
if (llvm::opt::Arg *A = _inputArgs->getLastArg(ld::OPT_relocatable))
|
||||
newArgs->AddFlagArg(A, _core.getOption(core::OPT_relocatable));
|
||||
|
||||
@@ -170,6 +181,14 @@ public:
|
||||
StringRef libName = (*it)->getValue();
|
||||
SmallString<128> p;
|
||||
for (const auto &path : _inputSearchPaths) {
|
||||
if (isOutputDynamic) {
|
||||
p = path;
|
||||
llvm::sys::path::append(p, Twine("lib") + libName + ".so");
|
||||
if (llvm::sys::fs::exists(p.str())) {
|
||||
inputPath = newArgs->MakeArgString(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
p = path;
|
||||
llvm::sys::path::append(p, Twine("lib") + libName + ".a");
|
||||
if (llvm::sys::fs::exists(p.str())) {
|
||||
|
||||
@@ -14,6 +14,8 @@ def output_e : Separate<["-"], "o">, Alias<output>;
|
||||
def relocatable : Flag<["--"], "relocatable">;
|
||||
def relocatable_r : Flag<["-"], "r">, Alias<relocatable>;
|
||||
|
||||
def dynamic_linker : Separate<["-"], "dynamic-linker">;
|
||||
|
||||
def OCTOTHORPE_OCTOTHORPE_OCTOTHORPE : Flag<["-"], "###">;
|
||||
|
||||
def emit_yaml : Flag<["-"], "emit-yaml">;
|
||||
|
||||
Reference in New Issue
Block a user