Bug 1639969

Summary: After recent update, gold linker crashes while building chromium with fedora build flags
Product: [Fedora] Fedora Reporter: Akarshan Biswas <akarshan.biswas>
Component: binutilsAssignee: Nick Clifton <nickc>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: akarshan.biswas, aoliva, dvlasenk, fweimer, jakub, nickc
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Fixed In Version: binutils-2.31.1-17.fc29 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-02-02 03:35:29 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

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):

Version-Release number of selected component(which worked):

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 

[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@GLIBC_2.2.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 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 :


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" 

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


Comment 5 Akarshan Biswas 2018-11-30 06:49:08 UTC
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. 


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.