Opened 8 years ago

Closed 8 years ago

#12439 closed bug (fixed)

gcc 2 won't build a non-position-independent executable

Reported by: simonsouth Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: System Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

(This is the legacy-buildtools equivalent of #12430.)

The attached patches align gcc 2.95 and ld 2.17 with recent changes to their new-world counterparts. With the patches applied

  • The default behaviour of gcc and ld is not changed.
  • Users can ask gcc to build a non-position-independent executable with the -fno-pic option.
  • Position-independent executables are built by default, using the -fPIC compiler setting and by explicitly specifying -pie to the linker.
  • An INTERP segment is included in every executable with a link to /system/runtime_loader.

Attachments (2)

0001-gcc2-Allow-the-user-to-build-non-PI-executables.patch (4.0 KB ) - added by simonsouth 8 years ago.
gcc2: Allow the user to build non-PI executables
0002-binutils-legacy-ld-Set-ELF-interpreter-to-system-run.patch (1.6 KB ) - added by simonsouth 8 years ago.
binutils (legacy): ld: Set ELF interpreter to /system/runtime_loader

Download all attachments as: .zip

Change History (6)

comment:1 by simonsouth, 8 years ago

patch: 01

comment:2 by korli, 8 years ago

Linking displays messages now (lib not found).

jam -q playwav
Starting build of type regular ... 
WebKit build feature not available for x86_gcc2 
...patience...
...patience...
...found 11601 target(s)...
...updating 1 target(s)...
Link /home/korli/githaiku/haiku/generated_gcc2/objects/haiku/x86_gcc2/release/bin/playsound/playwav 
/home/korli/githaiku/haiku/generated_gcc2/cross-tools-x86_gcc2/i586-pc-haiku/bin/ld: warning: libstdc++.r4.so, needed by /home/korli/githaiku/haiku/generated_gcc2/objects/haiku/x86_gcc2/release/kits/libbe.so, not found (try using -rpath or -rpath-link)
/home/korli/githaiku/haiku/generated_gcc2/cross-tools-x86_gcc2/i586-pc-haiku/bin/ld: warning: libicudata.so.55, needed by /home/korli/githaiku/haiku/generated_gcc2/objects/haiku/x86_gcc2/release/kits/libbe.so, not found (try using -rpath or -rpath-link)
/home/korli/githaiku/haiku/generated_gcc2/cross-tools-x86_gcc2/i586-pc-haiku/bin/ld: warning: libicui18n.so.55, needed by /home/korli/githaiku/haiku/generated_gcc2/objects/haiku/x86_gcc2/release/kits/libbe.so, not found (try using -rpath or -rpath-link)
/home/korli/githaiku/haiku/generated_gcc2/cross-tools-x86_gcc2/i586-pc-haiku/bin/ld: warning: libicuio.so.55, needed by /home/korli/githaiku/haiku/generated_gcc2/objects/haiku/x86_gcc2/release/kits/libbe.so, not found (try using -rpath or -rpath-link)
/home/korli/githaiku/haiku/generated_gcc2/cross-tools-x86_gcc2/i586-pc-haiku/bin/ld: warning: libicule.so.55, needed by /home/korli/githaiku/haiku/generated_gcc2/objects/haiku/x86_gcc2/release/kits/libbe.so, not found (try using -rpath or -rpath-link)
/home/korli/githaiku/haiku/generated_gcc2/cross-tools-x86_gcc2/i586-pc-haiku/bin/ld: warning: libiculx.so.55, needed by /home/korli/githaiku/haiku/generated_gcc2/objects/haiku/x86_gcc2/release/kits/libbe.so, not found (try using -rpath or -rpath-link)
/home/korli/githaiku/haiku/generated_gcc2/cross-tools-x86_gcc2/i586-pc-haiku/bin/ld: warning: libicutu.so.55, needed by /home/korli/githaiku/haiku/generated_gcc2/objects/haiku/x86_gcc2/release/kits/libbe.so, not found (try using -rpath or -rpath-link)
/home/korli/githaiku/haiku/generated_gcc2/cross-tools-x86_gcc2/i586-pc-haiku/bin/ld: warning: libicuuc.so.55, needed by /home/korli/githaiku/haiku/generated_gcc2/objects/haiku/x86_gcc2/release/kits/libbe.so, not found (try using -rpath or -rpath-link)
/home/korli/githaiku/haiku/generated_gcc2/cross-tools-x86_gcc2/i586-pc-haiku/bin/ld: warning: libz.so.1, needed by /home/korli/githaiku/haiku/generated_gcc2/objects/haiku/x86_gcc2/release/kits/libbe.so, not found (try using -rpath or -rpath-link)
SetType1 /home/korli/githaiku/haiku/generated_gcc2/objects/haiku/x86_gcc2/release/bin/playsound/playwav 
MimeSet1 /home/korli/githaiku/haiku/generated_gcc2/objects/haiku/x86_gcc2/release/bin/playsound/playwav 
SetVersion1 /home/korli/githaiku/haiku/generated_gcc2/objects/haiku/x86_gcc2/release/bin/playsound/playwav 
Chmod1 /home/korli/githaiku/haiku/generated_gcc2/objects/haiku/x86_gcc2/release/bin/playsound/playwav 
...updated 1 target(s)...

by simonsouth, 8 years ago

gcc2: Allow the user to build non-PI executables

by simonsouth, 8 years ago

binutils (legacy): ld: Set ELF interpreter to /system/runtime_loader

comment:3 by simonsouth, 8 years ago

I've updated both patches. The first patch additionally

  • Refactors LINK_SPEC to pass both the --no-add-needed and --allow-shlib-undefined options to the linker whenever a dynamically linked executable is being built. This instructs the linker to not recursively add shared libraries as dependencies but to allow undefined symbols in them (expected for BeOS and Haiku).
  • Patches the linker to skip recursively resolving the dependencies of a shared library if the --no-add-needed and --allow-shlib-undefined options are set. This was made the default behaviour of ld after binutils 2.17 (which is why this issue doesn't come up when building with gcc 4); effectively this change backports binutils commit 4706eab, which was a refinement of 8fbb09e.

You should find this allows the build to complete without those missing-library warnings.

I've modified the description in the second patch to use a short GUID for the commit it mentions.

comment:4 by korli, 8 years ago

Resolution: fixed
Status: newclosed

Very good! Applied in btrev43111. Thanks!

Note: See TracTickets for help on using tickets.