[haiku-bugs] [Haiku] #12430: gcc 4 won't build a non-position-independent executable

  • From: "simonsouth" <trac@xxxxxxxxxxxx>
  • Date: Sun, 25 Oct 2015 07:58:05 -0000

#12430: gcc 4 won't build a non-position-independent executable
------------------------+------------------------------
Reporter: simonsouth | Owner: nobody
Type: bug | Status: new
Priority: normal | Milestone: Unscheduled
Component: System | Version: R1/Development
Keywords: | Blocked By:
Blocking: | Has a Patch: 0
Platform: All |
------------------------+------------------------------
(This is the compile-side counterpart to #12427.)

On Haiku, executables are [https://en.wikipedia.org/wiki/Position-
independent_code#Position-independent_executables position-independent] by
default. However asking gcc (4.8.5) to build a non-position-independent
executable with (for instance) the `-fno-pie` flag fails with an error
message like

{{{
/boot/system/(...)/bin/ld: /tmp//ccxbCP1i.o: relocation R_X86_64_32
against `.rodata' can not be used when making a shared object; recompile
with -fPIC
/tmp//ccxbCP1i.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
}}}

This is because [http://cgit.haiku-
os.org/buildtools/tree/gcc/gcc/config/i386/haiku.h#n56 gcc is configured]
to always pass either the `-r` or `-shared` flag to the linker, and there
is no easy way to override this. But not everything is relocatable or a
shared object, and if the user specifically requests something different,
that request should be honoured.

Consequently apps like GNU Emacs that rely on support for fixed-position
executables cannot be built on Haiku right now.

--
Ticket URL: <https://dev.haiku-os.org/ticket/12430>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: