Skip to content
Snippets Groups Projects
Commit d63e6b41 authored by Ben Gamari's avatar Ben Gamari :turtle: Committed by Julian Ospald
Browse files

Don't `foreign import` `environ`

`musl` defines the `environ` symbol as a weak alias, which on AArch64
requires particular treatment by the compiler. As GHC doesn't have
access to the prototype of the symbol, it doesn't know that this
treatment is necessary and consequently we emit assembly that the linker
will choke on.

See GHC #24011.
parent 25b0f118
No related branches found
No related tags found
No related merge requests found
......@@ -22,8 +22,11 @@ getCEnviron = nsGetEnviron >>= peek
foreign import ccall unsafe "_NSGetEnviron"
nsGetEnviron :: IO (Ptr (Ptr CString))
#else
getCEnviron = peek c_environ_p
getCEnviron = _getCEnviron
foreign import ccall unsafe "&environ"
c_environ_p :: Ptr (Ptr CString)
-- N.B. we cannot import `environ` directly in Haskell as it may be a weak symbol
-- which requires special treatment by the compiler, which GHC is not equipped to
-- provide. See GHC #24011.
foreign import ccall unsafe "__hsunix_get_environ"
_getCEnviron :: IO (Ptr CString)
#endif
......@@ -8,6 +8,8 @@
#include "HsUnix.h"
char **__hsunix_get_environ (void) {return environ;}
#ifdef HAVE_RTLDNEXT
void *__hsunix_rtldNext (void) {return RTLD_NEXT;}
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment