porting to uClibc-based 686 Linux

Dubiousjim lists+haskell-glasgow at jimpryor.net
Thu Apr 18 12:48:12 CEST 2013

On Wed, Apr 17, 2013 at 11:18:52PM +0100, Ian Lynagh wrote:
> On Fri, Apr 05, 2013 at 11:12:38PM -0400, Dubiousjim wrote:
> >     target$ inplace/bin/ghc-stage2 -o hello-cross hello.hs
> >     [1 of 1] Compiling Main             ( hello.hs, hello.o )
> >     Linking hello-cross ...
> >     target$ ./hello-cross
> >     Can't modify application's text section; use the GCC option -fPIE
> >     for position-independent executables.
> You can pass -fPIE to gcc by using the -optc-fPIE flag.
> Thanks
> Ian

Thanks Ian. There's much I don't fully understand about ghc, but I read
somewhere that the 
-optc-* options would only be applied when building via intermediate C
files, which isn't
happening in the compilation process specified above. Is this incorrect,
or have
I misunderstood something?

In any event, adding -optc-fPIE doesn't remove the error message.

That error message is kicked up by uclibc, on account of the hello-cross
binary having a TEXTREL section, which I understand it shouldn't have if
we're generating PIE or PIC code. The instruction to "use the GCC option
is just uclibc's suggestion as to how to avoid this.

I also tried adding -fPIE or -fPIC to the "C compiler flags" section in
inplace/lib/settings, but this didn't resolve the issue.

I also tried using "BuildFlavour = unreg" in mk/build.mk, but this
didn't resolve the issue.

What I thought to try next is to add llvm/clang to my cross-compiler
toolchain, and try building with the -fllvm flag in SRC_HC_OPTS.

Other suggestions will be much welcomed. Thanks.
dubiousjim at gmail.com

More information about the Glasgow-haskell-users mailing list