Bug 236506

Summary: [CMake] REGRESSION(r289611): Debug builds fail linking binaries with ld.lld
Product: WebKit Reporter: Adrian Perez <aperez>
Component: Tools / TestsAssignee: Adrian Perez <aperez>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, keith_miller, mark.lam, mcatanzaro, msaboff, saam, tzagallo, webkit-bug-importer, ysuzuki, zdobersek
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=235979
https://bugs.webkit.org/show_bug.cgi?id=236976
Attachments:
Description Flags
Patch
ews-feeder: commit-queue-
Patch v2
ews-feeder: commit-queue-
Patch v3 none

Description Adrian Perez 2022-02-11 07:15:06 PST
SSIA, build failures can be seen e.g. in the WPE x86_64 debug build bot:

  https://build.webkit.org/#/builders/66/builds/7690

Error message follows:


ld.lld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/./__/__/JavaScriptCore/DerivedSources/unified-sources/UnifiedSource-3a3c4ec0-8.cpp.o
>>> referenced by ThunkGenerators.cpp:886 (/app/webkit/Source/JavaScriptCore/jit/ThunkGenerators.cpp:886)
>>>               Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/./__/__/JavaScriptCore/DerivedSources/unified-sources/UnifiedSource-3a3c4ec0-8.cpp.o:(JSC::expWrapper)                                                                                                                                                                                                                                                              ld.lld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output               >>> defined in Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/./__/__/JavaScriptCore/DerivedSources/unified-sources/UnifiedSource-3a3c4ec0-8.cpp.o                                                              >>> referenced by ThunkGenerators.cpp:886 (/app/webkit/Source/JavaScriptCore/jit/ThunkGenerators.cpp:886)                                                                                                            >>>               Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/./__/__/JavaScriptCore/DerivedSources/unified-sources/UnifiedSource-3a3c4ec0-8.cpp.o:(JSC::logWrapper)
ld.lld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/./__/__/JavaScriptCore/DerivedSources/unified-sources/UnifiedSource-3a3c4ec0-8.cpp.o
>>> referenced by ThunkGenerators.cpp:886 (/app/webkit/Source/JavaScriptCore/jit/ThunkGenerators.cpp:886)
>>>               Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/./__/__/JavaScriptCore/DerivedSources/unified-sources/UnifiedSource-3a3c4ec0-8.cpp.o:(JSC::floorWrapper)

ld.lld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/./__/__/JavaScriptCore/DerivedSources/unified-sources/UnifiedSource-3a3c4ec0-8.cpp.o
>>> referenced by ThunkGenerators.cpp:886 (/app/webkit/Source/JavaScriptCore/jit/ThunkGenerators.cpp:886)
>>>               Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/./__/__/JavaScriptCore/DerivedSources/unified-sources/UnifiedSource-3a3c4ec0-8.cpp.o:(JSC::ceilWrapper)

ld.lld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/./__/__/JavaScriptCore/DerivedSources/unified-sources/UnifiedSource-3a3c4ec0-8.cpp.o
>>> referenced by ThunkGenerators.cpp:886 (/app/webkit/Source/JavaScriptCore/jit/ThunkGenerators.cpp:886)
>>>               Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/./__/__/JavaScriptCore/DerivedSources/unified-sources/UnifiedSource-3a3c4ec0-8.cpp.o:(JSC::truncWrapper)
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Comment 1 Adrian Perez 2022-02-11 07:27:49 PST
Created attachment 451691 [details]
Patch
Comment 2 Adrian Perez 2022-02-11 07:32:42 PST
Created attachment 451693 [details]
Patch v2

Removes the leading dot from the section name,
hopefully that will make the EWS for Apple ports happier.
Comment 3 Adrian Perez 2022-02-11 07:37:03 PST
By the way, I think this is an interesting example about how LLD having
slightly stricter defaults ended up uncovering an issue in the code =)
Comment 4 Adrian Perez 2022-02-11 07:52:52 PST
(In reply to Adrian Perez from comment #2)
> Created attachment 451693 [details]
> Patch v2
> 
> Removes the leading dot from the section name,
> hopefully that will make the EWS for Apple ports happier.

Gah! Neither GNU toolchains nor Apple's like “.pushsection text”. I wanted
to use pushsection/popsection because the assembler (the GNU one at least)
sanity-checks that a push has a corresponding pop, and it would be neat to
have that; but it will be more portable to use .text/.previous instead.
Comment 5 Adrian Perez 2022-02-11 07:58:25 PST
Created attachment 451697 [details]
Patch v3


This version of the patch uses .previous to undo the effect of the .text
directives. The net result is the same as .pushsection/.popsection, but
the source is more portable.
Comment 6 EWS 2022-02-12 07:49:12 PST
Committed r289695 (247180@main): <https://commits.webkit.org/247180@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 451697 [details].
Comment 7 Radar WebKit Bug Importer 2022-02-12 07:50:19 PST
<rdar://problem/88855880>