|
| 1 | +diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp |
| 2 | +index 6c31df3e173b..69aaaf6ca78e 100644 |
| 3 | +--- a/llvm/tools/llvm-config/llvm-config.cpp |
| 4 | ++++ b/llvm/tools/llvm-config/llvm-config.cpp |
| 5 | +@@ -707,7 +707,34 @@ int main(int argc, char **argv) { |
| 6 | + // Output system libraries only if linking against a static |
| 7 | + // library (since the shared library links to all system libs |
| 8 | + // already) |
| 9 | +- OS << (LinkMode == LinkModeStatic ? LLVM_SYSTEM_LIBS : "") << '\n'; |
| 10 | ++ |
| 11 | ++ // ========== BEGIN HACK ========== |
| 12 | ++ |
| 13 | ++ // There is a bug where "llvm-config --system-libs" will output long absolute paths. |
| 14 | ++ // This ends up with rust's cc doing bad things like "-llibz.tbd" or "-llibxml2.dylib". |
| 15 | ++ // Some attempts have been made to patch this but none of them have actually landed |
| 16 | ++ // in either LLVM 10 (which Apple is currently using) nor in LLVM 11. |
| 17 | ++ // |
| 18 | ++ // References: |
| 19 | ++ // https://discourse.brew.sh/t/llvm-config-10-0-1-advertise-libxml2-tbd-as-system-libs/8593/4 |
| 20 | ++ // https://reviews.llvm.org/D86134 |
| 21 | ++ // https://reviews.llvm.org/D87590 |
| 22 | ++ // |
| 23 | ++ // It appears that the right way to fix this involves LLVM's CMakeLists.txt where |
| 24 | ++ // these system libraries are calculated. Unfortunately I can't work out how to apply |
| 25 | ++ // the proposed fixes to apple's fork of LLVM as the CMake stuff is all a bit different. |
| 26 | ++ // |
| 27 | ++ // Rather than spend all week understanding LLVM's build system, I'm going to make the |
| 28 | ++ // bold assumption that everybody who's building this bitcode toolchain is running on |
| 29 | ++ // basically similar Macs, so if I just hardcode the right list of libraries here then |
| 30 | ++ // we'll all be okay. |
| 31 | ++ // |
| 32 | ++ // This can be removed when the appropriate upstream fix reaches Xcode's LLVM. |
| 33 | ++ |
| 34 | ++ //OS << (LinkMode == LinkModeStatic ? LLVM_SYSTEM_LIBS : "") << '\n'; |
| 35 | ++ OS << (LinkMode == LinkModeStatic ? "-lz -lcurses -lm -lxml2" : "") << '\n'; |
| 36 | ++ |
| 37 | ++ // ========== END HACK ========== |
| 38 | + } |
| 39 | + } else if (!Components.empty()) { |
| 40 | + WithColor::error(errs(), "llvm-config") |
0 commit comments