Thread overview
Need help with setting up LDC to cross-compile to Android/ARM
Oct 17, 2018
H. S. Teoh
Oct 19, 2018
Joakim
Oct 19, 2018
Joakim
Oct 19, 2018
H. S. Teoh
Oct 19, 2018
H. S. Teoh
Oct 19, 2018
H. S. Teoh
Oct 20, 2018
Joakim
Oct 22, 2018
H. S. Teoh
Oct 20, 2018
H. S. Teoh
October 17, 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

October 19, 2018
On Wednesday, 17 October 2018 at 21:23:21 UTC, H. S. Teoh wrote:
> I'm trying to follow the instructions on this page:
>
> 	https://wiki.dlang.org/Build_D_for_Android
>
> [...]

Hmm, that's weird: can you extract the full compiler command for that file? For example, if you use Ninja, by appending --ninja to ldc-build-runtime, it will tell you the full command that failed. Not sure if Make has a way to get that too.
October 19, 2018
On Friday, 19 October 2018 at 20:50:36 UTC, Joakim wrote:
> On Wednesday, 17 October 2018 at 21:23:21 UTC, H. S. Teoh wrote:
>> I'm trying to follow the instructions on this page:
>>
>> 	https://wiki.dlang.org/Build_D_for_Android
>>
>> [...]
>
> Hmm, that's weird: can you extract the full compiler command for that file? For example, if you use Ninja, by appending --ninja to ldc-build-runtime, it will tell you the full command that failed. Not sure if Make has a way to get that too.

Also, if you're using a system-provided LDC, it may not support Android, if it wasn't built against our slightly tweaked llvm:

https://github.com/ldc-developers/llvm

In that case, use the LDC download from github instead:

https://github.com/ldc-developers/ldc/releases
October 19, 2018
On Fri, Oct 19, 2018 at 08:54:25PM +0000, Joakim via Digitalmars-d wrote: [...]
> Also, if you're using a system-provided LDC, it may not support Android, if it wasn't built against our slightly tweaked llvm:
> 
> https://github.com/ldc-developers/llvm
> 
> In that case, use the LDC download from github instead:
> 
> https://github.com/ldc-developers/ldc/releases

I tried ldc-build-runtime with --ninja and it came back with a bunch of errors about "cortex-a8" being an unsupported target, and then segfaulted.  So I'm going to try the "official" LDC release instead...

In the meantime, is there a particular version of the NDK that I should use?  Currently I have android-ndk-r13b-linux-x86_64.zip installed. Will it work?


T

-- 
I'm still trying to find a pun for "punishment"...
October 19, 2018
On Fri, Oct 19, 2018 at 02:41:48PM -0700, H. S. Teoh via Digitalmars-d wrote: [...]
> I tried ldc-build-runtime with --ninja and it came back with a bunch of errors about "cortex-a8" being an unsupported target, and then segfaulted.  So I'm going to try the "official" LDC release instead...
[...]

