Closed Bug 1563571 Opened 5 years ago Closed 4 years ago

Configure fails for android build with "ERROR: Failed to find a linker" with --enable-release

Categories

(Firefox Build System :: General, defect, P3)

Unspecified
Android
defect

Tracking

(firefox-esr78 wontfix, firefox86 wontfix, firefox87 fixed)

RESOLVED FIXED
87 Branch
Tracking Status
firefox-esr78 --- wontfix
firefox86 --- wontfix
firefox87 --- fixed

People

(Reporter: jnicol, Assigned: glandium)

References

(Regression)

Details

(Keywords: in-triage, regression)

Attachments

(2 files)

This is on a brand new PC so a fresh setup, so it's possible I'm missing some magic I had done to my old machine.

I checked out gecko, ran ./mach bootstrap for android, then ran ./mach build.

I get the following error:

0:03.16 checking for linker...
0:03.16 DEBUG: Executing: /usr/bin/clang -std=gnu99 --target=arm-linux-androideabi -Wl,--version -isystem /home/jamie/.mozbuild/android-ndk-r17b/sysroot/usr/include/arm-linux-androideabi -isystem /home/jamie/.mozbuild/android-ndk-r17b/sysroot/usr/include -gcc-toolchain /home/jamie/.mozbuild/android-ndk-r17b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 -D__ANDROID_API__=16
0:03.16 ERROR: Failed to find a linker

I had recently removed the CC and CXX lines from my mozconfig, as I'd read in bug 1561323 to do so. Adding them back in (to point to mozbuild's clang) makes the problem go away.

This is a reduced mozconfig which still triggers the bug:

ac_add_options --enable-application=mobile/android
ac_add_options --with-android-ndk="${HOME}/.mozbuild/android-ndk-r17b"

and adding this fixes it:

CC="${HOME}/.mozbuild/clang/bin/clang"
CXX="${HOME}/.mozbuild/clang/bin/clang++"

jnicol: huh, that's surprising. Can you give me the complete log of ./mach configure in the failing case (i.e., without CC and CXX)? After Bug 1519954 what you set should be the default... but if you look at your partial log, we're clearly finding /usr/bin/clang.

glandium: thoughts?

Flags: needinfo?(mh+mozilla)
Flags: needinfo?(jnicol)
Regressed by: 1519954

Are you building beta or release?

Flags: needinfo?(mh+mozilla)
Attached file ./mach build -v (deleted) —

This is building central.

Huh, this is interesting. I must have been mistaken yesterday when I said that 2-line reduced mozconfig reproduced it. Today I'm seeing it work fine with that: checking for the target C compiler... /home/jamie/.mozbuild/clang/bin/clang. But if I add the line ac_add_options --enable-release to my mozconfig then it tries to use /usr/bin/clang, and I get the linker error.

Any idea why that flag would cause that?

Flags: needinfo?(jnicol)

Because with --enable-release, .mozbuild is considered last, so if a compiler can be found before that, it will be used.

I think this is working as intended. glandium, should we prefer .mozbuild for developer builds even with --enable-release? I personally think so but don't have good context here.

If we don't want this, let's close this ticket.

Flags: needinfo?(mh+mozilla)
Summary: Configure fails for android build with "ERROR: Failed to find a linker" → Configure fails for android build with "ERROR: Failed to find a linker" with --enable-release

Thanks for helping here, happy for this to be closed. I don't usually have that option, but was doing some profiling of rust code and heard that's how to get it optimised properly. Is there a better way to achieve that?

should we prefer .mozbuild for developer builds even with --enable-release?

Well, that's the thing... The definition of a developer build is one without --enable-release... (and --enable-release is enabled by default on beta/release/esr). I do think there's something to improve here, and I think how I'm going to fix bug 1553230 will get us closer to being able to do that.

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: General → Android Studio and Gradle Integration

There is something more general than an Android problem here. In fact, I found this bug again while filing a bug with the title "Configure fails with "Failed to find a linker" in some cases instead of trying lld".

Assignee: nobody → mh+mozilla
Component: Android Studio and Gradle Integration → General
Flags: needinfo?(mh+mozilla)
Pushed by mh@glandium.org: https://hg.mozilla.org/integration/autoland/rev/97027c83ce2e Still try lld when the compiler can't find a linker on its own. r=firefox-build-system-reviewers,andi,dmajor
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch
Has Regression Range: --- → yes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: