Re: Need help with setting up LDC to cross-compile to Android/ARM
On Sat, Oct 20, 2018 at 09:51:28AM +, 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.
Re: Need help with setting up LDC to cross-compile to Android/ARM
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 +, 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.
Re: Need help with setting up LDC to cross-compile to Android/ARM
On Fri, Oct 19, 2018 at 08:50:36PM +, 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.
Re: Need help with setting up LDC to cross-compile to Android/ARM
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.
Re: Need help with setting up LDC to cross-compile to Android/ARM
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 ^ 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 /* for off_t */
Re: Need help with setting up LDC to cross-compile to Android/ARM
On Fri, Oct 19, 2018 at 08:54:25PM +, 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"...
Re: Need help with setting up LDC to cross-compile to Android/ARM
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
Re: Need help with setting up LDC to cross-compile to Android/ARM
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.