forked from OSchip/llvm-project
[JITLink][COFF] Consider lib/dll files in llvm-jitlink.
Consider lib/dll files in llvm-jitlink. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D129944
This commit is contained in:
parent
5fb4134210
commit
85c6629d85
|
@ -1486,7 +1486,8 @@ static Error addObjects(Session &S,
|
||||||
unsigned InputFileArgIdx =
|
unsigned InputFileArgIdx =
|
||||||
InputFiles.getPosition(InputFileItr - InputFiles.begin());
|
InputFiles.getPosition(InputFileItr - InputFiles.begin());
|
||||||
const std::string &InputFile = *InputFileItr;
|
const std::string &InputFile = *InputFileItr;
|
||||||
if (StringRef(InputFile).endswith(".a"))
|
if (StringRef(InputFile).endswith(".a") ||
|
||||||
|
StringRef(InputFile).endswith(".lib"))
|
||||||
continue;
|
continue;
|
||||||
auto &JD = *std::prev(IdxToJD.lower_bound(InputFileArgIdx))->second;
|
auto &JD = *std::prev(IdxToJD.lower_bound(InputFileArgIdx))->second;
|
||||||
LLVM_DEBUG(dbgs() << " " << InputFileArgIdx << ": \"" << InputFile
|
LLVM_DEBUG(dbgs() << " " << InputFileArgIdx << ": \"" << InputFile
|
||||||
|
@ -1572,7 +1573,7 @@ static Error addLibraries(Session &S,
|
||||||
for (auto InputFileItr = InputFiles.begin(), InputFileEnd = InputFiles.end();
|
for (auto InputFileItr = InputFiles.begin(), InputFileEnd = InputFiles.end();
|
||||||
InputFileItr != InputFileEnd; ++InputFileItr) {
|
InputFileItr != InputFileEnd; ++InputFileItr) {
|
||||||
StringRef InputFile = *InputFileItr;
|
StringRef InputFile = *InputFileItr;
|
||||||
if (!InputFile.endswith(".a"))
|
if (!InputFile.endswith(".a") && !InputFile.endswith(".lib"))
|
||||||
continue;
|
continue;
|
||||||
LibraryLoad LL;
|
LibraryLoad LL;
|
||||||
LL.LibName = InputFile;
|
LL.LibName = InputFile;
|
||||||
|
@ -1594,8 +1595,8 @@ static Error addLibraries(Session &S,
|
||||||
LL.Modifier = LibraryLoad::Hidden;
|
LL.Modifier = LibraryLoad::Hidden;
|
||||||
LibraryLoads.push_back(std::move(LL));
|
LibraryLoads.push_back(std::move(LL));
|
||||||
}
|
}
|
||||||
StringRef StandardExtensions[] = {".so", ".dylib", ".a"};
|
StringRef StandardExtensions[] = {".so", ".dylib", ".dll", ".a", ".lib"};
|
||||||
StringRef ArchiveExtensionsOnly[] = {".a"};
|
StringRef ArchiveExtensionsOnly[] = {".a", ".lib"};
|
||||||
|
|
||||||
// Add -lx arguments to LibraryLoads.
|
// Add -lx arguments to LibraryLoads.
|
||||||
for (auto LibItr = Libraries.begin(), LibEnd = Libraries.end();
|
for (auto LibItr = Libraries.begin(), LibEnd = Libraries.end();
|
||||||
|
@ -1676,13 +1677,16 @@ static Error addLibraries(Session &S,
|
||||||
auto JDSearchPathsItr = JDSearchPaths.find(&JD);
|
auto JDSearchPathsItr = JDSearchPaths.find(&JD);
|
||||||
if (JDSearchPathsItr != JDSearchPaths.end()) {
|
if (JDSearchPathsItr != JDSearchPaths.end()) {
|
||||||
for (StringRef SearchPath : JDSearchPathsItr->second) {
|
for (StringRef SearchPath : JDSearchPathsItr->second) {
|
||||||
for (const char *LibExt : {".dylib", ".so", ".a"}) {
|
for (const char *LibExt : {".dylib", ".so", ".dll", ".a", ".lib"}) {
|
||||||
SmallVector<char, 256> LibPath;
|
SmallVector<char, 256> LibPath;
|
||||||
LibPath.reserve(SearchPath.size() + strlen("lib") +
|
LibPath.reserve(SearchPath.size() + strlen("lib") +
|
||||||
LL.LibName.size() + strlen(LibExt) +
|
LL.LibName.size() + strlen(LibExt) +
|
||||||
2); // +2 for pathsep, null term.
|
2); // +2 for pathsep, null term.
|
||||||
llvm::copy(SearchPath, std::back_inserter(LibPath));
|
llvm::copy(SearchPath, std::back_inserter(LibPath));
|
||||||
|
if (StringRef(LibExt) != ".lib" && StringRef(LibExt) != ".dll")
|
||||||
sys::path::append(LibPath, "lib" + LL.LibName + LibExt);
|
sys::path::append(LibPath, "lib" + LL.LibName + LibExt);
|
||||||
|
else
|
||||||
|
sys::path::append(LibPath, LL.LibName + LibExt);
|
||||||
LibPath.push_back('\0');
|
LibPath.push_back('\0');
|
||||||
|
|
||||||
// Skip missing or non-regular paths.
|
// Skip missing or non-regular paths.
|
||||||
|
|
Loading…
Reference in New Issue