Closed Bug 1440037 Opened 2 years ago Closed 2 years ago

elfhack lacks support for R_X86_64_PLT32 relocations clang trunk emits

Categories

(Firefox Build System :: General, defect)

defect
Not set

Tracking

(firefox60 fixed)

RESOLVED FIXED
mozilla60
Tracking Status
firefox60 --- fixed

People

(Reporter: dholbert, Assigned: glandium)

References

Details

Attachments

(1 file)

Recent clang trunk builds[1] produce an error during the final "elfhack" stage of the build.

Here's what the build output looks like (with a clobber build [sped up using icecc]:

 4:21.16 === If you get failures below, please file a bug describing the error
 4:21.16 === and your environment (compiler and linker versions), and
 4:21.16 === provide the pre-elfhacked library as an attachment.
 4:21.16 === Use --disable-elf-hack until this is fixed.
 4:21.16 ===
 4:21.17  0x000000000000000c (INIT)               0x4060
 4:21.17 test-ctors.so: terminate called after throwing an instance of 'std::runtime_error'
 4:21.17   what():  Unsupported relocation type
 4:21.22 Makefile:17: recipe for target 'test-array.so' failed
 4:21.22 make[4]: *** [test-array.so] Aborted (core dumped)
 4:21.22 make[4]: *** Waiting for unfinished jobs....
 4:21.28 Makefile:17: recipe for target 'test-ctors.so' failed
 4:21.28 make[4]: *** [test-ctors.so] Aborted (core dumped)
 4:21.28 /scratch/work/builds/mozilla-inbound/mozilla/config/recurse.mk:100: recipe for target 'build/unix/elfhack/libs' failed
 4:21.28 make[3]: *** [build/unix/elfhack/libs] Error 2
 4:21.28 /scratch/work/builds/mozilla-inbound/mozilla/config/recurse.mk:32: recipe for target 'libs' failed
 4:21.28 make[2]: *** [libs] Error 2
 4:21.28 /scratch/work/builds/mozilla-inbound/mozilla/config/rules.mk:434: recipe for target 'default' failed
 4:21.28 make[1]: *** [default] Error 2
 4:21.28 client.mk:168: recipe for target 'build' failed
 4:21.28 make: *** [build] Error 2

I'm building this changeset:
https://hg.mozilla.org/integration/mozilla-inbound/rev/f598880f97c1

I'm bisecting clang revisions right now to find out when this started.  This morning's clang svn trunk (revision 325698) is definitely "bad", and here's the (slightly older) regression range that I'm got & am currently bisecting further:
 last-known-good: LLVM revision 325549
 first-known-bad: LLVM revision 325575
My mozconfig is as follows:
#########
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../obj
ac_add_options --enable-debug --disable-optimize
mk_add_options AUTOCLOBBER=1

# Use ccache and icecc:
ac_add_options --with-ccache
mk_add_options 'export CCACHE_PREFIX=icecc'
mk_add_options MOZ_MAKE_FLAGS="-j100"
This might be an LLVM bug, BTW. Only reporting it here for the moment, since it seems worth tracking (and as a place to gather data before filing the LLVM bug, if that ends up being the right outcome).

As for the regression -- I've narrowed the range a bit:
 last-known-good: LLVM revision 325562
 first-known-bad: LLVM revision 325569

I am initially eyeing revision 325569 itself as the likely cause, since the build error mentions "reloaction" and this SVN commit mentions "relocation" in its commit message:
------------------------------------------------------------------------
r325569 | grimar | 2018-02-20 02:17:57 -0800 (Tue, 20 Feb 2018) | 8 lines

[llvm-mc] - Produce R_X86_64_PLT32 for "call/jmp foo".

For instructions like call foo and jmp foo patch changes
relocation produced from R_X86_64_PC32 to R_X86_64_PLT32.
Relocation can be used as a marker for 32-bit PC-relative branches.
Linker will reduce PLT32 relocation to PC32 if function is defined locally.

Differential revision: https://reviews.llvm.org/D43383
------------------------------------------------------------------------
Indeed, revision 325569 is the "first bad" one. The previous one 325568 builds Firefox fine.

I can still build fine with that revision if I add this to my mozconfig (as suggested by the build output):
> ac_add_options --disable-elf-hack

I filed https://bugs.llvm.org/show_bug.cgi?id=36470 on this issue, in LLVM's bug tracker.  CC'd glandium & sledru -- glandium, I'm hoping maybe you can chime in with information about elfhack over there.
(Maybe you already might have an idea of what's going on, based on your knowledge of what elfhack is doing & based on info in the LLVM commit message and/or patch?)
Flags: needinfo?(mh+mozilla)
Flags: needinfo?(mh+mozilla)
Summary: clang trunk fails during elfhack build stage, with "test-ctors.so: terminate called after throwing an instance of 'std::runtime_error'" and then "what(): Unsupported relocation type" → elfhack lacks support for R_X86_64_PLT32 relocations clang trunk emits
Comment on attachment 8952870 [details]
Bug 1440037 - Add support for R_X86_64_PLT32 relocations in elfhack.

https://reviewboard.mozilla.org/r/222104/#review228280

That was easy.
Comment on attachment 8952870 [details]
Bug 1440037 - Add support for R_X86_64_PLT32 relocations in elfhack.

https://reviewboard.mozilla.org/r/222104/#review228288
Attachment #8952870 - Flags: review?(nfroyd) → review+
Pushed by mh@glandium.org:
https://hg.mozilla.org/integration/autoland/rev/afd291850b80
Add support for R_X86_64_PLT32 relocations in elfhack. r=froydnj
https://hg.mozilla.org/mozilla-central/rev/afd291850b80
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla60
Product: Core → Firefox Build System
Assignee: nobody → mh+mozilla
You need to log in before you can comment on or make changes to this bug.