neurocyte / ghc-android

Build scripts for building ghc cross compilers targeting Android
182 stars 29 forks source link

Build fails with "Can't use -fPIC or -dynamic on this platform" #11

Closed Tener closed 11 years ago

Tener commented 11 years ago

I tried to run ./build on my Arch Linux, x86-64 PC. Lots of things compile but now it's failing at this line:

"inplace/bin/ghc-stage1" -M -fPIC -dynamic  -H64m -O0 -fasm    -hide-all-packages -i -iutils/compare_sizes/. -iutils/compare_sizes/dist-install/build -iutils/compare_sizes/dist-install/build/autogen -Iutils/compare_sizes/dist-install/build -Iutils/compare_sizes/dist-install/build/autogen     -optP-include -optPutils/compare_sizes/dist-install/build/autogen/cabal_macros.h -package base-4.7.0.0 -package directory-1.2.0.1 -package filepath-1.3.0.2 -XHaskell98  -no-user-package-db -rtsopts      -odir utils/compare_sizes/dist-install/build -hidir utils/compare_sizes/dist-install/build -stubdir utils/compare_sizes/dist-install/build -dep-makefile utils/compare_sizes/dist-install/build/.depend.haskell.tmp -dep-suffix "dyn_" -include-pkg-deps  utils/compare_sizes/./Main.hs
: Can't use -fPIC or -dynamic on this platform
make[1]: *** [utils/compare_sizes/dist-install/build/.depend.haskell] Błąd 1

The ghc-stage1 reports this information:

inplace/bin/ghc-stage1 --info
 [("Project name","The Glorious Glasgow Haskell Compilation System")
 ,("GCC extra via C opts"," -fwrapv")
 ,("C compiler command","/home/tener/.ghc/android-14/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc")
 ,("C compiler flags"," -fno-stack-protector")
 ,("C compiler link flags","")
 ,("ld command","/home/tener/.ghc/android-14/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-ld")
 ,("ld flags","")
 ,("ld supports compact unwind","YES")
 ,("ld supports build-id","YES")
 ,("ld supports filelist","NO")
 ,("ld is GNU ld","YES")
 ,("ar command","/usr/bin/ar")
 ,("ar flags","q")
 ,("ar supports at file","YES")
 ,("touch command","touch")
 ,("dllwrap command","/bin/false")
 ,("windres command","/bin/false")
 ,("perl command","/usr/bin/perl")
 ,("target os","OSAndroid")
 ,("target arch","ArchARM {armISA = ARMv5, armISAExt = [], armABI = SOFT}")
 ,("target word size","4")
 ,("target has GNU nonexec stack","False")
 ,("target has .ident directive","True")
 ,("target has subsections via symbols","False")
 ,("Unregisterised","NO")
 ,("LLVM llc command","/usr/bin/llc")
 ,("LLVM opt command","/usr/bin/opt")
 ,("Project version","7.7.20130417")
 ,("Booter version","7.4.1")
 ,("Stage","1")
 ,("Build platform","x86_64-unknown-linux")
 ,("Host platform","x86_64-unknown-linux")
 ,("Target platform","arm-unknown-linux-android")
 ,("Have interpreter","YES")
 ,("Object splitting supported","NO")
 ,("Have native code generator","NO")
 ,("Support SMP","YES")
 ,("Tables next to code","YES")
 ,("RTS ways","l debug  thr thr_debug thr_l  dyn debug_dyn thr_dyn thr_debug_dyn l_dyn thr_l_dyn")
 ,("Dynamic by default","NO")
 ,("GHC Dynamic","YES")
 ,("Leading underscore","NO")
 ,("Debug on","False")
 ,("LibDir","/home/tener/dokumenty/forks/ghc-android/build-android-14-arm-linux-androideabi-4.7/ghc/inplace/lib")
 ,("Global Package DB","/home/tener/dokumenty/forks/ghc-android/build-android-14-arm-linux-androideabi-4.7/ghc/inplace/lib/package.conf.d")
 ]

inplace/bin/ghc-stage1 -V    
The Glorious Glasgow Haskell Compilation System, version 7.7.20130417

neurocyte commented 11 years ago

It looks like upstream changes have broken things. Will will have to remove the -fPIC option somehow because that is not supported on android afaik.

Tener commented 11 years ago

Ah, too bad. The commit that introduces this error message is from Oct 2012: http://www.haskell.org/pipermail/cvs-ghc/2012-October/076730.html

The code in question is: https://github.com/ghc/ghc/blob/master/compiler/main/DynFlags.hs#L3429

To be honest I'm not sure it does the right thing - the code is hard to read and I dont know what which flag mean.

Perhaps it simply doesn't take Android into account?

neurocyte commented 11 years ago

My last successful build was on 7th March. So that can’t be it. I think Ian Lynagh's clean-up of the build system a couple weeks ago changed something.

neurocyte commented 11 years ago

Probably commit 84df08debf13562f8a1fc7cd59054aaa9c379294

https://github.com/ghc/ghc/commit/84df08debf13562f8a1fc7cd59054aaa9c379294

Tener commented 11 years ago

That was just a wild guess. What is your recommendation on how to get a working build?

neurocyte commented 11 years ago

You could try reverting https://github.com/neurocyte/ghc-android/commit/84df08debf13562f8a1fc7cd59054aaa9c379294

Tener commented 11 years ago

It didn't work unfortunately, nothing appear to have changed. I'll try with 7th March HEAD later.

TrinCZ commented 11 years ago

Finally!

It took some nerves, but .... BUT ... it builds ... installs ... foreign-jni installs ... android-haskell-activity installs ... and works!!! Hooray!

My path to glory:

My greatest admiration to CJ!!!

Now it's time for me to step on the shoulder of giant and actually create something ... see you later.

neurocyte commented 11 years ago

I disabled dynamic linking in the build config, so it should work with the latest ghc head again (for now).