[llvm] r304707 - Fix building DynamicLibrary.cpp with musl libc

Dimitry Andric via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 5 04:22:19 PDT 2017


Author: dim
Date: Mon Jun  5 06:22:18 2017
New Revision: 304707

URL: http://llvm.org/viewvc/llvm-project?rev=304707&view=rev
Log:
Fix building DynamicLibrary.cpp with musl libc

Summary:
The workaround added in rL301240 for stderr/out/in symbols being both
macros and globals is only necessary for glibc, and it does not compile
with musl libc. Alpine Linux has had the following fix for it:

https://git.alpinelinux.org/cgit/aports/plain/main/llvm4/llvm-fix-DynamicLibrary-to-build-with-musl-libc.patch

Adapt the fix in our DynamicLibrary.inc for Unix.

Reviewers: marsupial, chandlerc, krytarowski

Reviewed By: krytarowski

Subscribers: srhines, krytarowski, llvm-commits

Differential Revision: https://reviews.llvm.org/D33883

Modified:
    llvm/trunk/lib/Support/Unix/DynamicLibrary.inc

Modified: llvm/trunk/lib/Support/Unix/DynamicLibrary.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/DynamicLibrary.inc?rev=304707&r1=304706&r2=304707&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/DynamicLibrary.inc (original)
+++ llvm/trunk/lib/Support/Unix/DynamicLibrary.inc Mon Jun  5 06:22:18 2017
@@ -101,10 +101,10 @@ static void *DoSearch(const char* Symbol
 #define EXPLICIT_SYMBOL(SYM) \
    if (!strcmp(SymbolName, #SYM)) return &SYM
 
-// On linux we have a weird situation. The stderr/out/in symbols are both
+// Under glibc we have a weird situation. The stderr/out/in symbols are both
 // macros and global variables because of standards requirements. So, we
 // boldly use the EXPLICIT_SYMBOL macro without checking for a #define first.
-#if defined(__linux__) and !defined(__ANDROID__)
+#if defined(__GLIBC__)
   {
     EXPLICIT_SYMBOL(stderr);
     EXPLICIT_SYMBOL(stdout);




More information about the llvm-commits mailing list