driver: use --no-relax form (instead of -no-relax)
Needs RevisionPublic

Authored by trofi on Aug 21 2018, 11:50 PM.

Details

Summary

Some targets define '-n' short option and cause ld to parse
'-no-relax' as -n -o'-relax'. Noticed by RyanGlScott in
https://phabricator.haskell.org/rGHC1cc9061fce42#132967

Use non-ambiguous --no-relax form istead.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

trofi created this revision.Aug 21 2018, 11:50 PM
bgamari accepted this revision.Aug 22 2018, 6:48 AM

Alright, I'm going to go ahead and test/merge this to unstick the build.

This revision is now accepted and ready to land.Aug 22 2018, 6:48 AM

I'm still quite perplexed how I wasn't seeing this.

RyanGlScott requested changes to this revision.Aug 22 2018, 7:03 AM

I'm afraid this doesn't fix things for me either. With this patch, I now experience a different error:

/usr/bin/ld.gold: --no-relax: unknown option
/usr/bin/ld.gold: use the --help option for usage information
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
make[1]: *** [libraries/base/dist-install/build/GHC/Float.o] Error 1
make: *** [all] Error 2

This is with:

$ ld.gold --version
GNU gold (GNU Binutils for Ubuntu 2.24) 1.11
Copyright 2013 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
This revision now requires changes to proceed.Aug 22 2018, 7:03 AM

It sounds like this will need a configure test.

trofi added a comment.Aug 22 2018, 5:16 PM

Oh, that's unfortunate. --no-relax is very old flag in binutils (ld.bfd) and sparc did --no-relax forever.
Sounds like we will need to extend the driver to query $LD at runtime to check for --no-relax support.

I think this change is good even if original change is reverted as it will cause linkage failure instead of obscure -relax file creation.

Phyx added a subscriber: Phyx.Aug 22 2018, 6:12 PM
In D5085#139881, @trofi wrote:

Oh, that's unfortunate. --no-relax is very old flag in binutils (ld.bfd) and sparc did --no-relax forever.
Sounds like we will need to extend the driver to query $LD at runtime to check for --no-relax support.

Why not just fix the configure time check instead of doing this at runtime. The ldIsGnuLd configure check should probably be extended to check for --no-relax support.

trofi added a comment.Aug 23 2018, 3:54 AM

Why not just fix the configure time check instead of doing this at runtime. The ldIsGnuLd configure check should probably be extended to check for --no-relax support.

Should work as well.

One note: ld.gold is GNU ld. ldIsGnuLd would have to change name or expand the meaning what ldIsGnuLd is supposed to mean. Or another relax-specific variable would need to be added.

Phyx added a comment.Aug 23 2018, 4:04 AM

Hmm right, gold does support --relax, jus not --no-relax, maybe just
add a new test for this and just wire it through like LdIsGnuLd. I think
we might be using that one for split-sections support to? Not sure, haven't
checked what else it's used for.

trofi added a comment.Aug 27 2018, 3:35 PM
In D5085#139913, @Phyx wrote:

Hmm right, gold does support --relax, jus not --no-relax

Which ld.gold version you are talking about? Your local version, what GHC supports or something else?

$ ld.gold --help 2>&1 | fgrep -i relax
  --relax                     Relax branches on certain targets
  --no-relax                  Do not relax branches (default)

$ ld.gold --version
GNU gold (Gentoo 2.31.1 p1 2.31.1) 1.16

maybe just add a new test for this and just wire it through like LdIsGnuLd. I think
we might be using that one for split-sections support to?

Which flag you are talking about here? --relax or --no-relax?

no-relax is used for partial linking (ld -r) when multiple .o files are merged together
into a single .o to simplify build system.

For example capi FFI on targets where relax is default behaviour (at least sparc) requires no-relax.

Phyx added a comment.Aug 27 2018, 4:05 PM
In D5085#140461, @trofi wrote:
In D5085#139913, @Phyx wrote:

Hmm right, gold does support --relax, jus not --no-relax

Which ld.gold version you are talking about? Your local version, what GHC supports or something else?

I was talking about my local version on Ubuntu xenial.

$ ld.gold --help 2>&1 | fgrep -i relax
  --relax                     Relax branches on certain targets
  --no-relax                  Do not relax branches (default)

$ ld.gold --version
GNU gold (Gentoo 2.31.1 p1 2.31.1) 1.16

Yes, it seems --no-relax support for gold was introduced in binutils 2.29, which is relatively recent.
So if you're using Ubuntu LTS releases like trusty or xenial you won't have it. Bionic is the first
version that would since that has 2.30.

maybe just add a new test for this and just wire it through like LdIsGnuLd. I think
we might be using that one for split-sections support to?

Which flag you are talking about here? --relax or --no-relax?

You want to pass --no-relax don't you? so just test the linker for support for it at configure time
like we do the rest of the linker options and put it in the setting file with the rest and read it in
in SysTools with the other options.

no-relax is used for partial linking (ld -r) when multiple .o files are merged together
into a single .o to simplify build system.

For example capi FFI on targets where relax is default behaviour (at least sparc) requires no-relax.