Bug 222641 - www/firefox: OPTIMIZED_CFLAGS=off build fails: libgkrust.a: could not read symbols
Summary: www/firefox: OPTIMIZED_CFLAGS=off build fails: libgkrust.a: could not read sy...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: freebsd-gecko (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-27 13:43 UTC by Rob Belics
Modified: 2018-01-04 22:18 UTC (History)
10 users (show)

See Also:
jbeich: maintainer-feedback+
jbeich: maintainer-feedback? (toolchain)


Attachments
pkg query output (21.03 KB, text/plain)
2017-09-28 13:25 UTC, Rob Belics
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rob Belics 2017-09-27 13:43:20 UTC
INPUT("../../media/psshparser/Unified_cpp_media_psshparser0.o")
    INPUT("StaticXULComponentsEnd/StaticXULComponentsEnd.o")

x86_64-unknown-freebsd/release/libgkrust.a: could not read symbols: File format not recognized
c++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[7]: *** [/usr/ports/www/firefox/work/firefox-56.0/config/rules.mk:719: libxul.so] Error 1
gmake[7]: Leaving directory '/usr/ports/www/firefox/work/firefox-56.0/obj-x86_64-unknown-freebsd11.1/toolkit/library'
gmake[6]: *** [/usr/ports/www/firefox/work/firefox-56.0/config/recurse.mk:73: toolkit/library/target] Error 2
gmake[6]: Leaving directory '/usr/ports/www/firefox/work/firefox-56.0/obj-x86_64-unknown-freebsd11.1'
gmake[5]: *** [/usr/ports/www/firefox/work/firefox-56.0/config/recurse.mk:33: compile] Error 2
gmake[5]: Leaving directory '/usr/ports/www/firefox/work/firefox-56.0/obj-x86_64-unknown-freebsd11.1'
gmake[4]: *** [/usr/ports/www/firefox/work/firefox-56.0/config/rules.mk:453: default] Error 2
gmake[4]: Leaving directory '/usr/ports/www/firefox/work/firefox-56.0/obj-x86_64-unknown-freebsd11.1'
gmake[3]: *** [/usr/ports/www/firefox/work/firefox-56.0/client.mk:419: realbuild] Error 2
gmake[3]: Leaving directory '/usr/ports/www/firefox/work/firefox-56.0'
gmake[2]: *** [/usr/ports/www/firefox/work/firefox-56.0/client.mk:170: build] Error 2
gmake[2]: Leaving directory '/usr/ports/www/firefox/work/firefox-56.0'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/www/firefox
*** Error code 1
Comment 1 Jan Beich freebsd_committer freebsd_triage 2017-09-28 04:28:19 UTC
> x86_64-unknown-freebsd/release/libgkrust.a: could not read symbols: File format not recognized

What FreeBSD version? Can you list selected port options? Can you show output for pkg query '%o: %v'? If ld.bfd is too old try the following:

  $ pkg install binutils
  $ export COMPILER_PATH=/usr/local/bin

FWIW, pkg-fallout@ didn't complain:

http://beefy5.nyi.freebsd.org/data/103i386-default/450797/logs/firefox-56.0,1.log
http://beefy6.nyi.freebsd.org/data/103amd64-default/450797/logs/firefox-56.0,1.log
http://beefy10.nyi.freebsd.org/data/110i386-default/450797/logs/firefox-56.0,1.log
http://beefy9.nyi.freebsd.org/data/110amd64-default/450797/logs/firefox-56.0,1.log
Comment 2 Rainer Hurling freebsd_committer freebsd_triage 2017-09-28 08:49:34 UTC
(In reply to Jan Beich from comment #1)
Hi Jan,

I had the same problem on recent HEAD like Rob described, and can confirm, that   

  $ pkg install binutils
  $ export COMPILER_PATH=/usr/local/bin

solves the problem. Obviously, there is a problem with compiler versions?

Thanks for your hint.
Comment 3 Tod McQuillin 2017-09-28 09:06:06 UTC
I'm seeinx86_64-unknown-freebsd/release/libgkrust.a: could not read symbols: File format not recognized

c++: error: linker command failed with exit code 1 (use -v to see invocation)
g the same failure on 11.1-STABLE with firefox-56.0

FreeBSD sodalime.pun-pun.prv 11.1-STABLE FreeBSD 11.1-STABLE #20 r322604: Thu Aug 17 18:47:07 JST 2017     devin@sodalime.pun-pun.prv:/usr/obj/usr/src/sys/SODALIME  amd64
Comment 4 Rob Belics 2017-09-28 13:25:52 UTC
Created attachment 186783 [details]
pkg query output
Comment 5 Rob Belics 2017-09-28 13:26:40 UTC
Yes, I forgot FreeBSD version is 11.1. Port options are the defaults.
Comment 6 Spas Marinov 2017-09-28 13:39:56 UTC
I also experienced this:

x86_64-unknown-freebsd/release/libgkrust.a: could not read symbols: File format not recognized

But setting this environment fixed it:

export COMPILER_PATH=/usr/local/bin
Comment 7 Jan Beich freebsd_committer freebsd_triage 2017-09-29 00:50:28 UTC
Maybe someone from toolchain@ has a clue.
Comment 8 Konstantin Belousov freebsd_committer freebsd_triage 2017-09-29 07:11:47 UTC
(In reply to Jan Beich from comment #7)
There are a lot of clues in the reports.  I am almost sure, that the error message comes out because in-tree ld(1) does not know about some relocation type used by some object file included into libgkrust.a.  When people install the binutils from ports and set a knob to force use /usr/local/bin/ld, the build finishes successfully because new ld understands this relocation.

The solution would be to force use binutils port ld(1) for linking.

libgkrust.a is produced by the rust compiler, unless I am wrong.  It probably triggers some code generation paths in llvm backend which caused to issue unusual relocations, which typically not created by clang.  So the C compilation is not affected and do not trip old linker in base.
Comment 9 Kurt Jaeger freebsd_committer freebsd_triage 2017-10-03 19:12:47 UTC
Reproduced the problem in poudriere, see

http://people.freebsd.org/~pi/logs/firefox-56.0_1,1.log
Comment 10 david 2017-10-03 19:30:06 UTC
While I have not encountered the issue, some of the other comments reminded me of bug #220481 (where the ar(1) that was invoked by the gcc5 toolchain is the one found in the execution search path -- not necessarily the one that was part of the gcc5 toolchain).
Comment 11 Dimitry Andric freebsd_committer freebsd_triage 2017-10-03 21:33:18 UTC
(In reply to Kurt Jaeger from comment #9)
> Reproduced the problem in poudriere, see
> 
> http://people.freebsd.org/~pi/logs/firefox-56.0_1,1.log

Can you figure out the location of the bad libgkrust.a file, and run file(1) on it?  If it says "thin archive", that will be the cause for the failure.
Comment 12 Rob Belics 2017-10-03 21:59:13 UTC
If it helps. I'm building it from ports and found it only in /usr/ports/www/firefox/work/firefox-56.0/obj-x86_64-unknown-freebsd11.1/toolkit/library/x86_64-unknown-freebsd/release and not on my system.

Running 'file' on it returns "current ar archive"
Comment 13 Jan Beich freebsd_committer freebsd_triage 2017-10-03 23:50:53 UTC
OPTIMIZED_CFLAGS=off adds RUSTFLAGS += -C opt-level=0 but the issue seems limited to --enable-stylo builds (default on amd64) which invoke rust-bindgen (uses libclang.so from devel/llvm40) to integrate Style system from Servo with the rest of Gecko.
Comment 14 Kurt Jaeger freebsd_committer freebsd_triage 2017-10-04 07:58:21 UTC
OPTIMIZED_CFLAGS=on allows ff 56 to build. Thanks!
Comment 15 Rob Belics 2017-10-04 21:39:23 UTC
(In reply to Kurt Jaeger from comment #14)
That did not work for me. Got the same error.
Comment 16 Kurt Jaeger freebsd_committer freebsd_triage 2017-10-05 05:24:35 UTC
(In reply to Rob Belics from comment #15)
Did you build in poudriere or on the main system ?
Comment 17 Craig Leres freebsd_committer freebsd_triage 2017-10-05 05:39:37 UTC
(In reply to Kurt Jaeger from comment #16)

As a data point I build with poudriere and can only build if OPTIMIZED_CFLAGS is enabled (10.3-RELEASE-p21).
Comment 18 Kurt Jaeger freebsd_committer freebsd_triage 2017-10-05 06:23:36 UTC
(In reply to Dimitry Andric from comment #11)
I'm running a testbuild for this right now, with -i to catch the file in question.
Comment 19 Rob Belics 2017-10-05 09:31:26 UTC
(In reply to Kurt Jaeger from comment #16)
I use "portmaster -m OPTIMIZED_CFLAGS=on firefox"
Comment 20 Jan Beich freebsd_committer freebsd_triage 2017-10-05 09:49:05 UTC
(In reply to Rob Belics from comment #19)
> I use "portmaster -m OPTIMIZED_CFLAGS=on firefox"

That doesn't do anything useful. See bug 170180 for how to override options on command line.
Comment 21 Rob Belics 2017-10-05 09:56:21 UTC
(In reply to Jan Beich from comment #20)
I've used it twice fairly recently and it worked. It's also the instructions in the man page for portmaster (the -m part).
Comment 22 Jan Beich freebsd_committer freebsd_triage 2017-10-05 10:17:08 UTC
Discussing portmaster bugs is off-topic. I'm also biased. Please, use bare build if poudriere is too hard/heavy for you:

  $ make clean all deinstall install WITH=OPTIMIZED_CFLAGS -C /usr/ports/www/firefox

(In reply to Rob Belics from comment #21)
> I've used it twice fairly recently and it worked.

Placebo? Or did you use a different syntax?

> the man page for portmaster (the -m part).

Can you quote the relevant part?
Comment 23 Rob Belics 2017-10-05 10:25:15 UTC
(In reply to Jan Beich from comment #22)

>Discussing portmaster bugs is off-topic.

You brought it up.

>Placebo? Or did you use a different syntax?

I just quoted what I did.

>Can you quote the relevant part?

Do "man portmaster" and search in vim with /-m 

I hope that's not too hard/heavy for you.

>make clean all deinstall install WITH=OPTIMIZED_CFLAGS -C /usr/ports/www/firefox

I'll try this in an hour or two.
Comment 24 Jan Beich freebsd_committer freebsd_triage 2017-10-05 10:55:45 UTC
(In reply to Rob Belics from comment #23)
>>Can you quote the relevant part?
> Do "man portmaster" and search in vim with /-m 
> I hope that's not too hard/heavy for you.

Where did portmaster manpage suggests how to use -m flag to override port options?  "portmaster -m WITH=OPTIMIZED_CFLAGS firefox" may have worked as intended.
Comment 25 Rob Belics 2017-10-05 11:25:17 UTC
(In reply to Jan Beich from comment #24)

I thought you were complaining about the -m option.

This works at upgraded Firefox:

"make clean all deinstall install WITH=OPTIMIZED_CFLAGS -C /usr/ports/www/firefox"
Comment 26 Kurt Jaeger freebsd_committer freebsd_triage 2017-10-08 10:11:31 UTC
(In reply to Kurt Jaeger from comment #18)
I was not able to catch the libgkrust file as of now.
Comment 27 Mikhail T. 2017-11-25 15:59:13 UTC
I just had this problem too trying to build 57.0_2,1, and was able to overcome it by setting the environment variable COMPILER_PATH to /opt/bin (/opt is what I use for LOCALBASE) and simply rerunning the build -- without cleaning and rebuilding.

My options are:

# This file is auto-generated by 'make config'.
# Options for firefox-57.0_2,1
_OPTIONS_READ=firefox-57.0_2,1
_FILE_COMPLETE_OPTIONS_LIST=BUNDLED_CAIRO CANBERRA DBUS DEBUG DTRACE FFMPEG GCONF INTEGER_SAMPLES LIBPROXY OPTIMIZED_CFLAGS PROFILE TEST ALSA JACK PULSEAUDIO SNDIO
OPTIONS_FILE_UNSET+=BUNDLED_CAIRO
OPTIONS_FILE_UNSET+=CANBERRA
OPTIONS_FILE_SET+=DBUS
OPTIONS_FILE_UNSET+=DEBUG
OPTIONS_FILE_UNSET+=DTRACE
OPTIONS_FILE_SET+=FFMPEG
OPTIONS_FILE_UNSET+=GCONF
OPTIONS_FILE_UNSET+=INTEGER_SAMPLES
OPTIONS_FILE_UNSET+=LIBPROXY
OPTIONS_FILE_UNSET+=OPTIMIZED_CFLAGS
OPTIONS_FILE_UNSET+=PROFILE
OPTIONS_FILE_UNSET+=TEST
OPTIONS_FILE_SET+=ALSA
OPTIONS_FILE_UNSET+=JACK
OPTIONS_FILE_UNSET+=PULSEAUDIO
OPTIONS_FILE_UNSET+=SNDIO
Comment 28 commit-hook freebsd_committer freebsd_triage 2017-12-31 00:57:44 UTC
A commit references this bug:

Author: jbeich
Date: Sun Dec 31 00:57:07 UTC 2017
New revision: 457657
URL: https://svnweb.freebsd.org/changeset/ports/457657

Log:
  www/firefox: unbreak OPTIMIZED_CFLAGS=off build after r450707

  x86_64-unknown-freebsd/release/libgkrust.a: could not read symbols: File format not recognized

  PR:		222641
  Reported by:	many

Changes:
  head/Mk/bsd.gecko.mk
Comment 29 commit-hook freebsd_committer freebsd_triage 2017-12-31 00:58:50 UTC
A commit references this bug:

Author: jbeich
Date: Sun Dec 31 00:58:13 UTC 2017
New revision: 457658
URL: https://svnweb.freebsd.org/changeset/ports/457658

Log:
  MFH: r457657

  www/firefox: unbreak OPTIMIZED_CFLAGS=off build after r450707

  x86_64-unknown-freebsd/release/libgkrust.a: could not read symbols: File format not recognized

  PR:		222641
  Reported by:	many
  Approved by:	ports-secteam blanket

Changes:
_U  branches/2017Q4/
  branches/2017Q4/Mk/bsd.gecko.mk
Comment 30 Jan Beich freebsd_committer freebsd_triage 2018-01-04 22:18:26 UTC
OPTIMIZED_CFLAGS=off is still broken on 11.1 i386 because new ld.bfd cannot handle DTRACE=on for some reason.

/usr/local/bin/ld: ../../js/src/js-dtrace.o: warning: relocation against `_ZN2js13ExecuteKernelEP9JSContextN2JS6HandleIP8JSScriptEER8JSObjectRKNS2_5ValueENS_16AbstractFramePtrEPS9_' in readonly section `.SUNW_dof'
/usr/local/bin/ld: read-only segment has dynamic relocations.

build log: https://ptpb.pw/Erv2