How to compile Busybox? - android

(The i9100 and i9100p phones have Exynos 4210 SoC which includes Cortex A9 dual core 1.2Ghz processor which supports NEON.)
I will compile the latest busybox source snapshot available and upload it for everyone for free on internet and maybe even make my own free BusyboxInstaller.apk (I already downloaded today's 14th March snapshot from the official website) because so many busybox installers have very outdated versions and I want to take advantage of possible optimizations for the Cortex A9 cpu.
(NEON technology is a 128-bit SIMD (Single Instruction, Multiple Data) architecture extension.
It can can accelerate multimedia and signal processing algorithms such as video encode/decode, 2D/3D graphics, gaming, audio and speech processing, image processing, telephony, and sound synthesis.)
1 does such as mean it will also benefit my busybox?
2 What other instructions/anythingelse I can use to optimize for i9100 devices?
3 Can I compile on my phone instead of PC with only 1x2Ghz and 2GB RAM? I think it should be much quicker because it has 2x1.5GHz and 1GB RAM (I overclock only a bit) versus 1x2GHz, am I right?
4 How to compile busybox?
What are these options for?
Force NOMMU build
Additional CFLAGS
Additional LDFLAGS
Additional LDLIBS
all in general configuration and Busybox Library Tuning and debug (I googled for each for a few hours but nothing satisfactory)
What kind of applet links to install?
(./_install) BusyBox installation prefix
**I have eeror when following vinayhunachyai instructions.
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- install
/home/euphoria/Sourcery/busybox/scripts/gcc-version.sh: line 11: arm-none-linux-gnueabi-gcc: command not found
CC applets/applets.o
/bin/sh: 1: arm-none-linux-gnueabi-gcc: not found
scripts/Makefile.build:197: recipe for target 'applets/applets.o' failed
make[1]: *** [applets/applets.o] Error 127
Makefile:372: recipe for target 'applets_dir' failed
make: *** [applets_dir] Error 2

How to compile busybox?
1st download toolchain. You can refer to this: Advice regarding installing ARM toolchain on Ubuntu VM (64bit)
untar new source-code
create default config
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- defconfig
A default configuration file is created.
update config to change it to our needs:
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig
The option to compile Busybox as a static executable, so that we don’t have to copy the dynamic libraries inside the root filesystem. The setting can be found in “Busybox Settings --> Build Options“.
Also, select what utilities you want embedded in Busybox.
Then, the following command builds Busybox and creates a directory called _install containing the root filesystem tree:
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- install.
Compile statically. If you compile dynamically then you need to copy libraries to target.
For more details see this link: http://balau82.wordpress.com/2010/03/27/busybox-for-arm-on-qemu/

For Android you can use config android_defconfig and build with examples/android-build.
I successfully used busybox patched by sherpya: his config sherpya_android_defconfig and slightly modified build script examples/android-build.

Related

Missing Kernel DTB after creating signed Android images

I'm porting android to a display device, and have nearly completed this. The device use the Freescale/NXP i.MX6 Dual Lite Soc. The Android version used is Android 8.0.0, and the build is based on the Board Support Packages from NXP/Freescale (link below).
https://www.nxp.com/support/developer-resources/software-development-tools/i.mx-developer-resources/android-os-for-i.mx-applications-processors:IMXANDROID?tab=Design_Tools_Tab
The OS builds fine, and the images (u-boot, boot.img, system.img, vendor.img) resuling from the "make" process works perfercly fine on the device. So my last step is basically to sign the images, and this is where I struggle to get stuff working.
I am following the the guide found here:
https://source.android.com/devices/tech/ota/sign_builds
After completing the steps, I use the now signed images found in the "signed-img.zip" file to flash the device (using the NXP Manufacturing Tool, and not Fast Boot). However, the device now fails to boot the Kernel, giving me an error that the DTB is missing.
Hit any key to stop autoboot: 0
boota mmc0
kernel # 14008000 (8183104)
ramdisk # 15000000 (2036048)
## Booting Android Image at 0x12000000 ...
Kernel load addr 0x14008000 size 7992 KiB
Kernel command line: console=ttymxc0,115200 init=/init video=mxcfb0:dev=ldb video=mxcfb1:off video=mxcfb2:off video=mxcfb3:off vmalloc=128M androidboot.console=ttymxc0 consoleblank=0 ldo_active=on androidboot.hardware=sedevices cma=448M android.selinux=permissive android.dm_verify=disable androidboot.selinux=enforce androidboot.dm_verity=disable androidboot.storage_type=emmc loglevel=8 vt.global_cursor_default=0 buildvariant=userdebug androidboot.serialno=0b2861d4df668b47 androidboot.soc_type=imx6dl androidboot.storage_type=emmc
ERROR: Did not find a cmdline Flattened Device Tree
Could not find a valid device tree
resetting ...
I've narrowed the problem down to the very first step in the guide, where "make dist" is executed in the build directory. This produces a number of ZIP files in the "out/dist" folder, which is processed further in the following steps in the guide. I've tried flashing the device with the images produced in this step (found in the resulting "out/dist/*-img-*.zip" file), and this produces the exact same issue.
So my question is, what does really "make dist" do which cause the DTB to be missing in the "boot.img"? I would've expected it to use the already working "boot.img" found in "out/target/product//". But it instead seems to re-build this image, and in this case not include the DTB. As with so many other aspects of building Android from Source, the workings of "make dist" does not seem to be explained anywhere in the documentation.
I hope anyone with some experience in building Android from source knows something about this, because I seem to be royally stuck.
Just FYI; when I flash the "boot.img" produced after a normal "make", the output after U-boot is as follows:
Hit any key to stop autoboot: 0
boota mmc0
Error: blob decap job completed with errors 0x2000081A
In boota get fastboot lock status error. Set lock status
kernel # 14008000 (8183104)
ramdisk # 15000000 (2036754)
fdt # 14f00000 (40998)
## Booting Android Image at 0x12000000 ...
Kernel load addr 0x14008000 size 7992 KiB
Kernel command line: console=ttymxc0,115200 init=/init video=mxcfb0:dev=ldb video=mxcfb1:off video=mxcfb2:off video=mxcfb3:off vmalloc=128M androidboot.console=ttymxc0 consoleblank=0 ldo_active=on androidboot.hardware=sedevices cma=448M android.selinux=permissive android.dm_verify=disable androidboot.selinux=enforce androidboot.dm_verity=disable androidboot.storage_type=emmc loglevel=8 vt.global_cursor_default=0 buildvariant=userdebug androidboot.serialno=0b2861d4df668b47 androidboot.soc_type=imx6dl androidboot.storage_type=emmc
## Flattened Device Tree blob at 14f00000
Booting using the fdt blob at 0x14f00000
Loading Kernel Image ... OK
Using Device Tree in place at 14f00000, end 14f0d025
switch to ldo_bypass mode!
Starting kernel ...
It seem NXP/Freescale have modified the Build Scripts in their AOSP Board Support Package, and broken the DTB inclusion in the process. It may seem like they where happy when the output from the standard "make" process worked on their Dev Board, and never bothered checking if it was possible to create working signed Release images with it.
The mechanism to include a DTB in the dist package was in place (specifying the location of the DTB in BOARD_KERNEL_DTS), and was also used for their "make otapackage" target. However, that target only generates an unsigned (or signed with dev keys) OTA package, which can not be used with the signing scripts.
In order to make it work as it should, I had to make a small change in the main Makefile which specifies the location of the DTB defined in the BoardConfig.mk. The change was simple enough to make, but the hard part was figuring out where the problem was and how it was intended to work in the first place.
The following patch in "build/make/" fixes the issue, as long as a BoardConfig.mk ONLY specifies one DTB (which at least suits my needs):
diff --git a/core/Makefile b/core/Makefile
index a650565a1..92f3025a9 100644
--- a/core/Makefile
+++ b/core/Makefile
## -621,6 +621,19 ## ifdef INTERNAL_KERNEL_CMDLINE
INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
endif
+# NOTE! This script has a defect which cause the kernel DTB to be left out when ever 'make dist'
+# is executed. The following addition "fixes" this by adding the first dtb specified in the
+# BoardConfig.mk file. (I would guess in most cases there is never more than one!)
+ifdef dist_goal
+ifndef BOARD_KERNEL_DTS
+ifdef TARGET_BOARD_DTS_CONFIG
+DTS_BOARD=$(word 2, $(subst :, ,$(word 1, $(TARGET_BOARD_DTS_CONFIG))))
+BOARD_KERNEL_DTS="$(KERNEL_OUT)/$(DTS_BOARD)"
+$(info FIXUP: Defining BOARD_KERNEL_DTS:=[$(BOARD_KERNEL_DTS)] for BOOT packaging)
+endif
+endif
+endif
+
INTERNAL_MKBOOTIMG_VERSION_ARGS := \
--os_version $(PLATFORM_VERSION) \
--os_patch_level $(PLATFORM_SECURITY_PATCH)

How to build boost 1.69.0 for Android with NDK r18b using dec1/Boost-for-Android?

I tried to use https://github.com/dec1/Boost-for-Android to compile boost for Android. It reports 1.69.0 is supported for NDK r18b. I'm under Windows 7.
Even if this is reported as working, I encounter many problems when trying to run the provided script:
Downloaded boost 1.69.0
Downloaded sources
Modified BOOST_SRC_DIR to point to folder containing "1.69.0" boost folder
Modified ANDROID_NDK_ROOT to point to ndk folder
Modified ABIS="armeabi-v7a,x86"
Modified LINKAGE="static"
Added Cygwin to my path (as this is a .sh file I need to run)
Ran doIt.sh
Got non blocking errors:
-nLe fichier sp?cifi? est introuvable.
ERROR: Unsupported HOST_TAG: windows-x86_64
Then I got final error
## COMMAND: mkdir /tmp/ndk-/tmp/build-11600/build-boost/armeabi-v7a/llvm/host-bin
## COMMAND: ./bootstrap.sh --with-toolset=cc Building Boost.Build engine
with toolset cc... Failed to build Boost.Build build engine Consult
'bootstrap.log' for more details ERROR: Could not bootstrap Boost build
'bootstrap.log'reports gcc: not found
Added MinGW to my PATH (to have gcc be found), then retried:
Now I get in 'bootstrap.log':
cc -o bootstrap/jam0 command.c compile.c constants.c debug.c execcmd.c frames.c function.c glob.c hash.c hdrmacro.c headers.c jam.c jambase.c jamgram.c lists.c make.c make1.c object.c option.c output.c parse.c pathsys.c regexp.c rules.c scan.c search.c subst.c timestamp.c variable.c modules.c strings.c filesys.c builtins.c class.c cwd.c native.c md5.c w32_getreg.c modules/set.c modules/path.c modules/regex.c modules/property-set.c modules/sequence.c modules/order.c execunix.c fileunix.c pathunix.c
command.c:1:0: sorry, unimplemented: 64-bit mode not compiled in
There is no 'cc' available in my PATH, dunno where this is supposed to be found
Any idea what I may be doing wrong?
Sorry, only building on linux is officially supported. Mac and Windows should work fine too but details of setting up the relevant environments (eg cgwin or homebrew) is beyond the scope of what this project tries to do.
If you want to use windows as a host you have two easiest options are:
Use virtual machines eg. VirtualBox or and create a linux virtual machine where you do the building.
You can also simply download and use the precompiled binaries I have made available
No matter what os you use to build under, the resulting binaries can then be copied to windows and used from then on as if you had built on windows to start with (theyre cross compiled for android).

How to compile boost 1.68.0 for Android using NDK r18b using Windows

I had to build a version of boost for Android using NDK r18b, I had a hardtime achieving this so I post Question+Answer here as it may help other persons.
Firstly, I tried https://github.com/moritz-wundke/Boost-for-Android, but this was unsuccessful, see How to build boost 1.69.0 for Android with NDK r18b using moritz-wundke/Boost-for-Android?.
Secondly, I tried https://github.com/dec1/Boost-for-Android, but this was unsuccessful too, see How to build boost 1.69.0 for Android with NDK r18b using dec1/Boost-for-Android?.
What are the steps to follow to achieve compilation of boost?
Actually, those scripts were designed for Linux, and they hardly work under Windows. Then, I started from scratch and could finally find the good config under Windows to achieve this. I basically checked how other libraries are compiled (I use QtCreator to deploy on Android, so the compilation window reported me how clang++ has to be invoked, so I write a user-config.jam based on that.
Here are the steps to follow to compile boost 1.68.0 for Android armeabiv7 and x86 using NDK r18b:
Download boost 1.68.0 from boost.org: https://www.boost.org/users/history/version_1_68_0.html
Apply moritz-wundke's patch, else it won't compile (thanks by the way). Take it from here: https://github.com/moritz-wundke/Boost-for-Android/tree/master/patches
Run bootstrap.bat (you'll need it to find a compiler, I have VS 2015 installed so it works just fine)
Then set some environment variables:
set ANDROIDNDKROOT=C:\Android\android-ndk-r18b (change this accordingly)
set NDKVER=r18b
set CLANGPATH=%ANDROIDNDKROOT%\toolchains\llvm\prebuilt\windows-x86_64\bin
Copy user-config.jam to boost folder tools/build/src:
import os ;
local AndroidNDKRoot = [ os.environ ANDROIDNDKROOT ] ;
local AndroidBinariesPath = [ os.environ CLANGPATH ] ;
using clang : armeabiv7a
:
$(AndroidBinariesPath)/clang++
:
<compileflags>-fexceptions
<compileflags>-frtti
<compileflags>-mthumb
<compileflags>-ffunction-sections
<compileflags>-funwind-tables
<compileflags>-fstack-protector-strong
<compileflags>-Wno-invalid-command-line-argument
<compileflags>-Wno-unused-command-line-argument
<compileflags>-no-canonical-prefixes
<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/llvm-libc++/include
<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/llvm-libc++abi/include
<compileflags>-I$(AndroidNDKRoot)/sources/android/support/include
<compileflags>-DANDROID
<compileflags>-Wa,--noexecstack
<compileflags>-Wformat
<compileflags>-Werror=format-security
<compileflags>-DNDEBUG
<compileflags>-D_REENTRANT
<compileflags>-O2
<compileflags>-gcc-toolchain
<compileflags>$(AndroidNDKRoot)/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64
<compileflags>-target
<compileflags>armv7-linux-androideabi
<compileflags>-march=armv7-a
<compileflags>-mfloat-abi=softfp
<compileflags>-mfpu=vfp
<compileflags>-fno-builtin-memmove
<compileflags>-fpic
<compileflags>-DHAVE_CONFIG_H
<compileflags>-fno-integrated-as
<compileflags>--sysroot
<compileflags>$(AndroidNDKRoot)/sysroot
<compileflags>-isystem
<compileflags>$(AndroidNDKRoot)/sysroot/usr/include/arm-linux-androideabi
<compileflags>-D__ANDROID_API__=18
<archiver>$(AndroidNDKRoot)/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/arm-linux-androideabi/bin/ar
<ranlib>$(AndroidNDKRoot)/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/arm-linux-androideabi/bin/ranlib
;
# --------------------------------------------------------------------
using clang : x86
:
$(AndroidBinariesPath)/clang++
:
<compileflags>-fexceptions
<compileflags>-frtti
<compileflags>-mthumb
<compileflags>-ffunction-sections
<compileflags>-funwind-tables
<compileflags>-fstack-protector-strong
<compileflags>-Wno-invalid-command-line-argument
<compileflags>-Wno-unused-command-line-argument
<compileflags>-no-canonical-prefixes
<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/llvm-libc++/include
<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/llvm-libc++abi/include
<compileflags>-I$(AndroidNDKRoot)/sources/android/support/include
<compileflags>-DANDROID
<compileflags>-Wa,--noexecstack
<compileflags>-Wformat
<compileflags>-Werror=format-security
<compileflags>-DNDEBUG
<compileflags>-D_REENTRANT
<compileflags>-O2
<compileflags>-gcc-toolchain
<compileflags>$(AndroidNDKRoot)/toolchains/x86-4.9/prebuilt/windows-x86_64
<compileflags>-target
<compileflags>i686-linux-android
<compileflags>-march=i686
<compileflags>-mfloat-abi=softfp
<compileflags>-mfpu=vfp
<compileflags>-fno-builtin-memmove
<compileflags>-fPIC
<compileflags>-mstackrealign
<compileflags>--sysroot
<compileflags>$(AndroidNDKRoot)/sysroot
<compileflags>-isystem
<compileflags>$(AndroidNDKRoot)/sysroot/usr/include/i686-linux-android
<compileflags>-D__ANDROID_API__=18
<archiver>$(AndroidNDKRoot)/toolchains/x86-4.9/prebuilt/windows-x86_64/i686-linux-android/bin/ar
<ranlib>$(AndroidNDKRoot)/toolchains/x86-4.9/prebuilt/windows-x86_64/i686-linux-android/bin/ranlib
;
Then, for armeabiv7-a:
Run bjam -q --without-math --without-context --without-coroutine --without-fiber --without-python architecture=arm --ignore-site-config -j4 target-os=android toolset=clang-armeabiv7a link=static threading=multi --layout=tagged --build-dir=build/arm/%NDKVER% --stagedir=stage_arm_%NDKVER% stage
Then, for x86:
Run bjam -q --without-math --without-context --without-coroutine --without-fiber --without-python architecture=arm --ignore-site-config -j4 target-os=android toolset=clang-armeabiv7a link=static threading=multi --layout=tagged --build-dir=build/arm/%NDKVER% --stagedir=stage_arm_%NDKVER% stage
Hopefully, the same steps can be followed to compile 1.69.0 (not tested)
Thanks for the helpful instructions.
moritz-wundke/Boost-for-Android is a great project and the original Boost-for-Android. However, the way it works, it requires constant maintenance in order to support each new combination of the ndk and boost as new versions come out (you can only build for the explicit versions the project has been configured to support). After a long time (boost version 1.53 -> 1.63, and ndk 10->16) where its seemed like the project was no longer being maintained, and my efforts to contact the maintainer were in vain, I decided to fork it, which is why dec1/Boost-for-Android came into existence.
It has the advantage that it does not, in general, need to be updated to support new versions of google's ndk, or boost. They generally build out of the box, or need rare adjustments (but I still test regularly to make sure).
Using dec1/Boost-for-Android is arguably also simpler (certainly than following your instructions above). You can build for any/all architectures (arm64-v8a, armeabi-v7a, x86, x86_64), in one go in a single line of code. And if you dont need a custom build you can simply download prebuilt binaries (boost 1.69.0, with ndk 19 and 18b, both dynamic and static are now also available) from here. There's also an example app to help you test your build.
Im pretty sure that it could be made to work on windows or mac too (possibly with less effort than you spent above), but its a lot easier to just use a virtual machine (eg the free virtualbox) to do the build, and copy the resulting binaries to windows if you really want to develop there.
Nonetheles, moritz-wundke/Boost-for-Android seems to have gotten a new influx of contributions of late, which is good news for everybody. And if you find it more suitable for building boost on windows (or any other platform) then thats great.
Good luck with your projects and thanks again for the insights.

Crosscompile Perl for Android x86

I like to crosscompile Perl for the Android x86 emulator. But I got a PIE (position independent executables) error on running Configure... Based on this and this tutorial.
Specs:
NDK version 14
Perl 5.22.1.
x86 Android emulator built with AOSP - Android 7.1.1
I set following variables:
export ANDROID_NDK=/home/fabian/Android/Sdk/ndk-bundle
export TARGET_ARCH=x86
export ANDROID_TOOLCHAIN=/tmp/toolchain-x86
export SYSROOT=$ANDROID_TOOLCHAIN/sysroot
export TARGETDIR=/data/local/perl
export GCC=i686-linux-android-gcc
export PATH=$PATH:$ANDROID_NDK/toolchains/x86-4.9/prebuilt/linux-x86_64/bin
Then I build the toolchain with following command:
$ANDROID_NDK/build/tools/make-standalone-toolchain.sh --platform=android-23 --install-dir=$ANDROID_TOOLCHAIN --toolchain=x86-4.9
and get this (correct?) output:
HOST_OS=linux
HOST_EXE=
HOST_ARCH=x86_64
HOST_TAG=linux-x86_64
HOST_NUM_CPUS=4
BUILD_NUM_CPUS=8
Auto-config: --arch=x86
Toolchain installed to /tmp/toolchain-x86.
Then I start the ./Configure command:
./Configure -des -Dusedevel -Dusecrosscompile -Dtargetrun=adb -Dcc=i686-linux-android-gcc -Dsysroot=$SYSROOT -Dtargetdir=$TARGETDIR -Dtargethost=emulator-5554
and got this output:
First let's make sure your kit is complete. Checking...
Would you like to see the instructions? [n]
Locating common programs...
Checking compatibility between /bin/echo and builtin echo (if any)...
Symbolic links are supported.
Checking how to test for symbolic links...
You can test for symbolic links with 'test -h'.
Using targetarch i686-linux-android.
Using targethost emulator-5554.
Building host miniperl and generate_uudmap binaries
Using targethost emulator-5554.
Guessing targetuser root.
Guessing targetport 22.
Using '/home/fabian/Desktop/Testimages/perl-5.22.1/Cross/run-adb' for remote execution,
and '/home/fabian/Desktop/Testimages/perl-5.22.1/Cross/from-scp' and '/home/fabian/Desktop/Testimages/perl-5.22.1/Cross/to-scp'
for remote file transfer.
Good, your tr supports [:lower:] and [:upper:] to convert case.
Using [:upper:] and [:lower:] to convert case.
aix_3 dragonfly irix_4 nonstopux stellar
aix_4 dynixptx irix_5 openbsd sunos_4_0
aix dynix irix_6_0 opus sunos_4_1
altos486 epix irix_6_1 os2 super-ux
amigaos esix4 irix_6 os390 svr4
atheos fps isc_2 os400 svr5
aux_3 freebsd isc posix-bc ti1500
bitrig freemint linux-android powerux ultrix_4
bsdos genix linux qnx umips
catamount gnukfreebsd lynxos riscos unicosmk
convexos gnuknetbsd midnightbsd sco_2_3_0 unicos
cxux gnu mips sco_2_3_1 unisysdynix
cygwin greenhills mirbsd sco_2_3_2 utekv
darwin haiku mpc sco_2_3_3 uwin
dcosx hpux ncr_tower sco_2_3_4 vos
dec_osf i386 netbsd sco
dos_djgpp interix newsos4 solaris_2
Which of these apply, if any? [linux-android]
"./a.out": error: only position independent executables (PIE) are supported.
Aborted
You don't have an ELF gcc. I will use dld if possible. If you are
using a version of DLD earlier than 3.2.6, or don't have it at all, you
should probably upgrade. If you are forced to use 3.2.4, you should
uncomment a couple of lines in hints/linux.sh and restart Configure so
that shared libraries will be disallowed.
Disabling ndbm. This will generate a Whoa There message in Configure.
Read hints/linux.sh for further information.
Operating system name? [linux-android]
Operating system version? [7.1.1]
Installation prefix to use? (~name ok) [/usr/local]
AFS does not seem to be running...
What installation prefix should I use for installing files? (~name ok)
[/usr/local]
Getting the current patchlevel...
Build a threading Perl? [n]
Build Perl for multiplicity? [n]
Use which C compiler? [i686-linux-android-gcc]
Checking for GNU cc in disguise and/or its version number...
"./try": error: only position independent executables (PIE) are supported.
Aborted
Now, how can we feed standard input to your C preprocessor...
Directories to use for library searches?
[/tmp/toolchain-x86/sysroot/usr/lib/../lib /tmp/toolchain-x86/sysroot/usr/lib]
What is the file extension used for shared libraries? [sa]
Make shared library basenames unique? [n]
Hmm. Based on the hints in hints/linux-android.sh,
the recommended value for $d_libname_unique on this machine was "define"!
Keep the recommended value? [y]
Build Perl for SOCKS? [n]
Try to use long doubles if available? [n]
Checking for optional libraries...
What libraries to use? [-lm -lc]
What optimizer/debugger flag should be used? [-O2]
Any additional cc flags?
[-DOVR_DBL_DIG=14 --sysroot=/tmp/toolchain-x86/sysroot]
Let me guess what the preprocessor flags are...
Any additional ld flags (NOT including libraries)?
[ --sysroot=/tmp/toolchain-x86/sysroot]
Checking your choice of C compiler and flags for coherency...
I've tried to compile and run the following simple program:
#include
int main() { printf("Ok\n"); return(0); }
I used the command:
i686-linux-android-gcc -o try -O2 -DOVR_DBL_DIG=14 --sysroot=/tmp/toolchain-x86/sysroot --sysroot=/tmp/toolchain-x86/sysroot try.c -lm -lc
/home/fabian/Desktop/Testimages/perl-5.22.1/Cross/run-adb-shell ./try
and I got the following output:
The program compiled OK, but exited with status 134.
You have a problem. Shall I abort Configure [y]
Ok. Stopping Configure.
OK I have to set the flags
Modify config.sh to enable PIE support. Append “-fPIE” to ccflags and
“-fPIE -pie” to ldflags. Then rerun configure to ensure this is
applied.
But there is no config.sh in the perl folder, so I tried this ./Configure command:
`./Configure -des -Dusedevel -Dusecrosscompile -Dtargetrun=adb -Dcc=i686-linux-android-gcc -Dsysroot=$SYSROOT -Dtargetdir=$TARGETDIR -Dtargethost=emulator-5554 -Dccflags='-fPIE' Dldflags='-fPIE -pie'`
but same problem again...
First let's make sure your kit is complete. Checking...
Would you like to see the instructions? [n]
Locating common programs...
Checking compatibility between /bin/echo and builtin echo (if any)...
Symbolic links are supported.
Checking how to test for symbolic links...
You can test for symbolic links with 'test -h'.
Using targetarch i686-linux-android.
Using targethost emulator-5554.
Building host miniperl and generate_uudmap binaries
Using targethost emulator-5554.
Guessing targetuser root.
Guessing targetport 22.
Using '/home/fabian/Desktop/Testimages/perl-5.22.1/Cross/run-adb' for remote execution,
and '/home/fabian/Desktop/Testimages/perl-5.22.1/Cross/from-scp' and '/home/fabian/Desktop/Testimages/perl-5.22.1/Cross/to-scp'
for remote file transfer.
Good, your tr supports [:lower:] and [:upper:] to convert case.
Using [:upper:] and [:lower:] to convert case.
aix_3 dragonfly irix_4 nonstopux stellar
aix_4 dynixptx irix_5 openbsd sunos_4_0
aix dynix irix_6_0 opus sunos_4_1
altos486 epix irix_6_1 os2 super-ux
amigaos esix4 irix_6 os390 svr4
atheos fps isc_2 os400 svr5
aux_3 freebsd isc posix-bc ti1500
bitrig freemint linux-android powerux ultrix_4
bsdos genix linux qnx umips
catamount gnukfreebsd lynxos riscos unicosmk
convexos gnuknetbsd midnightbsd sco_2_3_0 unicos
cxux gnu mips sco_2_3_1 unisysdynix
cygwin greenhills mirbsd sco_2_3_2 utekv
darwin haiku mpc sco_2_3_3 uwin
dcosx hpux ncr_tower sco_2_3_4 vos
dec_osf i386 netbsd sco
dos_djgpp interix newsos4 solaris_2
Which of these apply, if any? [linux-android]
"./a.out": error: only position independent executables (PIE) are supported.
Aborted
You don't have an ELF gcc. I will use dld if possible. If you are
using a version of DLD earlier than 3.2.6, or don't have it at all, you
should probably upgrade. If you are forced to use 3.2.4, you should
uncomment a couple of lines in hints/linux.sh and restart Configure so
that shared libraries will be disallowed.
Disabling ndbm. This will generate a Whoa There message in Configure.
Read hints/linux.sh for further information.
Operating system name? [linux-android]
Operating system version? [7.1.1]
Installation prefix to use? (~name ok) [/usr/local]
AFS does not seem to be running...
What installation prefix should I use for installing files? (~name ok)
[/usr/local]
Getting the current patchlevel...
Build a threading Perl? [n]
Build Perl for multiplicity? [n]
Use which C compiler? [i686-linux-android-gcc]
Checking for GNU cc in disguise and/or its version number...
"./try": error: only position independent executables (PIE) are supported.
Aborted
Now, how can we feed standard input to your C preprocessor...
Directories to use for library searches?
[/tmp/toolchain-x86/sysroot/usr/lib/../lib /tmp/toolchain-x86/sysroot/usr/lib]
What is the file extension used for shared libraries? [sa]
Make shared library basenames unique? [n]
Hmm. Based on the hints in hints/linux-android.sh,
the recommended value for $d_libname_unique on this machine was "define"!
Keep the recommended value? [y]
Build Perl for SOCKS? [n]
Try to use long doubles if available? [n]
Checking for optional libraries...
What libraries to use? [-lm -lc]
What optimizer/debugger flag should be used? [-O2]
Any additional cc flags?
[-DOVR_DBL_DIG=14 -fPIE --sysroot=/tmp/toolchain-x86/sysroot]
Let me guess what the preprocessor flags are...
Any additional ld flags (NOT including libraries)?
[ --sysroot=/tmp/toolchain-x86/sysroot]
Checking your choice of C compiler and flags for coherency...
I've tried to compile and run the following simple program:
#include
int main() { printf("Ok\n"); return(0); }
I used the command:
i686-linux-android-gcc -o try -O2 -DOVR_DBL_DIG=14 -fPIE --sysroot=/tmp/toolchain-x86/sysroot --sysroot=/tmp/toolchain-x86/sysroot try.c -lm -lc
/home/fabian/Desktop/Testimages/perl-5.22.1/Cross/run-adb-shell ./try
and I got the following output:
"./try": error: only position independent executables (PIE) are supported.
Aborted
The program compiled OK, but exited with status 134.
You have a problem. Shall I abort Configure [y]
Ok. Stopping Configure.
But now the ccflag is set how you can see in the last lines...
Did I miss something?

How to build i686-linux-android-gfortran for android-ndk8b (x86 arch Android)?

I tried building i686-linux-android-gfortran using build-gcc.sh following this
(it's for androdindk-7b) but I get error about link.h. I added link.h from here, but it gives further more errors.
Has anyone tried enabling i686-linux-android-gfortran for x86 Android?
From https://groups.google.com/forum/#!msg/android-ndk/QR1qiN0jIpE/g0MHkhTd4YMJ as selalerer suggested. I didn't try this, so I'm posting as a community wiki for reference purposes.
Fortran for x86 Android
=================
The guide is based on this one, many thanks to Phil:
Compiling Android NDK with Objective-C-enabled gcc errors
1) Download and unpack Android NDK 'android-ndk-r8c', (the older -r8b NDK won't work due to missing link.h!):
wget http://dl.google.com/android/ndk/android-ndk-r8c-linux-x86.tar.bz2
2) Create somewhere a folder called 'toolchain-src' (e.g. inside the folder android-ndk-r8c),
'cd' to this new folder
3) Make sure to have git installed ('yum install git' or whatever..) and download
the toolchain sources:
git clone https://android.googlesource.com/toolchain/build.git
git clone https://android.googlesource.com/toolchain/gmp.git
git clone https://android.googlesource.com/toolchain/gdb.git
git clone https://android.googlesource.com/toolchain/mpc.git
git clone https://android.googlesource.com/toolchain/mpfr.git
git clone https://android.googlesource.com/toolchain/expat.git
4) Create the folder 'binutils', 'cd' to this directory, unpack
binutils-2.23 there:
wget ftp.gnu.org/gnu/binutils/binutils-2.23.tar.gz
tar -xvzf binutils-2.23.tar.gz
You should now have a folder toolchain-src/binutils/binutils-2.23
5) Change to folder toolchain-src/build, edit the Makefile.in, changing the line:
--with-gnu-as --with-gnu-ld --enable-languages=c,c++
to
--with-gnu-as --with-gnu-ld --enable-languages=c,c++,fortran
6) In the file android-ndk-r8c/build/tools/build-mingw64-toolchain.sh change the line:
var_append GCC_CONFIGURE_OPTIONS "--enable-languages=c,c++"
to
var_append GCC_CONFIGURE_OPTIONS "--enable-languages=c,c++,fortran"
7) In the file android-ndk-r8c/build/tools/build-gcc.sh, change the line:
EXTRA_CONFIG_FLAGS=$EXTRA_CONFIG_FLAGS" --disable-libquadmath --disable-plugin"
to
EXTRA_CONFIG_FLAGS=$EXTRA_CONFIG_FLAGS" --disable-libquadmath --disable-libquadmath-support --disable-plugin"
8) In the file android-ndk-r8c/build/tools/build-host-gcc.sh, change the line:
ARGS=$ARGS" --enable-languages=c,c++"
to
ARGS=$ARGS" --enable-languages=c,c++,fortran"
And change the line
ARGS=$ARGS" --disable-libquadmath --disable-plugin --disable-libitm --disable-bootstrap"
to
ARGS=$ARGS" --disable-libquadmath --disable-libquadmath-support --disable-plugin --disable-libitm --disable-bootstrap"
9) Build your new toolchain:
/your/path/to/android-ndk-r8c/build/tools/build-gcc.sh -j1 --gmp-version=5.0.5 --mpfr-version=2.4.2 --mpc-version=0.8.1 --binutils-version=2.23 --gdb-version=7.3.x /your/path/to/toolchain-src /your/path/to/android-ndk-r8c x86-4.7
(don't worry about messages like 'expr: warning: unportable BRE:')
10) And go down to your knees in front of the screen, praying to the Lord that somehow these
countless configure scripts doing checks that nobody needs, using an ugly shell language
that cooks your brain with indentation going from right to left, will somehow manage to
compile a zillion of far too small files (so that 10% of the time is spent on compilation
and 90% on starting up GCC), and after an hour of watching progress with
tail -F /tmp/ndk-YourUserName/build/toolchain/config.log
your toolchain will be magically ready. You'll find it in the android-ndk-r8c/toolchains folder.
11) Finally, 'cd' to the folder
'/your/path/to/android-ndk-r8c/toolchains/x86-4.7/prebuilt/linux-x86/i686-linux-android'
and run this command:
ln -s ../libexec libexec
Without this command, it may happen that g++ raises the error message
"g++: fatal error: -fuse-linker-plugin, but liblto_plugin.so not found".
Using strace, I found that g++ looks in the wrong folder, but the link
above lets it find the file liblto_plugin.so nevertheless.
And here are a few lessons learned on the way, so that Google finds this page:
*) To speed up the compilation, you can remove the '-j1'. But only after you got
it to work once, since building in parallel on multiple CPU cores was reported to
cause additional troubles.
*) The error message "Link tests are not allowed after GCC_NO_EXECUTABLES" shows up
when linking fails for x86 (works for ARM). The reason is that GCC does not include
the proper ANDROID_STARTFILE_SPEC and ANDROID_ENDFILE_SPEC from
gcc-4.6.1/gcc/config/linux-android.h. GCC 4.6.1 only specifies them for ARM, but not
for i386, GCC 4.8.0 however does. The GCCs downloaded from Google also do,
so best use Google's GCC.
*) The error message "fatal error: link.h: No such file or directory" also happens
with Google's GCC, and apparently (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50877)
only when you enable additional languages like objc or fortran.
The bug thread is here: http://gcc.gnu.org/ml/gcc-bugs/2012-08/msg00494.html
MIPS has link.h in android-ndk-r8b/platforms/android-9/arch-mips/usr/include
In android-ndk-r8c, link.h is now also present in android-9/arch-x86/usr/include/link.h,
so this bug was fixed.
*) The error message "fatal error: quadmath_weak.h: No such file or directory":
It also happens with the latest gcc-4.8, so we can just continue using Googles GCC 4.7.
Google itself uses --disable-libquadmath, but we additionally need --disable-libquadmathsupport
(see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47648). So this needs to be added in
android-ndk-r8c/build/tools/build-gcc.sh
and
android-ndk-r8c/build/tools/build-host-gcc.sh
*) The error message "error: Pthreads are required to build libatomic"
Happens when building the ARM version of gcc-4.8 downloaded from gnu.org,
better stay with Google's GCCs.
*) The GCC that came with android-ndk-r8c didn't work for me (error message about
libstdc++.so.6 being too old), while the one in android-ndk-r8b worked
without problems. Since the android-ndk should support as many environments
as possible, I'm not sure why the Googlers decided to depend on a newer libstdc++,
but the good news are that building your own toolchain solves the issue.
*) If you get an error while compiling generic-morestack.c, then replace
#ifdef linux
// On Linux, the first two real time signals are used by the NPTL
with
#if defined(GLIBC) && defined(linux)
// On Linux, the first two real time signals are used by the NPTL

Categories

Resources