Need help with setting up LDC to cross-compile to Android/ARM
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed Oct 17 21:23:21 UTC 2018
I'm trying to follow the instructions on this page:
https://wiki.dlang.org/Build_D_for_Android
Currently, I'm stuck at the step to build the D runtime for ARM with
ldc-build-runtime: it fails with the error:
In file included from /mnt/3/usr/src/d/android/droid32/ldc-src/runtime/phobos/etc/c/zlib/adler32.c:8:
In file included from /mnt/3/usr/src/d/android/droid32/ldc-src/runtime/phobos/etc/c/zlib/zutil.h:22:
In file included from /mnt/3/usr/src/d/android/droid32/ldc-src/runtime/phobos/etc/c/zlib/zlib.h:34:
/mnt/3/usr/src/d/android/droid32/ldc-src/runtime/phobos/etc/c/zlib/zconf.h:444:14: fatal error:
'sys/types.h' file not found
# include <sys/types.h> /* for off_t */
^
1 error generated.
I *think* it's because I don't have the system library dev headers
installed for ARM (host system is Debian/Linux on amd64), but shouldn't
that already be included in the Android NDK, which I installed? I did
setup the CC environment variable with:
export CC=/usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
This is quite strange because for the configuration stage, cmake did
report:
-- Looking for sys/types.h
-- Looking for sys/types.h - found
So I'm not sure why it fails to find it when actually building.
Any tips?
P.S. The output of ldc2 --version is:
LDC - the LLVM D compiler (1.11.0):
based on DMD v2.081.2 and LLVM 6.0.1
built with LDC - the LLVM D compiler (0.17.6)
Default target: x86_64-pc-linux-gnu
Host CPU: amdfam10
http://dlang.org - http://wiki.dlang.org/LDC
Registered Targets:
aarch64 - AArch64 (little endian)
aarch64_be - AArch64 (big endian)
amdgcn - AMD GCN GPUs
arm - ARM
arm64 - ARM64 (little endian)
armeb - ARM (big endian)
avr - Atmel AVR Microcontroller
bpf - BPF (host endian)
bpfeb - BPF (big endian)
bpfel - BPF (little endian)
hexagon - Hexagon
lanai - Lanai
mips - Mips
mips64 - Mips64 [experimental]
mips64el - Mips64el [experimental]
mipsel - Mipsel
msp430 - MSP430 [experimental]
nvptx - NVIDIA PTX 32-bit
nvptx64 - NVIDIA PTX 64-bit
ppc32 - PowerPC 32
ppc64 - PowerPC 64
ppc64le - PowerPC 64 LE
r600 - AMD GPUs HD2XXX-HD6XXX
sparc - Sparc
sparcel - Sparc LE
sparcv9 - Sparc V9
systemz - SystemZ
thumb - Thumb
thumbeb - Thumb (big endian)
wasm32 - WebAssembly 32-bit
wasm64 - WebAssembly 64-bit
x86 - 32-bit X86: Pentium-Pro and above
x86-64 - 64-bit X86: EM64T and AMD64
xcore - XCore
The full output from ldc-build-runtime is as follows:
$ ldc-build-runtime --targetPreset=Android-arm --dFlags="-w;-mcpu=cortex-a8" --buildDir=droid32 --reset
Creating build directory: droid32
Downloading LDC source archive: https://github.com/ldc-developers/ldc/releases/download/v1.11.0/ldc-1.11.0-src.zip
Invoking: ["cmake", "-DLDC_EXE_FULL=/mnt/1/usr/bin/ldc2", "-DD_VERSION=2", "-DDMDFE_MINOR_VERSION=0", "-DDMDFE_PATCH_VERSION=81", "-DLDC_TARGET_PRESET=Android-arm", "-DTARGET_SYSTEM=AUTO", "-DD_FLAGS=-w;-mcpu=cortex-a8", "-DRT_CFLAGS=", "-DLD_FLAGS=", "-DCMAKE_SYSTEM_NAME=Linux", "-DCMAKE_C_COMPILER_WORKS=True", "/mnt/3/usr/src/d/android/droid32/ldc-src/runtime"]
-- The C compiler identification is Clang 3.8.256229
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- The ASM compiler identification is Clang
-- Found assembler: /usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void*
-- Check size of void* - done
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/3/usr/src/d/android/droid32
Invoking: ["make", "all"]
Scanning dependencies of target phobos2-ldc-debug-common
[ 0%] Generating objects-debug/etc/c/curl.o, objects-debug/etc/c/odbc/sql.o, objects-debug/etc/c/odbc/sqlext.o, objects-debug/etc/c/odbc/sqltypes.o, objects-debug/etc/c/odbc/sqlucode.o, objects-debug/etc/c/sqlite3.o, objects-debug/etc/c/zlib.o, objects-debug/std/algorithm/comparison.o, objects-debug/std/algorithm/internal.o, objects-debug/std/algorithm/iteration.o, objects-debug/std/algorithm/mutation.o, objects-debug/std/algorithm/package.o, objects-debug/std/algorithm/searching.o, objects-debug/std/algorithm/setops.o, objects-debug/std/algorithm/sorting.o, objects-debug/std/array.o, objects-debug/std/ascii.o, objects-debug/std/base64.o, objects-debug/std/bigint.o, objects-debug/std/bitmanip.o, objects-debug/std/compiler.o, objects-debug/std/complex.o, objects-debug/std/concurrency.o, objects-debug/std/container/array.o, objects-debug/std/container/binaryheap.o, objects-debug/std/container/dlist.o, objects-debug/std/container/package.o, objects-debug/std/container/rbtree.o, objects-debug/std/container/slist.o, objects-debug/std/container/util.o, objects-debug/std/conv.o, objects-debug/std/csv.o, objects-debug/std/datetime/date.o, objects-debug/std/datetime/interval.o, objects-debug/std/datetime/package.o, objects-debug/std/datetime/stopwatch.o, objects-debug/std/datetime/systime.o, objects-debug/std/datetime/timezone.o, objects-debug/std/demangle.o, objects-debug/std/digest/crc.o, objects-debug/std/digest/digest.o, objects-debug/std/digest/hmac.o, objects-debug/std/digest/md.o, objects-debug/std/digest/murmurhash.o, objects-debug/std/digest/package.o, objects-debug/std/digest/ripemd.o, objects-debug/std/digest/sha.o, objects-debug/std/encoding.o, objects-debug/std/exception.o, objects-debug/std/experimental/all.o, objects-debug/std/experimental/allocator/building_blocks/affix_allocator.o, objects-debug/std/experimental/allocator/building_blocks/aligned_block_list.o, objects-debug/std/experimental/allocator/building_blocks/allocator_list.o, objects-debug/std/experimental/allocator/building_blocks/ascending_page_allocator.o, objects-debug/std/experimental/allocator/building_blocks/bitmapped_block.o, objects-debug/std/experimental/allocator/building_blocks/bucketizer.o, objects-debug/std/experimental/allocator/building_blocks/fallback_allocator.o, objects-debug/std/experimental/allocator/building_blocks/free_list.o, objects-debug/std/experimental/allocator/building_blocks/free_tree.o, objects-debug/std/experimental/allocator/building_blocks/kernighan_ritchie.o, objects-debug/std/experimental/allocator/building_blocks/null_allocator.o, objects-debug/std/experimental/allocator/building_blocks/package.o, objects-debug/std/experimental/allocator/building_blocks/quantizer.o, objects-debug/std/experimental/allocator/building_blocks/region.o, objects-debug/std/experimental/allocator/building_blocks/scoped_allocator.o, objects-debug/std/experimental/allocator/building_blocks/segregator.o, objects-debug/std/experimental/allocator/building_blocks/stats_collector.o, objects-debug/std/experimental/allocator/common.o, objects-debug/std/experimental/allocator/gc_allocator.o, objects-debug/std/experimental/allocator/mallocator.o, objects-debug/std/experimental/allocator/mmap_allocator.o, objects-debug/std/experimental/allocator/package.o, objects-debug/std/experimental/allocator/showcase.o, objects-debug/std/experimental/allocator/typed.o, objects-debug/std/experimental/checkedint.o, objects-debug/std/experimental/logger/core.o, objects-debug/std/experimental/logger/filelogger.o, objects-debug/std/experimental/logger/multilogger.o, objects-debug/std/experimental/logger/nulllogger.o, objects-debug/std/experimental/logger/package.o, objects-debug/std/experimental/typecons.o, objects-debug/std/file.o, objects-debug/std/format.o, objects-debug/std/functional.o, objects-debug/std/getopt.o, objects-debug/std/internal/cstring.o, objects-debug/std/internal/digest/sha_SSSE3.o, objects-debug/std/internal/math/biguintarm.o, objects-debug/std/internal/math/biguintcore.o, objects-debug/std/internal/math/biguintnoasm.o, objects-debug/std/internal/ma
[ 0%] Built target phobos2-ldc-debug-common
Scanning dependencies of target phobos2-ldc-debug
[ 0%] Building C object CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/adler32.c.o
In file included from /mnt/3/usr/src/d/android/droid32/ldc-src/runtime/phobos/etc/c/zlib/adler32.c:8:
In file included from /mnt/3/usr/src/d/android/droid32/ldc-src/runtime/phobos/etc/c/zlib/zutil.h:22:
In file included from /mnt/3/usr/src/d/android/droid32/ldc-src/runtime/phobos/etc/c/zlib/zlib.h:34:
/mnt/3/usr/src/d/android/droid32/ldc-src/runtime/phobos/etc/c/zlib/zconf.h:444:14: fatal error:
'sys/types.h' file not found
# include <sys/types.h> /* for off_t */
^
1 error generated.
make[2]: *** [CMakeFiles/phobos2-ldc-debug.dir/build.make:644: CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/adler32.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:241: CMakeFiles/phobos2-ldc-debug.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
Error: command failed with status 2
T
--
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan
More information about the Digitalmars-d
mailing list