John Dallman
2018-04-24 14:49:15 UTC
I'm trying to build some simple command-line tools to run in the adb shell.
I built a standalone toolchain from NDK 16b with this command:
ndk-bundle/build/tools/make_standalone_toolchain.py \
--arch arm64-v8a --api 21 --std libc++ \
--install-dir /local/kernel_lx86/toolchain
I have these directories on the front of my PATH, so that I can use the
clang from that toolchain and adb from the command line:
/local/kernel_lx86/toolchain/bin:/local/kernel_lx86/android-sdk/platform-tools
I encountered the problem where the BFD linker sets a flag that causes
warnings from the Android loader, thus:
WARNING: linker: /data/local/tmp/world.bfd: unsupported flags
DT_FLAGS_1=0x8000000
Searching for that found me the github discussion at
https://github.com/android-ndk/ndk/issues/602, and the simple answer seems
to be to use the -fuse-ld=gold option. So I did that, and found my
executable for a "hello world" program got about eleven times larger:
world.c is:
#include <stdio.h>
int main( int argc, char *argv[])
{
printf( "Hello, world\n");
return 0;
}
My commands are:
clang -fPIC -O -pie -fuse-ld=gold world.c -o world.gold
clang -fPIC -O -pie world.c -o world.bfd
ls -l world.c world.bfd world.gold
The sizes are:
-rwxrwxr-x 1 kerman ps 6000 Apr 24 14:47 world.bfd
-rw-rw-r-- 1 kerman ps 111 Apr 20 17:47 world.c
-rwxrwxr-x 1 kerman ps 68824 Apr 24 14:47 world.gold
Am I doing something wrong, or is this a gold bug?
Thanks,
John Dallman
I built a standalone toolchain from NDK 16b with this command:
ndk-bundle/build/tools/make_standalone_toolchain.py \
--arch arm64-v8a --api 21 --std libc++ \
--install-dir /local/kernel_lx86/toolchain
I have these directories on the front of my PATH, so that I can use the
clang from that toolchain and adb from the command line:
/local/kernel_lx86/toolchain/bin:/local/kernel_lx86/android-sdk/platform-tools
I encountered the problem where the BFD linker sets a flag that causes
warnings from the Android loader, thus:
WARNING: linker: /data/local/tmp/world.bfd: unsupported flags
DT_FLAGS_1=0x8000000
Searching for that found me the github discussion at
https://github.com/android-ndk/ndk/issues/602, and the simple answer seems
to be to use the -fuse-ld=gold option. So I did that, and found my
executable for a "hello world" program got about eleven times larger:
world.c is:
#include <stdio.h>
int main( int argc, char *argv[])
{
printf( "Hello, world\n");
return 0;
}
My commands are:
clang -fPIC -O -pie -fuse-ld=gold world.c -o world.gold
clang -fPIC -O -pie world.c -o world.bfd
ls -l world.c world.bfd world.gold
The sizes are:
-rwxrwxr-x 1 kerman ps 6000 Apr 24 14:47 world.bfd
-rw-rw-r-- 1 kerman ps 111 Apr 20 17:47 world.c
-rwxrwxr-x 1 kerman ps 68824 Apr 24 14:47 world.gold
Am I doing something wrong, or is this a gold bug?
Thanks,
John Dallman
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAH1xqgnu%2BTWj9E0Ri2Q0f36TfgF5eKQy9LqOUmqznGCfCf_isQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAH1xqgnu%2BTWj9E0Ri2Q0f36TfgF5eKQy9LqOUmqznGCfCf_isQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.