I'm getting the same error with the official LDC 12.0.  Running with --ninja revealed that it's not just sys/types.h, but seems that a bunch of standard C headers (possibly all?) that are mysteriously missing:


	$ ldc-build-runtime --targetPreset=Android-arm --dFlags=-w;-mcpu=cortex-a8 --buildDir=droid32 --ninja
	-- Configuring done
	-- Generating done
	CMake Warning (dev):
	  Policy CMP0058 is not set: Ninja requires custom command byproducts to be
	  explicit.  Run "cmake --help-policy CMP0058" for policy details.  Use the
	  cmake_policy command to set the policy and suppress this warning.

	  This project specifies custom command DEPENDS on files in the build tree
	  that are not specified as the OUTPUT or BYPRODUCTS of any
	  add_custom_command or add_custom_target:

	   ldc-src/runtime/druntime/src/core/atomic.d
	   ldc-src/runtime/druntime/src/core/attribute.d
	   ldc-src/runtime/druntime/src/core/bitop.d
	   ldc-src/runtime/druntime/src/core/checkedint.d
	   ldc-src/runtime/druntime/src/core/cpuid.d
	   ldc-src/runtime/druntime/src/core/demangle.d
	   ldc-src/runtime/druntime/src/core/exception.d
	   ldc-src/runtime/druntime/src/core/internal/abort.d
	   ldc-src/runtime/druntime/src/core/internal/arrayop.d
	   ldc-src/runtime/druntime/src/core/internal/convert.d

	  For compatibility with versions of CMake that did not have the BYPRODUCTS
	  option, CMake is generating phony rules for such files to convince 'ninja'
	  to build.

	  Project authors should add the missing BYPRODUCTS or OUTPUT options to the
	  custom commands that produce these files.
	This warning is for project developers.  Use -Wno-dev to suppress it.

	-- Build files have been written to: /mnt/3/usr/src/d/android/droid32
	[1/40] Building C object CMakeFiles/phobos2-ldc.dir/phobos/etc/c/zlib/gzwrite.c.o
	FAILED: CMakeFiles/phobos2-ldc.dir/phobos/etc/c/zlib/gzwrite.c.o
	/usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang   -DHAVE_UNISTD_H -fPIC   -ffunction-sections -funwind-tables -fstack-protector-strong -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes -g -DNDEBUG -DANDROID  -D__ANDROID_API__=21 -Wa,--noexecstack -Wformat -Werror=format-security -fpie -target armv7-none-linux-androideabi21 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -gcc-toolchain /usr/lib/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot /usr/lib/android-ndk/sysroot -isystem /usr/lib/android-ndk/sysroot/usr/include/arm-linux-androideabi -fno-integrated-as -MD -MT CMakeFiles/phobos2-ldc.dir/phobos/etc/c/zlib/gzwrite.c.o -MF CMakeFiles/phobos2-ldc.dir/phobos/etc/c/zlib/gzwrite.c.o.d -o CMakeFiles/phobos2-ldc.dir/phobos/etc/c/zlib/gzwrite.c.o   -c ldc-src/runtime/phobos/etc/c/zlib/gzwrite.c
	In file included from ldc-src/runtime/phobos/etc/c/zlib/gzwrite.c:6:
	ldc-src/runtime/phobos/etc/c/zlib/gzguts.h:21:10: fatal error: 'stdio.h' file not found
	#include <stdio.h>
		 ^
	1 error generated.
	[2/40] Building C object CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/compress.c.o
	FAILED: CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/compress.c.o
	/usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang   -DHAVE_UNISTD_H -fPIC   -ffunction-sections -funwind-tables -fstack-protector-strong -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes -g -DNDEBUG -DANDROID  -D__ANDROID_API__=21 -Wa,--noexecstack -Wformat -Werror=format-security -fpie -target armv7-none-linux-androideabi21 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -gcc-toolchain /usr/lib/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot /usr/lib/android-ndk/sysroot -isystem /usr/lib/android-ndk/sysroot/usr/include/arm-linux-androideabi -fno-integrated-as -MD -MT CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/compress.c.o -MF CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/compress.c.o.d -o CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/compress.c.o   -c ldc-src/runtime/phobos/etc/c/zlib/compress.c
	In file included from ldc-src/runtime/phobos/etc/c/zlib/compress.c:9:
	In file included from ldc-src/runtime/phobos/etc/c/zlib/zlib.h:34:
	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.
	[3/40] Building C object CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/adler32.c.o
	FAILED: CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/adler32.c.o
	/usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang   -DHAVE_UNISTD_H -fPIC   -ffunction-sections -funwind-tables -fstack-protector-strong -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes -g -DNDEBUG -DANDROID  -D__ANDROID_API__=21 -Wa,--noexecstack -Wformat -Werror=format-security -fpie -target armv7-none-linux-androideabi21 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -gcc-toolchain /usr/lib/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot /usr/lib/android-ndk/sysroot -isystem /usr/lib/android-ndk/sysroot/usr/include/arm-linux-androideabi -fno-integrated-as -MD -MT CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/adler32.c.o -MF CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/adler32.c.o.d -o CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/adler32.c.o   -c ldc-src/runtime/phobos/etc/c/zlib/adler32.c
	In file included from ldc-src/runtime/phobos/etc/c/zlib/adler32.c:8:
	In file included from ldc-src/runtime/phobos/etc/c/zlib/zutil.h:22:
	In file included from ldc-src/runtime/phobos/etc/c/zlib/zlib.h:34:
	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.
	[4/40] Building C object CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/gzlib.c.o
	FAILED: CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/gzlib.c.o
	/usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang   -DHAVE_UNISTD_H -fPIC   -ffunction-sections -funwind-tables -fstack-protector-strong -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes -g -DNDEBUG -DANDROID  -D__ANDROID_API__=21 -Wa,--noexecstack -Wformat -Werror=format-security -fpie -target armv7-none-linux-androideabi21 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -gcc-toolchain /usr/lib/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot /usr/lib/android-ndk/sysroot -isystem /usr/lib/android-ndk/sysroot/usr/include/arm-linux-androideabi -fno-integrated-as -MD -MT CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/gzlib.c.o -MF CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/gzlib.c.o.d -o CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/gzlib.c.o   -c ldc-src/runtime/phobos/etc/c/zlib/gzlib.c
	In file included from ldc-src/runtime/phobos/etc/c/zlib/gzlib.c:6:
	ldc-src/runtime/phobos/etc/c/zlib/gzguts.h:21:10: fatal error: 'stdio.h' file not found
	#include <stdio.h>
		 ^
	1 error generated.
	[5/40] Building C object CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/gzread.c.o
	FAILED: CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/gzread.c.o
	/usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang   -DHAVE_UNISTD_H -fPIC   -ffunction-sections -funwind-tables -fstack-protector-strong -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes -g -DNDEBUG -DANDROID  -D__ANDROID_API__=21 -Wa,--noexecstack -Wformat -Werror=format-security -fpie -target armv7-none-linux-androideabi21 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -gcc-toolchain /usr/lib/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot /usr/lib/android-ndk/sysroot -isystem /usr/lib/android-ndk/sysroot/usr/include/arm-linux-androideabi -fno-integrated-as -MD -MT CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/gzread.c.o -MF CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/gzread.c.o.d -o CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/gzread.c.o   -c ldc-src/runtime/phobos/etc/c/zlib/gzread.c
	In file included from ldc-src/runtime/phobos/etc/c/zlib/gzread.c:6:
	ldc-src/runtime/phobos/etc/c/zlib/gzguts.h:21:10: fatal error: 'stdio.h' file not found
	#include <stdio.h>
		 ^
	1 error generated.
	[6/40] Building C object CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/deflate.c.o
	FAILED: CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/deflate.c.o
	/usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang   -DHAVE_UNISTD_H -fPIC   -ffunction-sections -funwind-tables -fstack-protector-strong -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes -g -DNDEBUG -DANDROID  -D__ANDROID_API__=21 -Wa,--noexecstack -Wformat -Werror=format-security -fpie -target armv7-none-linux-androideabi21 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -gcc-toolchain /usr/lib/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot /usr/lib/android-ndk/sysroot -isystem /usr/lib/android-ndk/sysroot/usr/include/arm-linux-androideabi -fno-integrated-as -MD -MT CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/deflate.c.o -MF CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/deflate.c.o.d -o CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/deflate.c.o   -c ldc-src/runtime/phobos/etc/c/zlib/deflate.c
	In file included from ldc-src/runtime/phobos/etc/c/zlib/deflate.c:52:
	In file included from ldc-src/runtime/phobos/etc/c/zlib/deflate.h:16:
	In file included from ldc-src/runtime/phobos/etc/c/zlib/zutil.h:22:
	In file included from ldc-src/runtime/phobos/etc/c/zlib/zlib.h:34:
	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.
	[7/40] Building C object CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/gzclose.c.o
	FAILED: CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/gzclose.c.o
	/usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang   -DHAVE_UNISTD_H -fPIC   -ffunction-sections -funwind-tables -fstack-protector-strong -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes -g -DNDEBUG -DANDROID  -D__ANDROID_API__=21 -Wa,--noexecstack -Wformat -Werror=format-security -fpie -target armv7-none-linux-androideabi21 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -gcc-toolchain /usr/lib/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot /usr/lib/android-ndk/sysroot -isystem /usr/lib/android-ndk/sysroot/usr/include/arm-linux-androideabi -fno-integrated-as -MD -MT CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/gzclose.c.o -MF CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/gzclose.c.o.d -o CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/gzclose.c.o   -c ldc-src/runtime/phobos/etc/c/zlib/gzclose.c
	In file included from ldc-src/runtime/phobos/etc/c/zlib/gzclose.c:6:
	ldc-src/runtime/phobos/etc/c/zlib/gzguts.h:21:10: fatal error: 'stdio.h' file not found
	#include <stdio.h>
		 ^
	1 error generated.
	[8/40] Building C object CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/crc32.c.o
	FAILED: CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/crc32.c.o
	/usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang   -DHAVE_UNISTD_H -fPIC   -ffunction-sections -funwind-tables -fstack-protector-strong -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes -g -DNDEBUG -DANDROID  -D__ANDROID_API__=21 -Wa,--noexecstack -Wformat -Werror=format-security -fpie -target armv7-none-linux-androideabi21 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -gcc-toolchain /usr/lib/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot /usr/lib/android-ndk/sysroot -isystem /usr/lib/android-ndk/sysroot/usr/include/arm-linux-androideabi -fno-integrated-as -MD -MT CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/crc32.c.o -MF CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/crc32.c.o.d -o CMakeFiles/phobos2-ldc-debug.dir/phobos/etc/c/zlib/crc32.c.o   -c ldc-src/runtime/phobos/etc/c/zlib/crc32.c
	In file included from ldc-src/runtime/phobos/etc/c/zlib/crc32.c:31:
	In file included from ldc-src/runtime/phobos/etc/c/zlib/zutil.h:22:
	In file included from ldc-src/runtime/phobos/etc/c/zlib/zlib.h:34:
	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.
	ninja: build stopped: subcommand failed.
	Warning: build directory already exists: droid32
	Invoking: ["cmake", "-DLDC_EXE_FULL=/mnt/3/usr/src/d/android/ldc2-1.12.0-linux-x86_64/bin/ldc2", "-DD_VERSION=2", "-DDMDFE_MINOR_VERSION=0", "-DDMDFE_PATCH_VERSION=82", "-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", "-G", "Ninja", "/mnt/3/usr/src/d/android/droid32/ldc-src/runtime"]
	Invoking: ["ninja", "all"]
	Error: command failed with status 1


