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

System.Posix.getEnvironment => [] #7

Open
joeyh opened this issue Feb 22, 2013 · 3 comments
Open

System.Posix.getEnvironment => [] #7

joeyh opened this issue Feb 22, 2013 · 3 comments

Comments

@joeyh
Copy link
Contributor

joeyh commented Feb 22, 2013

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.

@joeyh
Copy link
Contributor Author

joeyh commented Feb 22, 2013

FWIW: While getEnvironment fails, getEnv works. This test program prints [] three times and then a username.

import System.Environment
import System.FilePath
import System.Posix.Env

main :: IO ()
main = do
print =<< System.Environment.getEnvironment
print =<< System.Posix.Env.getEnvironment
print =<< System.Posix.Env.getEnvironmentPrim
print =<< System.Posix.Env.getEnv "USER"

@ghost ghost assigned neurocyte May 15, 2013
@joeyh
Copy link
Contributor Author

joeyh commented Nov 12, 2013

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/

@joeyh
Copy link
Contributor Author

joeyh commented Nov 12, 2013

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.

@neurocyte neurocyte removed their assignment Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants