问题
When I'm compiling Android 5.1.1, I get dozens of errors like this:
...
...
...
libnativehelper/JniInvocation.cpp:165: error: unsupported reloc 43
libnativehelper/JniInvocation.cpp:165: error: unsupported reloc 43
libnativehelper/JniInvocation.cpp:165: error: unsupported reloc 43
libnativehelper/JniInvocation.cpp:165: error: unsupported reloc 43
and the make process finally fails:
clang: error: linker command failed with exit code 1 (use -v to see invocation)
build/core/host_shared_library_internal.mk:44: recipe for target 'out/host/linux-x86/obj32/lib/libnativehelper.so' failed
make: *** [out/host/linux-x86/obj32/lib/libnativehelper.so] Error 1
I've tried building sources with and without clang, and with different versions of clang. But on newer branches, clang is a requirement and make doesn't start without it.
What might be wrong?
回答1:
One should apply this patch to get the things working https://android-review.googlesource.com/#/c/223100/
Open build/core/clang/HOST_x86_common.mk
file in your android source code directory with some editor add these lines, as mentioned in this link
For Android Lollipop or any earlier version, make sure to keep -no-integrated-as
while applying this patch. Make sure the line continuations are proper(\
at the end of each line except the last line).
But, -no-integrated-as
is removed in Marshmallow.
回答2:
It works to me:
in file /art/build/Android.common_build.mk, find out:
# Host.
ART_HOST_CLANG := false
ifneq ($(WITHOUT_HOST_CLANG),true)
# By default, host builds use clang for better warnings.
ART_HOST_CLANG := true
endif
change to :
# Host.
ART_HOST_CLANG := false
ifeq ($(WITHOUT_HOST_CLANG),false)
# By default, host builds use clang for better warnings.
ART_HOST_CLANG := true
endif
If it still not works,try this in your android root path:
cp /usr/bin/ld.gold prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/x86_64-linux/bin/ld
回答3:
Problems comes from an incompatible change in binutils: some section were added. Some build platform have the new binutils and android build tree have old one. The bug comes from clang invocation variables definition. These doesn't tell clang to use the provided build chain. Then clang uses the native build platform binutils (here /usr/bin/as instead the prebuilts provided as). Then the fix imply applying the patch pointed by mysticTot and then removing all binaries produced by the toolchain (according to where the error appears this could change but removing all STATIC_LIBRARIES/SHARED_LIBRARIES/EXECUTABLES etc dirs in out tree should do it). Also remove the ccache cache (as it stores .o) then rebuild. Fix provided by Ov3r1oad consisting in replacing the prebuilt toolchain ld by the native ld is not a solution, just a workaround and could be dangerous (mixing section number is not good). Hope it willl help.
回答4:
As a hard workaround I just replaced prebuilt linker with soft link on /usr/bin/ld.gold . It described here: https://bbs.archlinux.org/viewtopic.php?id=209698 .
回答5:
Are you building on Arch Linux? I have the same problem since today. My previous builds were 3 days ago and were all fine. Today all fail.
I see the admin upgraded some packages 2 days ago, especially these
[2016-03-16 15:29] [ALPM] upgraded glibc (2.22-3 -> 2.23-1)
[2016-03-16 15:29] [ALPM] upgraded lib32-glibc (2.22-3.1 -> 2.23-1)
[2016-03-16 15:29] [ALPM] upgraded lib32-gcc-libs (5.3.0-3 -> 5.3.0-5)
[2016-03-16 15:29] [ALPM] upgraded gcc-libs-multilib (5.3.0-3 -> 5.3.0-5)
[2016-03-16 15:29] [ALPM] upgraded libcap (2.24-2 -> 2.25-1)
[2016-03-16 15:29] [ALPM] upgraded binutils (2.25.1-3 -> 2.26-3)
[2016-03-16 15:29] [ALPM] upgraded gcc-multilib (5.3.0-3 -> 5.3.0-5)
[2016-03-16 15:29] [ALPM] upgraded libcups (2.1.2-3 -> 2.1.3-1)
binutils could be the culprit? (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=808206)
also see https://groups.google.com/d/msg/android-x86/U1XpL0tUpqw/y4W3wRCdJgAJ ...
来源:https://stackoverflow.com/questions/36048358/building-android-from-sources-unsupported-reloc-43