T

-- 
Государство делает вид, что платит нам зарплату, а мы делаем вид, что работаем.
October 19, 2018
On Fri, Oct 19, 2018 at 02:41:48PM -0700, H. S. Teoh via Digitalmars-d wrote: [...]
> In the meantime, is there a particular version of the NDK that I should use?  Currently I have android-ndk-r13b-linux-x86_64.zip installed.  Will it work?
[...]

Haha, I feel so silly now.  NDK r13b does not seem to have the sysroot subdir required by the clang build command, that's why it couldn't find the system headers.  So I ditched r13b and installed r17b instead, and now I can build the runtime successfully!


T

-- 
Questions are the beginning of intelligence, but the fear of God is the beginning of wisdom.
October 19, 2018
On Fri, Oct 19, 2018 at 08:50:36PM +0000, Joakim via Digitalmars-d wrote:
> On Wednesday, 17 October 2018 at 21:23:21 UTC, H. S. Teoh wrote:
> > I'm trying to follow the instructions on this page:
> > 
> > 	https://wiki.dlang.org/Build_D_for_Android
[...]

On a side note, the last section on that page mentions not knowing how to create a keystore from scratch; actually, it's very simple with the `keytool` utility that comes with the Oracle JRE.  I added the steps on the talk page.  The only thing I'm unsure about is whether keytool is available natively on Android.  If not, then you'll have to generate the keystore on a PC and copy it over to Android afterwards.


