return {};
}
-void Link(std::vector<std::string> &relocatables, DriverOptions &driver) {
+void Link(std::vector<std::string> &liblist, std::vector<std::string> &objects,
+ DriverOptions &driver) {
if (!ParentProcess()) {
std::vector<char *> argv;
for (size_t j{0}; j < driver.F18_FCArgs.size(); ++j) {
argv.push_back(driver.F18_FCArgs[j].data());
}
- for (auto &relo : relocatables) {
- argv.push_back(relo.data());
+ for (auto &obj : objects) {
+ argv.push_back(obj.data());
}
if (!driver.outputPath.empty()) {
char dashO[3] = "-o";
argv.push_back(dashO);
argv.push_back(driver.outputPath.data());
}
+ for (auto &lib : liblist) {
+ argv.push_back(lib.data());
+ }
Exec(argv, driver.verbose);
}
}
bool isPGF90{driver.F18_FCArgs.back().rfind("pgf90") != std::string::npos};
std::list<std::string> args{argList(argc, argv)};
+ std::vector<std::string> objlist, liblist;
std::string prefix{args.front()};
args.pop_front();
prefix += ": ";
Fortran::common::IntrinsicTypeDefaultKinds defaultKinds;
- std::vector<std::string> fortranSources, otherSources, relocatables;
+ std::vector<std::string> fortranSources, otherSources;
bool anyFiles{false};
while (!args.empty()) {
std::string arg{std::move(args.front())};
+ auto dot{arg.rfind(".")};
+ std::string suffix{arg.substr(dot + 1)};
+ std::string prefix{arg.substr(0, 2)};
args.pop_front();
if (arg.empty()) {
} else if (arg.at(0) != '-') {
anyFiles = true;
- auto dot{arg.rfind(".")};
if (dot == std::string::npos) {
driver.F18_FCArgs.push_back(arg);
} else {
- std::string suffix{arg.substr(dot + 1)};
if (suffix == "f" || suffix == "F" || suffix == "ff" ||
suffix == "f90" || suffix == "F90" || suffix == "ff90" ||
suffix == "f95" || suffix == "F95" || suffix == "ff95" ||
suffix == "cuf" || suffix == "CUF" || suffix == "f18" ||
suffix == "F18" || suffix == "ff18") {
fortranSources.push_back(arg);
- } else if (suffix == "o" || suffix == "a") {
- relocatables.push_back(arg);
+ } else if (suffix == "o" || suffix == "so") {
+ objlist.push_back(arg);
+ } else if (suffix == "a") {
+ liblist.push_back(arg);
} else {
otherSources.push_back(arg);
}
}
+ } else if (prefix == "-l" || suffix == "a") {
+ liblist.push_back(arg);
} else if (arg == "-") {
fortranSources.push_back("-");
} else if (arg == "--") {
for (const auto &path : fortranSources) {
std::string relo{CompileFortran(path, options, driver, defaultKinds)};
if (!driver.compileOnly && !relo.empty()) {
- relocatables.push_back(relo);
+ objlist.push_back(relo);
}
}
for (const auto &path : otherSources) {
std::string relo{CompileOtherLanguage(path, driver)};
if (!driver.compileOnly && !relo.empty()) {
- relocatables.push_back(relo);
+ objlist.push_back(relo);
}
}
- if (!relocatables.empty()) {
- Link(relocatables, driver);
+ if (!objlist.empty()) {
+ Link(liblist, objlist, driver);
}
return exitStatus;
}