Bug 1639969 - After recent update, gold linker crashes while building chromium with fedora build flags
Summary: After recent update, gold linker crashes while building chromium with fedora ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: binutils
Version: rawhide
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Nick Clifton
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-10-17 03:49 UTC by Akarshan Biswas
Modified: 2019-02-02 03:35 UTC (History)
6 users (show)

Fixed In Version: binutils-2.31.1-17.fc29
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-02-02 03:35:29 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Akarshan Biswas 2018-10-17 03:49:39 UTC
Description of problem:
After the recent update of binutils on rawhide, gold linker crashes while building chromium with fedora build flags.

Version-Release number of selected component (Current, which doesn't work):
2.31.1-14.fc30

Version-Release number of selected component(which worked):
2.31.1-13.fc30

How reproducible:
Everytime with the new update

Steps to Reproduce:
1. Run chromium with GCC and fedora build flags with gold turned on


Actual results:
It failed at:
FAILED: transport_security_state_generator 
/usr/bin/python2 "../../build/toolchain/gcc_link_wrapper.py" --output="./transport_security_state_generator" -- g++ -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--as-needed -fuse-ld=gold -B../../third_party/binutils/Linux_x64/Release/bin -m64 -Wl,-O2 -Wl,--gc-sections -rdynamic -Wl,-rpath-link=. -Wl,--disable-new-dtags -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -o "./transport_security_state_generator" -Wl,--start-group @"./transport_security_state_generator.rsp"  -Wl,--end-group   -latomic -ldl -lpthread -lrt -lgmodule-2.0 -lglib-2.0 -lgobject-2.0 -lgthread-2.0 -lsmime3 -lnss3 -lnssutil3 -lplds4 -lplc4 -lnspr4 
/usr/bin/ld.gold: internal error in add_output_section_to_load, at output.cc:4148
collect2: error: ld returned 1 exit status

Expected results:
It should passed as it was passing before and on older releases of fedora(i,e 28, 29)

Additional info:

Might be related to this commit: https://src.fedoraproject.org/rpms/binutils/c/b25b0811ad427c673aadfa81552ec8fe2bd14f51

Comment 1 Nick Clifton 2018-11-14 16:09:53 UTC
Hi Akarshan,

  I am having trouble reproducing this failure, not least because it takes
  so long to build chromium.  But when I do, the build ends with this 
  failure:

[3453/21626] /usr/bin/python2 "../../build/toolchain/gcc_solink_wrapper.py" --readelf="readelf" --nm="nm" --sofile="./libembedder_switches.so" --tocfile="./libembedder_switches.so.TOC" --output="./libembedder_switches.so" -- g++ -shared -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--as-needed -fuse-ld=gold -B../../third_party/binutils/Linux_x64/Release/bin -m64 -Wl,-O2 -Wl,--gc-sections -rdynamic -o "./libembedder_switches.so" -Wl,-soname="libembedder_switches.so" @"./libembedder_switches.so.rsp"
FAILED: libembedder_switches.so libembedder_switches.so.TOC 
/usr/bin/python2 "../../build/toolchain/gcc_solink_wrapper.py" --readelf="readelf" --nm="nm" --sofile="./libembedder_switches.so" --tocfile="./libembedder_switches.so.TOC" --output="./libembedder_switches.so" -- g++ -shared -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--as-needed -fuse-ld=gold -B../../third_party/binutils/Linux_x64/Release/bin -m64 -Wl,-O2 -Wl,--gc-sections -rdynamic -o "./libembedder_switches.so" -Wl,-soname="libembedder_switches.so" @"./libembedder_switches.so.rsp"
/usr/bin/ld.gold: warning: discarding version information for __cxa_finalize.5, defined in unused shared library /lib64/libc.so.6 (linked with --as-needed)
/usr/bin/ld.gold: error: treating warnings as errors
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
error: Bad exit status from /var/tmp/rpm-tmp.jy0sMv (%build)

  Which I think is a problem with the chromium build files.  

  I did make one other change to the chromium.spec file, apart from
  enabling gold, which was to add the -j1 option to the ninja invocations
  so that the builds would not happen in parallel.  I did this to ensure
  that the error messages would be related to the compilation/linkage that
  had just been displayed in the logs.

  Can you tell me which component of chromium is being built when the error
  you encountered is reported ?

Comment 2 Akarshan Biswas 2018-11-15 04:13:23 UTC
Hi Nick,

Your chromium build failed because you're treating "warnings as errors" but that's not the case.

First you have to enable fedora build flags and carefully omit out few flags as they are not compatible with chromium code such as -fexceptions.
```
#Build flags to make hardened binaries
#Remove some flags which are not required/incompatible with chromium code. 
CBUILDFLAGS="$(echo '%{__global_cflags}' | sed -e 's/-fexceptions//' \
                                               -e 's/-Werror=format-security//' \
                                               -e 's/-pipe//' \
                                               -e 's/-g1record-g1cc-switches//' \
                                               -e 's/^-g / /g' -e 's/ -g / /g' -e 's/ -g$//g')"
CXXBUILDFLAGS="$(echo '%{?__global_cxxflags}%{!?__global_cxxflags:%{__global_cflags}}' | sed -e 's/-fexceptions//' \
                                                                                            -e 's/-Werror=format-security//' \
                                                                                            -e 's/-pipe//' \
                                                                                            -e 's/-g1record-g1cc-switches//' \
                                                                                            -e 's/^-g / /g' -e 's/ -g / /g' -e 's/ -g$//g')"   
export CFLAGS="${CBUILDFLAGS}"
export CXXFLAGS="${CXXBUILDFLAGS} -fpermissive"
export LDFLAGS='%{__global_ldflags}'
```




Second, try building only the browser not the headless.
I haven't used gold for a while in rawhide because of this but I need it to build chromium for rpi/arm32.

Comment 3 Akarshan Biswas 2018-11-15 04:20:23 UTC
Edit: I think this gyp flag is needed to fix "treating warnings as errors" error :

treat_warnings_as_errors=false

Comment 4 Nick Clifton 2018-11-16 15:59:10 UTC
Hi Akarshan,

  I am sorry, but I am still unable to reproduce this problem. :-(

  Can you upload the transport_security_state_generator.rsp file, as
  generated by 

    /usr/bin/python2 "../../build/toolchain/gcc_link_wrapper.py" 
    --output="./transport_security_state_generator"

  (which does not seem to work for me) and I will try again.

Cheers
  Nick

Comment 5 Akarshan Biswas 2018-11-30 06:49:08 UTC
@Nick
Hello. Since I'm travelling atm, let me return home. I will provide you a srpm to test. 
Testing condition will be targetted on the mentioned version of binutils.

I will probably return next week. 


Regards,
Akarshan.

Comment 6 Fedora Update System 2019-01-30 12:46:24 UTC
binutils-2.31.1-17.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-ba3cbcfd20

Comment 7 Fedora Update System 2019-01-31 02:30:17 UTC
binutils-2.31.1-17.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-ba3cbcfd20

Comment 8 Fedora Update System 2019-02-02 03:35:29 UTC
binutils-2.31.1-17.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.