New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 775254 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Last visit 25 days ago
Closed: Jan 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Fuchsia
Pri: 1
Type: Bug

Blocked on:
issue 787920



Sign in to add a comment

Linking content_unittests for Fuchsia/ARM64/Debug fails with "relocation R_AARCH64_CALL26 out of range"

Project Member Reported by w...@chromium.org, Oct 16 2017

Issue description

Chrome Version: Headless Shell build args w/ target_cpu=arm64 @ 64.0.3242.0

Building the content_unittests target for Fuchsia/arm64, link fails with errors of the form:

ld.lld: error: background_sync_manager_unittest.cc:(function base::internal::AdaptCallbackForRepeatingHelper<content::ServiceWorkerStatusCode, scoped_refptr<content::ServiceWorkerRegistration> >::Run(content::ServiceWorkerStatusCode, scoped_refptr<content::ServiceWorkerRegistration>)): relocation R_AARCH64_CALL26 out of range

This appears to be a known issue with LLVM code generation for very large binaries, and can be reproduced with a simple test-case (cribbed from https://sourceware.org/bugzilla/show_bug.cgi?id=18668):

main.c:
    void  foo ();
    int main () {foo();}

$ third_party/llvm-build/Release+Asserts/bin/clang --target=aarch64-linux-gnu -Wl,--defsym=foo=0x80000000 -o main main.c

 

Comment 1 by w...@chromium.org, Oct 16 2017

Hmmm; the minimal repro case is using the GCC-cross 'ld' command, which may not know how to add the necessary veneer for the far call?

Comment 2 by w...@chromium.org, Oct 16 2017

Cc: mcgrathr@chromium.org
+mcgrathr: Do you know if there's some magic we're missing here? FWIW linker command-line for our content_unittests binary looks like:

clang++ -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--no-as-needed -lpthread -Wl,--as-needed -fuse-ld=lld -Wl,--icf=all --target=aarch64-fuchsia -resource-dir ../../third_party/fuchsia-sdk/toolchain_libs/clang/6.0.0 -Wl,-z,stack-size=0x800000 -Wl,--no-as-needed -lfdio -Wl,--as-needed -Werror -Wl,--gdb-index -nostdlib++ --sysroot=../../third_party/fuchsia-sdk/sysroot/aarch64-fuchsia -o "./content_unittests" -Wl,--start-group @"./content_unittests.rsp"  -Wl,--end-group   -lzircon -llaunchpad -lmedia_client 

Comment 3 by phosek@chromium.org, Oct 16 2017

Cc: phosek@chromium.org
LLD doesn't support inserting veneers at the moment. There's a patch to add that support https://reviews.llvm.org/D34691 but it's still in review.
The code segment is too big for a single BL (call) instruction.
It can address +/- 128MB, so your binary must be pretty darn big.
Should it really be that big?

Comment 5 by w...@chromium.org, Oct 17 2017

Re #4: Quite possibly, yes; this is the content_unittests target of Chromium, which builds-in all the unit-tests for the core of the multi-process browser, including the Blink rendering engine and various other large dependencies.  We're (currently) building it statically-linked (versus componentized), and in Debug mode which will mean additional checks, logging and data-structures being built-in.

We may be able to get the Fuchsia component build working again, as a work-around but it has bit-rotted, so if the toolchain fix will arrive soon, perhaps we can avoid that extra work for now.

Comment 6 by w...@chromium.org, Oct 17 2017

Looking into the question of whether a 128MB+ text segment is reasonable, I checked the stripped content_unittests size on Linux/x64 and Fuchsia/x64; the *component* build for Linux/x64 is already 60MB (stripped), while the (static) Fuchsia/x64 build is 309MB, FWIW.
Release with DCHECKs is probably better anyway:

is_debug = false
dcheck_always_on = true
is_component_build = false
target_os = "fuchsia"
use_goma = true
symbol_level = 1
target_cpu = "arm64"

I think this is a more useful set of args than a real "debug" or component debug, as we don't have a debugger in any case. It's also what the bots build.

This links content_unittests fine for me (with https://chromium-review.googlesource.com/c/chromium/src/+/722262), I guess because it's smaller. (?) It's still 723M on disk, but the .text is "only" 77.6M.
Seems likely that aarch64 code will be larger than x86_64 code (perhaps by a lot).  So content_unittests really will be very very large.  (A vaguely close comparison might be content_unittests in the aarch64 Android build if that's handy.)

Comment 9 by thakis@chromium.org, Oct 17 2017

Cc: ruiu@google.com p...@chromium.org
+pcc who's been using https://reviews.llvm.org/D34691 and friends locally for android builds.

+ruiu. FYI, fuchsia builds also need the arm patch series.
Note https://reviews.llvm.org/D34691 addresses the analogous issue for ARM32, but AFAIK nobody has done the work for AArch64, which is what we're talking about here.

Comment 11 by w...@chromium.org, Oct 17 2017

Summary: Linking content_unittests for Fuchsia/ARM64/Debug fails with "relocation R_AARCH64_CALL26 out of range" (was: Linking content_unittests for Fuchsia fails with "relocation R_AARCH64_CALL26 out of range")

Comment 12 by w...@chromium.org, Oct 23 2017

Owner: mcgrathr@chromium.org

Comment 13 by p...@chromium.org, Nov 7 2017

Looks like Peter Smith has a patch out for this.
https://reviews.llvm.org/D39744
The change has landed upstream, so a toolchain built after r319307 should have it.  We haven't yet rolled the Fuchsia toolchain up that far and tested this ourselves, but we'll do that soon.
We've verified the new lld works for large binaries on aarch64-fuchsia (i.e., produces binaries that work when run on Fuchsia).
It's in the Fuchsia prebuilt toolchain now.
Chrome folks need to do a Clang roll on their side to pick up recent upstream.

Comment 16 by p...@chromium.org, Dec 5 2017

Blockedon: 787920

Comment 17 by w...@chromium.org, Dec 8 2017

Labels: -M-64 M-65

Comment 18 by r...@chromium.org, Jan 5 2018

The roll is in, but I'll let you confirm and close the bug.

Comment 19 by w...@chromium.org, Jan 6 2018

Status: Fixed (was: Started)
Confirmed that we can build Debug/Fuchsia/ARM64/static content_unittests successfully, with the latest toolchain.  Thanks!

Sign in to add a comment