Linux: ld.lld: error: relocation R_X86_64_TPOFF32 against blink::g_thread_specific_ cannot be used with -shared

219 views
Skip to first unread message

Marshall Greenblatt

unread,
Aug 23, 2021, 3:07:19 PM8/23/21
to blink-dev, omer...@chromium.org
Hi All,

I'm attempting an ASAN build of a Chromium-based project on Linux (Ubuntu 18.04 64-bit) at the M94 branch point (master #911515) and I'm getting the below errors [1]. These errors do not reproduce with an ASAN build at the M93 branch point (master #902210). Any suggestions on how to fix them would be welcome.

Thanks,
Marshall

[1] [51527/51531] SOLINK ./libcef.so
FAILED: libcef.so libcef.so.TOC
python3 "../../build/toolchain/gcc_solink_wrapper.py" --readelf="readelf" --nm="../../third_party/llvm-build/Release+Asserts/bin/llvm-nm"  --sofile="./libcef.so" --tocfile="./libcef.so.TOC" --output="./libcef.so" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -Wl,-soname="libcef.so" -Wl,--version-script=/home/marshall/code/chromium_git/chromium/src/cef/libcef_dll/libcef.lst -fuse-ld=lld -Wl,--build-id -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--color-diagnostics -Wl,--no-call-graph-profile-sort -m64 -Werror -Wl,-O2 -Wl,--gc-sections -rdynamic -nostdlib++ -fsanitize=address -Wl,-u_sanitizer_options_link_helper -fsanitize=address -o "./libcef.so" @"./libcef.so.rsp"
ld.lld: error: relocation R_X86_64_TPOFF32 against blink::g_thread_specific_ cannot be used with -shared
>>> defined in obj/third_party/blink/renderer/platform/heap/heap/thread_state.o
>>> referenced by thread_state.cc:92 (../../third_party/blink/renderer/platform/heap/v8_wrapper/thread_state.cc:92)
>>>               obj/third_party/blink/renderer/platform/heap/heap/thread_state.o:(blink::ThreadState::Current())

ld.lld: error: relocation R_X86_64_TPOFF32 against blink::g_thread_specific_ cannot be used with -shared
>>> defined in obj/third_party/blink/renderer/platform/heap/heap/thread_state.o
>>> referenced by thread_state.cc:155 (../../third_party/blink/renderer/platform/heap/v8_wrapper/thread_state.cc:155)
>>>               obj/third_party/blink/renderer/platform/heap/heap/thread_state.o:(blink::ThreadState::ThreadState(v8::Platform*))
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: cannot make progress due to previous errors.

Marshall Greenblatt

unread,
Aug 23, 2021, 5:32:07 PM8/23/21
to Omer Katz (chromium.org), blink-dev
Hi Omer,

Thanks for the response. I'm building a single shared library ("libcef.so") that includes Chromium and Blink code on Linux. This library will be loaded by a separate exe at runtime, similar in concept to "chrome.dll" on Windows and "Google Chrome Framework" on macOS. Since I'm not making a component build in the Chromium sense (not setting `is_component_build=true`) is there a way to override the tls_model used by Blink's GCed heap?

Thanks,
Marshall

On Mon, Aug 23, 2021 at 5:23 PM Omer Katz (chromium.org) <omer...@chromium.org> wrote:
Are you building with chromium's build system (i.e. gn) or your own?
I suspect this error is related to the tls_model used by Blink's GCed heap, which is different based on whether it is built as a shared library (i.e. "component build" in chromium) or a single statically linked binary.
It seems to me you're building a shared library but with the tls model for a single statically linked binary.
The command you posted seems to be different then the one gn generates, so I'm assuming you forgot to set the COMPONENT_BUILD build flag for chromium.

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAFW9UJ8DQSnCAkpsD%3DSRHdwm43YZEV7E3k%2Bz%2Bwi4B5TybPFCqw%40mail.gmail.com.

Marshall Greenblatt

unread,
Aug 24, 2021, 12:32:54 PM8/24/21
to Omer Katz (chromium.org), blink-dev
On Mon, Aug 23, 2021 at 5:37 PM Omer Katz (chromium.org) <omer...@chromium.org> wrote:
There is no built-in way that I know of (probably because, to the best of my knowledge, it was not meant to be used like you use it).
I'd start with trying to hardcode a different tls model to at least confirm that that is the issue.

Thanks, changing the BLINK_HEAP_THREAD_LOCAL_MODEL value to "initial-exec" fixed the Linux build error. I do wonder why "local-exec" works on macOS. Perhaps loading "Google Chrome Framework" via dlopen() instead of dynamic linking makes the difference.
 

Reply all
Reply to author
Forward
0 new messages