T

-- 
Computers shouldn't beep through the keyhole.
October 20, 2018
On Friday, 19 October 2018 at 22:19:31 UTC, H. S. Teoh wrote:
> On Fri, Oct 19, 2018 at 02:41:48PM -0700, H. S. Teoh via Digitalmars-d wrote: [...]
>> In the meantime, is there a particular version of the NDK that I should use?  Currently I have android-ndk-r13b-linux-x86_64.zip installed.  Will it work?
> [...]
>
> Haha, I feel so silly now.  NDK r13b does not seem to have the sysroot subdir required by the clang build command, that's why it couldn't find the system headers.  So I ditched r13b and installed r17b instead, and now I can build the runtime successfully!

Ah, that makes sense, that NDK is ancient, ;) it came out two years ago:

https://developer.android.com/ndk/downloads/revision_history

Official D support for Android was added to ldc 1.4 last September, which was after NDK r15c came out, when they switched to that sysroot directory with unified headers for all Android versions, so that's what ldc uses. Before that, each Android version had its headers in a separate directory, which isn't supported by LDC.

> I tried ldc-build-runtime with --ninja and it
> came back with a bunch of errors about "cortex-a8"
> being an unsupported target, and then segfaulted.

That's likely because you left off the double-quotes around the list of semicolon-separated flags passed to ldc-build-runtime --dFlags: the double quotes are required, as shown in the docs.

