openbsd-ports/devel/llvm/patches/patch-tools_lld_ELF_DriverUtils_cpp

64 lines
2.5 KiB
Plaintext
Raw Normal View History

$OpenBSD: patch-tools_lld_ELF_DriverUtils_cpp,v 1.2 2017/03/23 08:26:07 ajacoutot Exp $
- Print out "supported targets".
- Handle the OpenBSD-style major/minor shared library version scheme.
--- tools/lld/ELF/DriverUtils.cpp.orig Fri Jan 6 05:04:35 2017
+++ tools/lld/ELF/DriverUtils.cpp Wed Mar 22 19:10:55 2017
@@ -120,6 +120,18 @@ opt::InputArgList ELFOptTable::parse(ArrayRef<const ch
void elf::printHelp(const char *Argv0) {
ELFOptTable Table;
Table.PrintHelp(outs(), Argv0, "lld", false);
+ outs() << "\n";
+
+ // Scripts generated by Libtool 2.4.6 or earlier expects /supported
+ // targets:.* elf/ in a message for the -help option. If it doesn't
+ // match, the scripts suppose that the linker doesn't support very basic
+ // features such as shared libraries. Therefore, we need to print out at
+ // least "elf". Here, we print out all the targets that we support.
+ outs() << Argv0 << ": supported targets: "
+ << "elf32-i386 elf32-iamcu elf32-littlearm elf32-powerpc "
+ << "elf32-tradbigmips elf32-tradlittlemips elf32-x86-64 "
+ << "elf64-amdgpu elf64-littleaarch64 elf64-powerpc "
+ << "elf64-tradbigmips elf64-tradlittlemips elf64-x86-64\n";
}
// Reconstructs command line arguments so that so that you can re-run
@@ -180,9 +192,35 @@ Optional<std::string> elf::searchLibrary(StringRef Nam
return findFromSearchPaths(Name.substr(1));
for (StringRef Dir : Config->SearchPaths) {
- if (!Config->Static)
+ if (!Config->Static) {
if (Optional<std::string> S = findFile(Dir, "lib" + Name + ".so"))
return S;
+
+ llvm::SmallString<128> Scratch;
+ const StringRef LibName = ("lib" + Name + ".so.").toStringRef(Scratch);
+ int MaxMaj = -1, MaxMin = -1;
+ std::error_code EC;
+ for (fs::directory_iterator LI(Dir, EC), LE;
+ !EC && LI != LE; LI = LI.increment(EC)) {
+ StringRef FilePath = LI->path();
+ StringRef FileName = path::filename(FilePath);
+ if (!(FileName.startswith(LibName)))
+ continue;
+ std::pair<StringRef, StringRef> MajMin =
+ FileName.substr(LibName.size()).split('.');
+ int Maj, Min;
+ if (MajMin.first.getAsInteger(10, Maj) || Maj < 0)
+ continue;
+ if (MajMin.second.getAsInteger(10, Min) || Min < 0)
+ continue;
+ if (Maj > MaxMaj)
+ MaxMaj = Maj, MaxMin = Min;
+ if (MaxMaj == Maj && Min > MaxMin)
+ MaxMin = Min;
+ }
+ if (MaxMaj >= 0)
+ return findFile(Dir, LibName + Twine(MaxMaj) + "." + Twine(MaxMin));
+ }
if (Optional<std::string> S = findFile(Dir, "lib" + Name + ".a"))
return S;
}