Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 618366 - app-emulation/dosemu-1.4.1_pre20130107-r3: compilation fails with sys-devel/gcc[pie] + gold linker
Summary: app-emulation/dosemu-1.4.1_pre20130107-r3: compilation fails with sys-devel/g...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Sergei Trofimovich
URL: https://sourceware.org/bugzilla/show_...
Whiteboard:
Keywords:
Depends on:
Blocks: gold-tracker gcc-6 582688
  Show dependency tree
 
Reported: 2017-05-13 13:56 UTC by Martin Väth
Modified: 2017-09-30 15:12 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Failed build.log (app-emulation:dosemu-1.4.1_pre20130107-r3:20170513-134545.log,30.88 KB, text/x-log)
2017-05-13 13:56 UTC, Martin Väth
Details
emerge --info of x86 system (emerge.info,16.43 KB, application/x-info)
2017-05-13 13:57 UTC, Martin Väth
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Väth 2017-05-13 13:56:50 UTC
Created attachment 472502 [details]
Failed build.log

When emerging app-emulation/dosemu-1.4.1_pre20130107-r3 with sys-devel/gcc[pie] and the gold linker enabled, the compilation fails with an error of the type

/usr/lib/gcc/i686-pc-linux-gnu/7.1.0/../../../../i686-pc-linux-gnu/bin/ld: fatal error: binary output format not compatible with -shared or -pie or -r

The error does not occur if _one_ of the following is added to CFLAGS/LDFLAGS

a) -no-pie
b) -fuse-ld=bfd

Of course, (a) is like using sys-devel/gcc[-pie] and (b) is like not enabling the gold linker. Certainly neither is a good solution but just a workaround.
Comment 1 Martin Väth 2017-05-13 13:57:45 UTC
Created attachment 472504 [details]
emerge --info of x86 system

The attached emerge --info is from an x86 system,
but the same issue occurs with an amd64 system
(which has a very similar emerge --info, e.g. with identical package versions)
Comment 2 Martin Väth 2017-05-13 14:01:43 UTC
I forgot a possibly important information:
the used compiler is sys-devel/gcc-7.1.0-r1
Comment 3 Sergei Trofimovich gentoo-dev 2017-05-21 20:06:13 UTC
Interesting!

isemu.S is a 16-bit stub code:

  .text
  .code16
    .globl<>_start16
  _start16:
    ....

Even though result resides in ELF file of the host OS.
Later compiled 16-bit code is copied as a .com file:

    $ x86_64-pc-linux-gnu-gcc -Wl,-warn-common -pie -fuse-ld=gold -Wl,-Ttext,100,-e,_start16,--oformat,binary -nostdlib -s -o ../../1.4.0.8/commands/isemu.com isemu.o

I would argue in this particular case there is no much value in gcc being called instead of 'ld' directly.

As for -fuse-ld=bdf /  -fuse-ld=gold I'm not sure if it's -fuse-ld=bdf's infelicty to accept "-pie --oformat,binary"
or ld.gold's omission.

I'll file a bug to binutils and add a -no-pie workaround to ebuild.
Comment 4 Sergei Trofimovich gentoo-dev 2017-05-24 21:13:28 UTC
Filed ld.gold bug upstream as https://sourceware.org/bugzilla/show_bug.cgi?id=21518
Comment 5 Sergei Trofimovich gentoo-dev 2017-06-01 21:43:00 UTC
toolchain@, what would be the best test if current ${CC} supports -no-pie?

In ghc i', using a version check i'm not happy about:
'tc-is-gcc && version_is_at_least 6.3 $(gcc-version)'

What would be the preferred way to do it?
Comment 6 Sergei Trofimovich gentoo-dev 2017-07-05 21:42:24 UTC
Pushed -no-pie workaround as: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=60c042fa6d30842870a81da6090fc39960304a27

Thanks for the report!