On Saturday, 20 October 2018 at 04:01:37 UTC, H. S. Teoh wrote:
> On Fri, Oct 19, 2018 at 08:50:36PM +0000, Joakim via Digitalmars-d wrote:
>> On Wednesday, 17 October 2018 at 21:23:21 UTC, H. S. Teoh wrote:
>> > I'm trying to follow the instructions on this page:
>> > 
>> > 	https://wiki.dlang.org/Build_D_for_Android
> [...]
>
> On a side note, the last section on that page mentions not knowing how to create a keystore from scratch; actually, it's very simple with the `keytool` utility that comes with the Oracle JRE.  I added the steps on the talk page.  The only thing I'm unsure about is whether keytool is available natively on Android.  If not, then you'll have to generate the keystore on a PC and copy it over to Android afterwards.

From scratch meaning without using keytool, ie OpenSSL or some other hashing/fingerprinting tool alone, because keytool isn't available in the Termux app. As mentioned at the end of the wiki page, I used to manually edit the apk hashed manifests using OpenSSL alone until that apksigner tool was added later.
October 21, 2018
On Sat, Oct 20, 2018 at 09:51:28AM +0000, Joakim via Digitalmars-d wrote:
> On Friday, 19 October 2018 at 22:19:31 UTC, H. S. Teoh wrote:
[...]
> > Haha, I feel so silly now.  NDK r13b does not seem to have the sysroot subdir required by the clang build command, that's why it couldn't find the system headers.  So I ditched r13b and installed r17b instead, and now I can build the runtime successfully!
> 
> Ah, that makes sense, that NDK is ancient, ;) it came out two years ago:
> 
> https://developer.android.com/ndk/downloads/revision_history

Well, it was what came with my distro, and I had just installed it without much thought as to how recent it was or whether LDC would support it.


> Official D support for Android was added to ldc 1.4 last September, which was after NDK r15c came out, when they switched to that sysroot directory with unified headers for all Android versions, so that's what ldc uses.  Before that, each Android version had its headers in a separate directory, which isn't supported by LDC.

Thanks for the info, updated the wiki page.


[...]
> > On a side note, the last section on that page mentions not knowing how to create a keystore from scratch; actually, it's very simple with the `keytool` utility that comes with the Oracle JRE.  I added the steps on the talk page.  The only thing I'm unsure about is whether keytool is available natively on Android.  If not, then you'll have to generate the keystore on a PC and copy it over to Android afterwards.
> 
> From scratch meaning without using keytool, ie OpenSSL or some other hashing/fingerprinting tool alone, because keytool isn't available in the Termux app. As mentioned at the end of the wiki page, I used to manually edit the apk hashed manifests using OpenSSL alone until that apksigner tool was added later.

I see.  Anyway, if openssl works then IMO it's so much the better than the walled garden that is keytool / Java keystore.


T

-- 
Creativity is not an excuse for sloppiness.