Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

give BSDs some attention #13700

Closed
mikdusan opened this issue Nov 29, 2022 · 0 comments · Fixed by #13699
Closed

give BSDs some attention #13700

mikdusan opened this issue Nov 29, 2022 · 0 comments · Fixed by #13699

Comments

@mikdusan
Copy link
Member

mikdusan commented Nov 29, 2022

Tier 2 BSDs have fallen behind over last year or so and PR #13699 aims to make general progress.

status (updated as the PR makes progress)

ARCH OS VERSIONS STAGE2 STAGE3 NOTES
x86_64 freebsd 13.1, 13.0, 12.4, 12.3 yes yes
  • zig build test docs
openbsd 7.2, 7.1 yes yes
  • zig build test docs
netbsd 10.0, 9.3, 9.2 yes yes
  • zig build test docs
dragonfly 6.4, 6.2, 6.0 yes yes
  • zig build test docs
aarch64 freebsd 13.1 yes yes
  • behavior test: 2 fails
riscv64 freebsd 13.1 yes yes
  • behavior test: 2 fails

openbsd special instructions

  • default stack size of 4MB fails with various errors like SIGSEG, SIGILL when building stage3
  • set LIBRARY_PATH for extra libdir if your llvm dep was built with libzstd
limit stacksize 32M
export LIBRARY_PATH=/usr/local/lib
  • this patch is required against llvm-project otherwise finding dynamic libraries fails:
diff
diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp
index 51f3dc3a056e..eea7d5b10d4a 100644
--- a/lld/ELF/DriverUtils.cpp
+++ b/lld/ELF/DriverUtils.cpp
@@ -224,11 +224,38 @@ Optional<std::string> elf::findFromSearchPaths(StringRef path) {
 // search paths.
 Optional<std::string> elf::searchLibraryBaseName(StringRef name) {
   for (StringRef dir : config->searchPaths) {
-    if (!config->isStatic)
+    if (!config->isStatic) {
       if (Optional<std::string> s = findFile(dir, "lib" + name + ".so"))
         return s;
-    if (Optional<std::string> s = findFile(dir, "lib" + name + ".a"))
-      return s;
+
+      // Handle OpenBSD-style maj/min shlib scheme
+      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;
+          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;
   }
   return None;
 }
diff --git a/llvm/cmake/modules/GetLibraryName.cmake b/llvm/cmake/modules/GetLibraryName.cmake
index 13c0080671a3..c226b57dc8ac 100644
--- a/llvm/cmake/modules/GetLibraryName.cmake
+++ b/llvm/cmake/modules/GetLibraryName.cmake
@@ -2,7 +2,7 @@
 function(get_library_name path name)
   get_filename_component(path ${path} NAME)
   set(prefixes ${CMAKE_FIND_LIBRARY_PREFIXES})
-  set(suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
+  set(suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES} ".so.[0-9]+.[0-9]+")
   list(FILTER prefixes EXCLUDE REGEX "^\\s*$")
   list(FILTER suffixes EXCLUDE REGEX "^\\s*$")
   if(prefixes)

netbsd special instructions

  • default stack size of 4MB fails with various errors like SIGSEGV when building stage3
  • set LIBRARY_PATH for extra libdir if your llvm dep was built with libzstd
limit stacksize 32M
export LIBRARY_PATH=/usr/pkg/lib
  • for netbsd < 10.0 this patch is required against llvm-project otherwise building clang fails:
diff
diff --git a/clang/lib/Interpreter/IncrementalParser.cpp b/clang/lib/Interpreter/IncrementalParser.cpp
index db854c4161b4..88f22e2347f2 100644
--- a/clang/lib/Interpreter/IncrementalParser.cpp
+++ b/clang/lib/Interpreter/IncrementalParser.cpp
@@ -53,7 +53,7 @@ public:
           switch (CI.getFrontendOpts().ProgramAction) {
           default:
             Err = llvm::createStringError(
-                std::errc::state_not_recoverable,
+                clang::errc::state_not_recoverable,
                 "Driver initialization failed. "
                 "Incremental mode for action %d is not supported",
                 CI.getFrontendOpts().ProgramAction);
diff --git a/clang/lib/Interpreter/IncrementalParser.h b/clang/lib/Interpreter/IncrementalParser.h
index 8e45d6b5931b..885ce4596ff1 100644
--- a/clang/lib/Interpreter/IncrementalParser.h
+++ b/clang/lib/Interpreter/IncrementalParser.h
@@ -79,6 +79,14 @@ public:
 private:
   llvm::Expected<PartialTranslationUnit &> ParseOrWrapTopLevelDecl();
 };
+
+  namespace errc {
+#if defined(ENOTRECOVERABLE)
+    const std::errc state_not_recoverable = std:errc::state_not_recoverable;
+#else
+    const std::errc state_not_recoverable = static_cast<std::errc>(ELAST + 1000);
+#endif
+  }
 } // end namespace clang

 #endif // LLVM_CLANG_LIB_INTERPRETER_INCREMENTALPARSER_H

dragonfly special instructions

  • set LIBRARY_PATH for extra libdir if your llvm dep was built with libzstd
export LIBRARY_PATH=/usr/local/lib

related:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants