-
Notifications
You must be signed in to change notification settings - Fork 29
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
System.Posix.getEnvironment => [] #7
Comments
FWIW: While getEnvironment fails, getEnv works. This test program prints [] three times and then a username. import System.Environment main :: IO () |
This is looking likely to be due to the android linker's handling of R_ARM_COPY relocations; the environ symbol is one such and I supect the linker sets it to point to garbage or null rather than the real environ. On android 4.3/4.4, this apparently instead causes the "ANNOT LINK EXECUTABLE: git-annex invalid R_ARM_COPY relocation against DT_SYMBOLIC shared library libc.so" error -- which I incorrectly earlier thought I'd avoided by upgrading to a newver version of the NDK. The workaround is to pass -optl-z -optlnocopyreloc to ghc, which avoids using this type of relocation. I think that ghc-android will probably need to either make its cabal wrapper do that, or put a wrapper around the android ld.gold (which would also fix ghc when not using cabal). Gory details here: http://git-annex.branchable.com/bugs/git-annex_broken_on_Android_4.3/ |
While -optl-z -optlnocopyreloc makes getEnvironment work on Android 4.3 and 4.4, it unfortunately yields binaries that segfault on Android 4.0.4 whenever they deal with the environment. |
This apparently fails, and always returns a null list.
System.Environment.getEnvironment does work.
I have not checked, but it seems likely other functions in System.Posix.Env are also broken.
Also, there is something weird going on, it seems that in some cases even when System.Environment.getEnvironment should be used, a null list is returned. I have a test case involving an internal module:
import System.Environment
import qualified Internal.Module
main = print =<< getEnvironment
This prints [], and commenting out the second import fixes it. The module is not used at all, but it does import a lot of other modules including System.Posix.Env.
The text was updated successfully, but these errors were encountered: