www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - [Tutorial][Binaries] gdc for android

reply Johannes Pfau <nospam example.com> writes:
Hi,
I tried to rebuild the android ndk with gdc and documented the build
process at https://bitbucket.org/goshawk/gdc/wiki/GDC%20on%20Android

The tutorial explains how to build a gdc cross compiler for android. It
uses GCC 4.6.2, a recent binutils snapshot and additionally provides a
recent gdb 7.4.

32bit linux binaries are also available here:
http://www.mediafire.com/?2cex2faqx327l
Download the android ndk r7 and extract the gdc 7z file in
android-ndk-r7/toolchains/

What's working:
I couldn't test the compiler yet and I hope someone else will provide
feedback, but the basic gdc compiler should work. druntime may or may
not work, but it's distributed so that can be tested.
Phobos is not being built yet.

Known bugs/TODO:

You need to build all D code with -fno-section-anchors, see
https://bitbucket.org/goshawk/gdc/issue/120/fsection-anchors-broken-on-arm

build-druntime.patch needs to be integrated with gdc. See
https://gist.github.com/1739039
There are basically 3 things this patch does:
* Currently gdc checks for __libc_stack_end as that's used by
  druntime. This function is only available in glibc, but bionic
  provides a similar function: __get_stack_base. The patch currently
  simply replaces __libc_stack_end. We need some way to detect if we
  build for bionic, so we can properly version this code. It should
  also be tested to verify it is working correctly
* Building gcc/config/unix.d fails, so the patch simply skips that
  file. This should be investigated further and fixed correctly.
* Disables phobos for now, although I think I just disabled building the
  final library and the object files are still being built.

gdbserver is not being built for some reason. Had no time to
investigate that yet.
Feb 04 2012
next sibling parent "Nick Sabalausky" <a a.a> writes:
"Johannes Pfau" <nospam example.com> wrote in message 
news:20120204203109.26c9a80b jpf-laptop...
 Hi,
 I tried to rebuild the android ndk with gdc and documented the build
 process at https://bitbucket.org/goshawk/gdc/wiki/GDC%20on%20Android

 The tutorial explains how to build a gdc cross compiler for android. It
 uses GCC 4.6.2, a recent binutils snapshot and additionally provides a
 recent gdb 7.4.

 32bit linux binaries are also available here:
 http://www.mediafire.com/?2cex2faqx327l
 Download the android ndk r7 and extract the gdc 7z file in
 android-ndk-r7/toolchains/

 What's working:
 I couldn't test the compiler yet and I hope someone else will provide
 feedback, but the basic gdc compiler should work. druntime may or may
 not work, but it's distributed so that can be tested.
 Phobos is not being built yet.

 Known bugs/TODO:

 You need to build all D code with -fno-section-anchors, see
 https://bitbucket.org/goshawk/gdc/issue/120/fsection-anchors-broken-on-arm

 build-druntime.patch needs to be integrated with gdc. See
 https://gist.github.com/1739039
 There are basically 3 things this patch does:
 * Currently gdc checks for __libc_stack_end as that's used by
  druntime. This function is only available in glibc, but bionic
  provides a similar function: __get_stack_base. The patch currently
  simply replaces __libc_stack_end. We need some way to detect if we
  build for bionic, so we can properly version this code. It should
  also be tested to verify it is working correctly
 * Building gcc/config/unix.d fails, so the patch simply skips that
  file. This should be investigated further and fixed correctly.
 * Disables phobos for now, although I think I just disabled building the
  final library and the object files are still being built.

 gdbserver is not being built for some reason. Had no time to
 investigate that yet.

Awesome! I look forward to giving it a try.
Feb 04 2012
prev sibling next sibling parent reply Iain Buclaw <ibuclaw ubuntu.com> writes:
On 4 February 2012 21:59, Manu <turkeyman gmail.com> wrote:
 On 4 February 2012 21:31, Johannes Pfau <nospam example.com> wrote:
 Hi,
 I tried to rebuild the android ndk with gdc and documented the build
 process at https://bitbucket.org/goshawk/gdc/wiki/GDC%20on%20Android

 The tutorial explains how to build a gdc cross compiler for android. It
 uses GCC 4.6.2, a recent binutils snapshot and additionally provides a
 recent gdb 7.4.

 32bit linux binaries are also available here:
 http://www.mediafire.com/?2cex2faqx327l
 Download the android ndk r7 and extract the gdc 7z file in
 android-ndk-r7/toolchains/

 What's working:
 I couldn't test the compiler yet and I hope someone else will provide
 feedback, but the basic gdc compiler should work. druntime may or may
 not work, but it's distributed so that can be tested.
 Phobos is not being built yet.

 Known bugs/TODO:

 You need to build all D code with -fno-section-anchors, see
 https://bitbucket.org/goshawk/gdc/issue/120/fsection-anchors-broken-on-a=


 build-druntime.patch needs to be integrated with gdc. See
 https://gist.github.com/1739039
 There are basically 3 things this patch does:
 * Currently gdc checks for __libc_stack_end as that's used by
 =A0druntime. This function is only available in glibc, but bionic
 =A0provides a similar function: __get_stack_base. The patch currently
 =A0simply replaces __libc_stack_end. We need some way to detect if we
 =A0build for bionic, so we can properly version this code. It should
 =A0also be tested to verify it is working correctly
 * Building gcc/config/unix.d fails, so the patch simply skips that
 =A0file. This should be investigated further and fixed correctly.
 * Disables phobos for now, although I think I just disabled building the
 =A0final library and the object files are still being built.

 gdbserver is not being built for some reason. Had no time to
 investigate that yet.

Amazing! Do you know how/could you produce binaries for the mingw host? The androi=

 toolchain for windows can only be built from linux according to the
 toolchain docs last time I tried to build it.

Virtualbox. :=FE --=20 Iain Buclaw *(p < e ? p++ : p) =3D (c & 0x0f) + '0';
Feb 04 2012
parent =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= <xtzgzorex gmail.com> writes:
On 02/05/2012 11:04 PM, Johannes Pfau wrote:
 Am Sun, 5 Feb 2012 18:04:12 +0100
 schrieb Johannes Pfau<nospam example.com>:

 I will probably need some more time to get this working...

I have some good news: http://www.mediafire.com/?107we120sh3xx I fixed that problem and then the whole build worked fine. I'll post build instructions soon, but the binaries are ready. I only did a simple gdc -c test.d to check the compiler, but it seems to work. Linking against druntime fails, as it uses functions which are not available on Android (backtrace, signal stuff). I also built a simple hello world on linux (printf, no runtime) and ran it on my android phone, and it worked! In case you haven't used GDC without runtime before, a short introduction: * use gdc -nophoboslib to make gdc not link against phobos (and afaik, druntime) * theres also -nostdlib in case you need it * complex code may require -fno-section-anchors because of bug #120 * You'll get an error about a missing _Dmodule_ref symbol. That symbol is used by module constructors and not generated by gdc if -nophoboslib was passed. As long as you don't run the module constructors, you can add a fake _Dmodule_ref in a .c file: ------------ void* _Dmodule_ref; ------------ * The compiler defines version(Android) Here's my hello world: ------------ version(Android) { pragma(msg, "Hello Android!"); } extern(C) { int printf(in char* format, ...); } extern(C) void main() { printf("Hello, %s!\n".ptr, "Android".ptr); } ------------ compile the _Dmodule_ref into hack.o, then use gdc -nophoboslib hello.d hack.o

Can we standardize that Android version identifier? Would be good to have it on dlang.org/version.html. -- - Alex
Feb 05 2012
prev sibling next sibling parent Johannes Pfau <nospam example.com> writes:
Am Sat, 4 Feb 2012 22:17:54 +0000
schrieb Iain Buclaw <ibuclaw ubuntu.com>:

 On 4 February 2012 21:59, Manu <turkeyman gmail.com> wrote:
 On 4 February 2012 21:31, Johannes Pfau <nospam example.com> wrote:
 Hi,
 I tried to rebuild the android ndk with gdc and documented the
 build process at
 https://bitbucket.org/goshawk/gdc/wiki/GDC%20on%20Android

 The tutorial explains how to build a gdc cross compiler for
 android. It uses GCC 4.6.2, a recent binutils snapshot and
 additionally provides a recent gdb 7.4.

 32bit linux binaries are also available here:
 http://www.mediafire.com/?2cex2faqx327l
 Download the android ndk r7 and extract the gdc 7z file in
 android-ndk-r7/toolchains/

 What's working:
 I couldn't test the compiler yet and I hope someone else will
 provide feedback, but the basic gdc compiler should work. druntime
 may or may not work, but it's distributed so that can be tested.
 Phobos is not being built yet.

 Known bugs/TODO:

 You need to build all D code with -fno-section-anchors, see
 https://bitbucket.org/goshawk/gdc/issue/120/fsection-anchors-broken-on=



 build-druntime.patch needs to be integrated with gdc. See
 https://gist.github.com/1739039
 There are basically 3 things this patch does:
 * Currently gdc checks for __libc_stack_end as that's used by
 =C2=A0druntime. This function is only available in glibc, but bionic
 =C2=A0provides a similar function: __get_stack_base. The patch current=



 =C2=A0simply replaces __libc_stack_end. We need some way to detect if =



 =C2=A0build for bionic, so we can properly version this code. It should
 =C2=A0also be tested to verify it is working correctly
 * Building gcc/config/unix.d fails, so the patch simply skips that
 =C2=A0file. This should be investigated further and fixed correctly.
 * Disables phobos for now, although I think I just disabled
 building the final library and the object files are still being
 built.

 gdbserver is not being built for some reason. Had no time to
 investigate that yet.

Amazing! Do you know how/could you produce binaries for the mingw host? The android toolchain for windows can only be built from linux according to the toolchain docs last time I tried to build it.

Virtualbox. :=C3=BE =20

According to the docs I just have to pass --mingw to the build script and use the windows ndk as a base. I'll try this tomorrow, but I'd be surprised if it really was that easy ;-)
Feb 04 2012
prev sibling next sibling parent Manu <turkeyman gmail.com> writes:
--0022158c0d410f0c4304b82ca979
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 5 February 2012 01:17, Johannes Pfau <nospam example.com> wrote:

 Am Sat, 4 Feb 2012 22:17:54 +0000
 schrieb Iain Buclaw <ibuclaw ubuntu.com>:

 On 4 February 2012 21:59, Manu <turkeyman gmail.com> wrote:
 On 4 February 2012 21:31, Johannes Pfau <nospam example.com> wrote:
 Hi,
 I tried to rebuild the android ndk with gdc and documented the
 build process at
 https://bitbucket.org/goshawk/gdc/wiki/GDC%20on%20Android

 The tutorial explains how to build a gdc cross compiler for
 android. It uses GCC 4.6.2, a recent binutils snapshot and
 additionally provides a recent gdb 7.4.

 32bit linux binaries are also available here:
 http://www.mediafire.com/?2cex2faqx327l
 Download the android ndk r7 and extract the gdc 7z file in
 android-ndk-r7/toolchains/

 What's working:
 I couldn't test the compiler yet and I hope someone else will
 provide feedback, but the basic gdc compiler should work. druntime
 may or may not work, but it's distributed so that can be tested.
 Phobos is not being built yet.

 Known bugs/TODO:

 You need to build all D code with -fno-section-anchors, see




 build-druntime.patch needs to be integrated with gdc. See
 https://gist.github.com/1739039
 There are basically 3 things this patch does:
 * Currently gdc checks for __libc_stack_end as that's used by
  druntime. This function is only available in glibc, but bionic
  provides a similar function: __get_stack_base. The patch currently
  simply replaces __libc_stack_end. We need some way to detect if we
  build for bionic, so we can properly version this code. It should
  also be tested to verify it is working correctly
 * Building gcc/config/unix.d fails, so the patch simply skips that
  file. This should be investigated further and fixed correctly.
 * Disables phobos for now, although I think I just disabled
 building the final library and the object files are still being
 built.

 gdbserver is not being built for some reason. Had no time to
 investigate that yet.

Amazing! Do you know how/could you produce binaries for the mingw host? The android toolchain for windows can only be built from linux according to the toolchain docs last time I tried to build it.

Virtualbox. :=C3=BE

According to the docs I just have to pass --mingw to the build script and use the windows ndk as a base. I'll try this tomorrow, but I'd be surprised if it really was that easy ;-)

Me too, but good luck! Here's hoping... :P --0022158c0d410f0c4304b82ca979 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On 5 February 2012 01:17, Johannes Pfau <span di= r=3D"ltr">&lt;<a href=3D"mailto:nospam example.com">nospam example.com</a>&= gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 = 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Am Sat, 4 Feb 2012 22:17:54 +0000<br> schrieb Iain Buclaw &lt;<a href=3D"mailto:ibuclaw ubuntu.com">ibuclaw ubunt= u.com</a>&gt;:<br> <div><div class=3D"h5"><br> &gt; On 4 February 2012 21:59, Manu &lt;<a href=3D"mailto:turkeyman gmail.c= om">turkeyman gmail.com</a>&gt; wrote:<br> &gt; &gt; On 4 February 2012 21:31, Johannes Pfau &lt;<a href=3D"mailto:nos= pam example.com">nospam example.com</a>&gt; wrote:<br> &gt; &gt;&gt;<br> &gt; &gt;&gt; Hi,<br> &gt; &gt;&gt; I tried to rebuild the android ndk with gdc and documented th= e<br> &gt; &gt;&gt; build process at<br> &gt; &gt;&gt; <a href=3D"https://bitbucket.org/goshawk/gdc/wiki/GDC%20on%20= Android" target=3D"_blank">https://bitbucket.org/goshawk/gdc/wiki/GDC%20on%= 20Android</a><br> &gt; &gt;&gt;<br> &gt; &gt;&gt; The tutorial explains how to build a gdc cross compiler for<b= r> &gt; &gt;&gt; android. It uses GCC 4.6.2, a recent binutils snapshot and<br=

&gt; &gt;&gt;<br> &gt; &gt;&gt; 32bit linux binaries are also available here:<br> &gt; &gt;&gt; <a href=3D"http://www.mediafire.com/?2cex2faqx327l" target=3D= "_blank">http://www.mediafire.com/?2cex2faqx327l</a><br> &gt; &gt;&gt; Download the android ndk r7 and extract the gdc 7z file in<br=

&gt; &gt;&gt;<br> &gt; &gt;&gt; What&#39;s working:<br> &gt; &gt;&gt; I couldn&#39;t test the compiler yet and I hope someone else = will<br> &gt; &gt;&gt; provide feedback, but the basic gdc compiler should work. dru= ntime<br> &gt; &gt;&gt; may or may not work, but it&#39;s distributed so that can be = tested.<br> &gt; &gt;&gt; Phobos is not being built yet.<br> &gt; &gt;&gt;<br> &gt; &gt;&gt; Known bugs/TODO:<br> &gt; &gt;&gt;<br> &gt; &gt;&gt; You need to build all D code with -fno-section-anchors, see<b= r> &gt; &gt;&gt; <a href=3D"https://bitbucket.org/goshawk/gdc/issue/120/fsecti= on-anchors-broken-on-arm" target=3D"_blank">https://bitbucket.org/goshawk/g= dc/issue/120/fsection-anchors-broken-on-arm</a><br> &gt; &gt;&gt;<br> &gt; &gt;&gt; build-druntime.patch needs to be integrated with gdc. See<br> &gt; &gt;&gt; <a href=3D"https://gist.github.com/1739039" target=3D"_blank"=
https://gist.github.com/1739039</a><br>

&gt; &gt;&gt; * Currently gdc checks for __libc_stack_end as that&#39;s use= d by<br> &gt; &gt;&gt; =C2=A0druntime. This function is only available in glibc, but= bionic<br> &gt; &gt;&gt; =C2=A0provides a similar function: __get_stack_base. The patc= h currently<br> &gt; &gt;&gt; =C2=A0simply replaces __libc_stack_end. We need some way to d= etect if we<br> &gt; &gt;&gt; =C2=A0build for bionic, so we can properly version this code.= It should<br> &gt; &gt;&gt; =C2=A0also be tested to verify it is working correctly<br> &gt; &gt;&gt; * Building gcc/config/unix.d fails, so the patch simply skips= that<br> &gt; &gt;&gt; =C2=A0file. This should be investigated further and fixed cor= rectly.<br> &gt; &gt;&gt; * Disables phobos for now, although I think I just disabled<b= r> &gt; &gt;&gt; building the final library and the object files are still bei= ng<br> &gt; &gt;&gt; built.<br> &gt; &gt;&gt;<br> &gt; &gt;&gt; gdbserver is not being built for some reason. Had no time to<= br> &gt; &gt;&gt; investigate that yet.<br> &gt; &gt;<br> &gt; &gt;<br> &gt; &gt; Amazing!<br> &gt; &gt; Do you know how/could you produce binaries for the mingw host? Th= e<br> &gt; &gt; android toolchain for windows can only be built from linux<br> &gt; &gt; according to the toolchain docs last time I tried to build it.<br=

</div></div>&gt; Virtualbox. :=C3=BE<br> &gt;<br> <br> According to the docs I just have to pass --mingw to the build script<br> and use the windows ndk as a base. I&#39;ll try this tomorrow, but I&#39;d = be<br> surprised if it really was that easy ;-)<br></blockquote><div><br></div><di= v>Me too, but good luck!</div><div>Here&#39;s hoping... :P=C2=A0</div></div=

--0022158c0d410f0c4304b82ca979--
Feb 04 2012
prev sibling next sibling parent =?ISO-8859-1?Q?S=F6nke_Ludwig?= <ludwig informatik.uni-luebeck.de> writes:
Great thing! I tried some time ago to build gdc like this, but I always 
faild miserably due to obscure make problems. Maybe my library versions 
were slightly off... I'll try this out later today.
Feb 05 2012
prev sibling next sibling parent Johannes Pfau <nospam example.com> writes:
Am Sun, 05 Feb 2012 12:21:43 +0100
schrieb S=C3=B6nke Ludwig <ludwig informatik.uni-luebeck.de>:

 Great thing! I tried some time ago to build gdc like this, but I
 always faild miserably due to obscure make problems. Maybe my library
 versions were slightly off... I'll try this out later today.

Library versions are one problem but I also had build failures when texinfo wasn't installed (although all packages say texinfo is completely optional...). The hardest part was actually getting a plain gcc-4.6.2 toolchain to build, adding gdc is easy.
Feb 05 2012
prev sibling next sibling parent Johannes Pfau <nospam example.com> writes:
Am Sun, 5 Feb 2012 02:31:01 +0200
schrieb Manu <turkeyman gmail.com>:

 On 5 February 2012 01:17, Johannes Pfau <nospam example.com> wrote:
=20
 Am Sat, 4 Feb 2012 22:17:54 +0000
 schrieb Iain Buclaw <ibuclaw ubuntu.com>:

 On 4 February 2012 21:59, Manu <turkeyman gmail.com> wrote:
 On 4 February 2012 21:31, Johannes Pfau <nospam example.com>
 wrote:
 Hi,
 I tried to rebuild the android ndk with gdc and documented the
 build process at
 https://bitbucket.org/goshawk/gdc/wiki/GDC%20on%20Android

 The tutorial explains how to build a gdc cross compiler for
 android. It uses GCC 4.6.2, a recent binutils snapshot and
 additionally provides a recent gdb 7.4.

 32bit linux binaries are also available here:
 http://www.mediafire.com/?2cex2faqx327l
 Download the android ndk r7 and extract the gdc 7z file in
 android-ndk-r7/toolchains/

 What's working:
 I couldn't test the compiler yet and I hope someone else will
 provide feedback, but the basic gdc compiler should work.
 druntime may or may not work, but it's distributed so that can
 be tested. Phobos is not being built yet.

 Known bugs/TODO:

 You need to build all D code with -fno-section-anchors, see





 build-druntime.patch needs to be integrated with gdc. See
 https://gist.github.com/1739039
 There are basically 3 things this patch does:
 * Currently gdc checks for __libc_stack_end as that's used by
  druntime. This function is only available in glibc, but bionic
  provides a similar function: __get_stack_base. The patch
 currently simply replaces __libc_stack_end. We need some way
 to detect if we build for bionic, so we can properly version
 this code. It should also be tested to verify it is working
 correctly
 * Building gcc/config/unix.d fails, so the patch simply skips
 that file. This should be investigated further and fixed
 correctly.
 * Disables phobos for now, although I think I just disabled
 building the final library and the object files are still being
 built.

 gdbserver is not being built for some reason. Had no time to
 investigate that yet.

Amazing! Do you know how/could you produce binaries for the mingw host? The android toolchain for windows can only be built from linux according to the toolchain docs last time I tried to build it.

Virtualbox. :=C3=BE

According to the docs I just have to pass --mingw to the build script and use the windows ndk as a base. I'll try this tomorrow, but I'd be surprised if it really was that easy ;-)

Me too, but good luck! Here's hoping... :P =20

somehow the build scripts pick up the wrong compiler and I have no clue why. ------------------- configure:2642: checking for i586-mingw32msvc-gcc configure:2669: result: gcc configure:2938: checking for C compiler version configure:2947: gcc --version >&5 gcc (Debian 4.6.1-4) 4.6.1 ------------------- I will probably need some more time to get this working...
Feb 05 2012
prev sibling next sibling parent Johannes Pfau <nospam example.com> writes:
Am Sun, 5 Feb 2012 18:04:12 +0100
schrieb Johannes Pfau <nospam example.com>:

 I will probably need some more time to get this working...
 

I have some good news: http://www.mediafire.com/?107we120sh3xx I fixed that problem and then the whole build worked fine. I'll post build instructions soon, but the binaries are ready. I only did a simple gdc -c test.d to check the compiler, but it seems to work. Linking against druntime fails, as it uses functions which are not available on Android (backtrace, signal stuff). I also built a simple hello world on linux (printf, no runtime) and ran it on my android phone, and it worked! In case you haven't used GDC without runtime before, a short introduction: * use gdc -nophoboslib to make gdc not link against phobos (and afaik, druntime) * theres also -nostdlib in case you need it * complex code may require -fno-section-anchors because of bug #120 * You'll get an error about a missing _Dmodule_ref symbol. That symbol is used by module constructors and not generated by gdc if -nophoboslib was passed. As long as you don't run the module constructors, you can add a fake _Dmodule_ref in a .c file: ------------ void* _Dmodule_ref; ------------ * The compiler defines version(Android) Here's my hello world: ------------ version(Android) { pragma(msg, "Hello Android!"); } extern(C) { int printf(in char* format, ...); } extern(C) void main() { printf("Hello, %s!\n".ptr, "Android".ptr); } ------------ compile the _Dmodule_ref into hack.o, then use gdc -nophoboslib hello.d hack.o
Feb 05 2012
prev sibling next sibling parent maarten van damme <maartenvd1994 gmail.com> writes:
--047d7b33d8d86f769704b83f85af
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

wow, great news for my phone :)
I've read another blogpost about someone trying to achieve the same, had
something to do with "between ideals", I'll google it up if you need it.
he had a github repo with some "ugly hacks" to make druntime work for
android, maybe this can be looked into?

2012/2/5 Alex R=F8nne Petersen <xtzgzorex gmail.com>

 On 02/05/2012 11:04 PM, Johannes Pfau wrote:

 Am Sun, 5 Feb 2012 18:04:12 +0100
 schrieb Johannes Pfau<nospam example.com>:

  I will probably need some more time to get this working...

http://www.mediafire.com/?**107we120sh3xx<http://www.mediafire.com/?107w=


 I fixed that problem and then the whole build worked fine. I'll post
 build instructions soon, but the binaries are ready. I only did a
 simple gdc -c test.d to check the compiler, but it seems to work.

 Linking against druntime fails, as it uses functions which are not
 available on Android (backtrace, signal stuff).

 I also built a simple hello world on linux (printf, no runtime) and ran
 it on my android phone, and it worked!

 In case you haven't used GDC without runtime before, a short
 introduction:

 * use gdc -nophoboslib to make gdc not link against phobos (and afaik,
   druntime)
 * theres also -nostdlib in case you need it
 * complex code may require -fno-section-anchors because of bug #120
 * You'll get an error about a missing _Dmodule_ref symbol. That symbol
   is used by module constructors and not generated by gdc if
   -nophoboslib was passed. As long as you don't run the module
   constructors, you can add a fake _Dmodule_ref in a .c file:

 ------------
 void* _Dmodule_ref;
 ------------

 * The compiler defines version(Android)

 Here's my hello world:
 ------------
 version(Android)
 {
     pragma(msg, "Hello Android!");
 }

 extern(C)
 {
     int printf(in char* format, ...);
 }

 extern(C) void main()
 {
     printf("Hello, %s!\n".ptr, "Android".ptr);
 }
 ------------

 compile the _Dmodule_ref into hack.o, then use
 gdc -nophoboslib hello.d hack.o

Can we standardize that Android version identifier? Would be good to have it on dlang.org/version.html. -- - Alex

--047d7b33d8d86f769704b83f85af Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable wow, great news for my phone :)<br>I&#39;ve read another blogpost about som= eone trying to achieve the same, had something to do with &quot;between ide= als&quot;, I&#39;ll google it up if you need it.<br>he had a github repo wi= th some &quot;ugly hacks&quot; to make druntime work for android, maybe thi= s can be looked into?<br> <br><div class=3D"gmail_quote">2012/2/5 Alex R=F8nne Petersen <span dir=3D"= ltr">&lt;<a href=3D"mailto:xtzgzorex gmail.com">xtzgzorex gmail.com</a>&gt;= </span><br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bor= der-left:1px #ccc solid;padding-left:1ex"> <div class=3D"HOEnZb"><div class=3D"h5">On 02/05/2012 11:04 PM, Johannes Pf= au wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> Am Sun, 5 Feb 2012 18:04:12 +0100<br> schrieb Johannes Pfau&lt;<a href=3D"mailto:nospam example.com" target=3D"_b= lank">nospam example.com</a>&gt;:<br> <br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> I will probably need some more time to get this working...<br> <br> </blockquote> <br> I have some good news:<br> <a href=3D"http://www.mediafire.com/?107we120sh3xx" target=3D"_blank">http:= //www.mediafire.com/?<u></u>107we120sh3xx</a><br> <br> I fixed that problem and then the whole build worked fine. I&#39;ll post<br=

simple gdc -c test.d to check the compiler, but it seems to work.<br> <br> Linking against druntime fails, as it uses functions which are not<br> available on Android (backtrace, signal stuff).<br> <br> I also built a simple hello world on linux (printf, no runtime) and ran<br> it on my android phone, and it worked!<br> <br> In case you haven&#39;t used GDC without runtime before, a short<br> introduction:<br> <br> * use gdc -nophoboslib to make gdc not link against phobos (and afaik,<br> =A0 druntime)<br> * theres also -nostdlib in case you need it<br> * complex code may require -fno-section-anchors because of bug #120<br> * You&#39;ll get an error about a missing _Dmodule_ref symbol. That symbol<= br> =A0 is used by module constructors and not generated by gdc if<br> =A0 -nophoboslib was passed. As long as you don&#39;t run the module<br> =A0 constructors, you can add a fake _Dmodule_ref in a .c file:<br> <br> ------------<br> void* _Dmodule_ref;<br> ------------<br> <br> * The compiler defines version(Android)<br> <br> Here&#39;s my hello world:<br> ------------<br> version(Android)<br> {<br> =A0 =A0 pragma(msg, &quot;Hello Android!&quot;);<br> }<br> <br> extern(C)<br> {<br> =A0 =A0 int printf(in char* format, ...);<br> }<br> <br> extern(C) void main()<br> {<br> =A0 =A0 printf(&quot;Hello, %s!\n&quot;.ptr, &quot;Android&quot;.ptr);<br> }<br> ------------<br> <br> compile the _Dmodule_ref into hack.o, then use<br> gdc -nophoboslib hello.d hack.o<br> </blockquote> <br></div></div> Can we standardize that Android version identifier? Would be good to have i= t on <a href=3D"http://dlang.org/version.html" target=3D"_blank">dlang.org/= version.html</a>.<span class=3D"HOEnZb"><font color=3D"#888888"><br> <br> -- <br> - Alex<br> </font></span></blockquote></div><br> --047d7b33d8d86f769704b83f85af--
Feb 05 2012
prev sibling next sibling parent Manu <turkeyman gmail.com> writes:
--20cf300faaf1de377704b840b170
Content-Type: text/plain; charset=UTF-8

On 6 February 2012 00:04, Johannes Pfau <nospam example.com> wrote:

 Am Sun, 5 Feb 2012 18:04:12 +0100
 schrieb Johannes Pfau <nospam example.com>:

 I will probably need some more time to get this working...

I have some good news: http://www.mediafire.com/?107we120sh3xx I fixed that problem and then the whole build worked fine. I'll post build instructions soon, but the binaries are ready. I only did a simple gdc -c test.d to check the compiler, but it seems to work. Linking against druntime fails, as it uses functions which are not available on Android (backtrace, signal stuff). I also built a simple hello world on linux (printf, no runtime) and ran it on my android phone, and it worked! In case you haven't used GDC without runtime before, a short introduction: * use gdc -nophoboslib to make gdc not link against phobos (and afaik, druntime) * theres also -nostdlib in case you need it * complex code may require -fno-section-anchors because of bug #120 * You'll get an error about a missing _Dmodule_ref symbol. That symbol is used by module constructors and not generated by gdc if -nophoboslib was passed. As long as you don't run the module constructors, you can add a fake _Dmodule_ref in a .c file: ------------ void* _Dmodule_ref; ------------ * The compiler defines version(Android) Here's my hello world: ------------ version(Android) { pragma(msg, "Hello Android!"); } extern(C) { int printf(in char* format, ...); } extern(C) void main() { printf("Hello, %s!\n".ptr, "Android".ptr); } ------------ compile the _Dmodule_ref into hack.o, then use gdc -nophoboslib hello.d hack.o

Amazing! You sir, are a genius! I'm gonna have to have some fun with that after work tomorrow :) I reckon this binary distro should be put on d-p-l somewhere obvious. --20cf300faaf1de377704b840b170 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On 6 February 2012 00:04, Johannes Pfau <span di= r=3D"ltr">&lt;<a href=3D"mailto:nospam example.com">nospam example.com</a>&= gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 = 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Am Sun, 5 Feb 2012 18:04:12 +0100<br> schrieb Johannes Pfau &lt;<a href=3D"mailto:nospam example.com">nospam exam= ple.com</a>&gt;:<br> <div class=3D"im"><br> &gt; I will probably need some more time to get this working...<br> &gt;<br> <br> </div>I have some good news:<br> <a href=3D"http://www.mediafire.com/?107we120sh3xx" target=3D"_blank">http:= //www.mediafire.com/?107we120sh3xx</a><br> <br> I fixed that problem and then the whole build worked fine. I&#39;ll post<br=

simple gdc -c test.d to check the compiler, but it seems to work.<br> <br> Linking against druntime fails, as it uses functions which are not<br> available on Android (backtrace, signal stuff).<br> <br> I also built a simple hello world on linux (printf, no runtime) and ran<br> it on my android phone, and it worked!<br> <br> In case you haven&#39;t used GDC without runtime before, a short<br> introduction:<br> <br> * use gdc -nophoboslib to make gdc not link against phobos (and afaik,<br> =C2=A0druntime)<br> * theres also -nostdlib in case you need it<br> * complex code may require -fno-section-anchors because of bug #120<br> * You&#39;ll get an error about a missing _Dmodule_ref symbol. That symbol<= br> =C2=A0is used by module constructors and not generated by gdc if<br> =C2=A0-nophoboslib was passed. As long as you don&#39;t run the module<br> =C2=A0constructors, you can add a fake _Dmodule_ref in a .c file:<br> <br> ------------<br> void* _Dmodule_ref;<br> ------------<br> <br> * The compiler defines version(Android)<br> <br> Here&#39;s my hello world:<br> ------------<br> version(Android)<br> {<br> =C2=A0 =C2=A0pragma(msg, &quot;Hello Android!&quot;);<br> }<br> <br> extern(C)<br> {<br> =C2=A0 =C2=A0int printf(in char* format, ...);<br> }<br> <br> extern(C) void main()<br> {<br> =C2=A0 =C2=A0printf(&quot;Hello, %s!\n&quot;.ptr, &quot;Android&quot;.ptr)= ;<br> }<br> ------------<br> <br> compile the _Dmodule_ref into hack.o, then use<br> gdc -nophoboslib hello.d hack.o<br> </blockquote></div><br><div>Amazing! You sir, are a genius!</div><div>I&#39= ;m gonna have to have some fun with that after work tomorrow :)</div><div><= br></div><div>I reckon this binary distro should be put on d-p-l somewhere = obvious.</div> --20cf300faaf1de377704b840b170--
Feb 05 2012
prev sibling next sibling parent Manu <turkeyman gmail.com> writes:
--20cf3074b0b279546704b8414900
Content-Type: text/plain; charset=UTF-8

On 6 February 2012 02:25, Manu <turkeyman gmail.com> wrote:

 On 6 February 2012 00:04, Johannes Pfau <nospam example.com> wrote:

 Am Sun, 5 Feb 2012 18:04:12 +0100
 schrieb Johannes Pfau <nospam example.com>:

 I will probably need some more time to get this working...

I have some good news: http://www.mediafire.com/?107we120sh3xx I fixed that problem and then the whole build worked fine. I'll post build instructions soon, but the binaries are ready. I only did a simple gdc -c test.d to check the compiler, but it seems to work. Linking against druntime fails, as it uses functions which are not available on Android (backtrace, signal stuff). I also built a simple hello world on linux (printf, no runtime) and ran it on my android phone, and it worked! In case you haven't used GDC without runtime before, a short introduction: * use gdc -nophoboslib to make gdc not link against phobos (and afaik, druntime) * theres also -nostdlib in case you need it * complex code may require -fno-section-anchors because of bug #120 * You'll get an error about a missing _Dmodule_ref symbol. That symbol is used by module constructors and not generated by gdc if -nophoboslib was passed. As long as you don't run the module constructors, you can add a fake _Dmodule_ref in a .c file: ------------ void* _Dmodule_ref; ------------ * The compiler defines version(Android) Here's my hello world: ------------ version(Android) { pragma(msg, "Hello Android!"); } extern(C) { int printf(in char* format, ...); } extern(C) void main() { printf("Hello, %s!\n".ptr, "Android".ptr); } ------------ compile the _Dmodule_ref into hack.o, then use gdc -nophoboslib hello.d hack.o

Amazing! You sir, are a genius! I'm gonna have to have some fun with that after work tomorrow :) I reckon this binary distro should be put on d-p-l somewhere obvious.

I just tried with -mfpu=neon, which should allow GCC to generate neon opcodes for the simd stuff, but it didn't seem to want to do that. In fact it generates really horrible code where it CALLS an intrinsic for each float in the vector... Any idea why this wouldn't work out of the box? I wanted to add ARM support to my std.simd work here as a better proof of concept. Iain: was there anything particularly special you needed to do to hook the x86 SSE stuff to GDC which would need to be duplicated for ARM? gcc.builtins doesn't seen to have any ARM intrinsics in there either... --20cf3074b0b279546704b8414900 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On 6 February 2012 02:25, Manu <span dir=3D"ltr"=
&lt;<a href=3D"mailto:turkeyman gmail.com">turkeyman gmail.com</a>&gt;</sp=

border-left:1px #ccc solid;padding-left:1ex"> <div class=3D"HOEnZb"><div class=3D"h5"><div class=3D"gmail_quote">On 6 Feb= ruary 2012 00:04, Johannes Pfau <span dir=3D"ltr">&lt;<a href=3D"mailto:nos= pam example.com" target=3D"_blank">nospam example.com</a>&gt;</span> wrote:= <br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef= t:1px #ccc solid;padding-left:1ex"> Am Sun, 5 Feb 2012 18:04:12 +0100<br> schrieb Johannes Pfau &lt;<a href=3D"mailto:nospam example.com" target=3D"_= blank">nospam example.com</a>&gt;:<br> <div><br> &gt; I will probably need some more time to get this working...<br> &gt;<br> <br> </div>I have some good news:<br> <a href=3D"http://www.mediafire.com/?107we120sh3xx" target=3D"_blank">http:= //www.mediafire.com/?107we120sh3xx</a><br> <br> I fixed that problem and then the whole build worked fine. I&#39;ll post<br=

simple gdc -c test.d to check the compiler, but it seems to work.<br> <br> Linking against druntime fails, as it uses functions which are not<br> available on Android (backtrace, signal stuff).<br> <br> I also built a simple hello world on linux (printf, no runtime) and ran<br> it on my android phone, and it worked!<br> <br> In case you haven&#39;t used GDC without runtime before, a short<br> introduction:<br> <br> * use gdc -nophoboslib to make gdc not link against phobos (and afaik,<br> =C2=A0druntime)<br> * theres also -nostdlib in case you need it<br> * complex code may require -fno-section-anchors because of bug #120<br> * You&#39;ll get an error about a missing _Dmodule_ref symbol. That symbol<= br> =C2=A0is used by module constructors and not generated by gdc if<br> =C2=A0-nophoboslib was passed. As long as you don&#39;t run the module<br> =C2=A0constructors, you can add a fake _Dmodule_ref in a .c file:<br> <br> ------------<br> void* _Dmodule_ref;<br> ------------<br> <br> * The compiler defines version(Android)<br> <br> Here&#39;s my hello world:<br> ------------<br> version(Android)<br> {<br> =C2=A0 =C2=A0pragma(msg, &quot;Hello Android!&quot;);<br> }<br> <br> extern(C)<br> {<br> =C2=A0 =C2=A0int printf(in char* format, ...);<br> }<br> <br> extern(C) void main()<br> {<br> =C2=A0 =C2=A0printf(&quot;Hello, %s!\n&quot;.ptr, &quot;Android&quot;.ptr)= ;<br> }<br> ------------<br> <br> compile the _Dmodule_ref into hack.o, then use<br> gdc -nophoboslib hello.d hack.o<br> </blockquote></div><br></div></div><div>Amazing! You sir, are a genius!</di= v><div>I&#39;m gonna have to have some fun with that after work tomorrow :)= </div><div><br></div><div>I reckon this binary distro should be put on d-p-= l somewhere obvious.</div> </blockquote></div><br><div>I just tried with -mfpu=3Dneon, which should al= low GCC to generate neon opcodes for the simd stuff, but it didn&#39;t seem= to want to do that. In fact it generates really horrible code where it CAL= LS an intrinsic for each float in the vector...</div> <div>Any idea why this wouldn&#39;t work out of the box?</div><div><br></di= v><div>I wanted to add ARM support to my std.simd work here as a better pro= of of concept.</div><div><br></div><div>Iain: was there anything particular= ly special you needed to do to hook the x86 SSE stuff to GDC which would ne= ed to be duplicated for ARM? gcc.builtins doesn&#39;t seen to have any ARM = intrinsics in there either...</div> --20cf3074b0b279546704b8414900--
Feb 05 2012
prev sibling next sibling parent Johannes Pfau <nospam example.com> writes:
Am Mon, 6 Feb 2012 03:07:31 +0200
schrieb Manu <turkeyman gmail.com>:

 On 6 February 2012 02:25, Manu <turkeyman gmail.com> wrote:
 
 On 6 February 2012 00:04, Johannes Pfau <nospam example.com> wrote:

 Am Sun, 5 Feb 2012 18:04:12 +0100
 schrieb Johannes Pfau <nospam example.com>:

 I will probably need some more time to get this working...

I have some good news: http://www.mediafire.com/?107we120sh3xx I fixed that problem and then the whole build worked fine. I'll post build instructions soon, but the binaries are ready. I only did a simple gdc -c test.d to check the compiler, but it seems to work. Linking against druntime fails, as it uses functions which are not available on Android (backtrace, signal stuff). I also built a simple hello world on linux (printf, no runtime) and ran it on my android phone, and it worked! In case you haven't used GDC without runtime before, a short introduction: * use gdc -nophoboslib to make gdc not link against phobos (and afaik, druntime) * theres also -nostdlib in case you need it * complex code may require -fno-section-anchors because of bug #120 * You'll get an error about a missing _Dmodule_ref symbol. That symbol is used by module constructors and not generated by gdc if -nophoboslib was passed. As long as you don't run the module constructors, you can add a fake _Dmodule_ref in a .c file: ------------ void* _Dmodule_ref; ------------ * The compiler defines version(Android) Here's my hello world: ------------ version(Android) { pragma(msg, "Hello Android!"); } extern(C) { int printf(in char* format, ...); } extern(C) void main() { printf("Hello, %s!\n".ptr, "Android".ptr); } ------------ compile the _Dmodule_ref into hack.o, then use gdc -nophoboslib hello.d hack.o

Amazing! You sir, are a genius! I'm gonna have to have some fun with that after work tomorrow :) I reckon this binary distro should be put on d-p-l somewhere obvious.

I just tried with -mfpu=neon, which should allow GCC to generate neon opcodes for the simd stuff, but it didn't seem to want to do that. In fact it generates really horrible code where it CALLS an intrinsic for each float in the vector... Any idea why this wouldn't work out of the box?

The android toolchain configures gcc with: += --with-float=soft --with-fpu=vfp --with-arch=armv5te I could try to build an optimized build, but then you'll have to tell me what processor you're using. Cortex A8? I'm not sure if you can override that at runtime. You could probably try: -mfloat-abi=hard -mcpu=cortex-a8 -march=armv7-a -mfpu=neon
 I wanted to add ARM support to my std.simd work here as a better
 proof of concept.
 
 Iain: was there anything particularly special you needed to do to
 hook the x86 SSE stuff to GDC which would need to be duplicated for
 ARM? gcc.builtins doesn't seen to have any ARM intrinsics in there
 either...
 

Feb 05 2012
prev sibling next sibling parent Andrew Wiley <wiley.andrew.j gmail.com> writes:
On Mon, Feb 6, 2012 at 1:40 AM, Johannes Pfau <nospam example.com> wrote:
 Am Mon, 6 Feb 2012 03:07:31 +0200
 schrieb Manu <turkeyman gmail.com>:

 On 6 February 2012 02:25, Manu <turkeyman gmail.com> wrote:

 On 6 February 2012 00:04, Johannes Pfau <nospam example.com> wrote:

 Am Sun, 5 Feb 2012 18:04:12 +0100
 schrieb Johannes Pfau <nospam example.com>:

 I will probably need some more time to get this working...

I have some good news: http://www.mediafire.com/?107we120sh3xx I fixed that problem and then the whole build worked fine. I'll post build instructions soon, but the binaries are ready. I only did a simple gdc -c test.d to check the compiler, but it seems to work. Linking against druntime fails, as it uses functions which are not available on Android (backtrace, signal stuff). I also built a simple hello world on linux (printf, no runtime) and ran it on my android phone, and it worked! In case you haven't used GDC without runtime before, a short introduction: * use gdc -nophoboslib to make gdc not link against phobos (and afaik, druntime) * theres also -nostdlib in case you need it * complex code may require -fno-section-anchors because of bug #120 * You'll get an error about a missing _Dmodule_ref symbol. That symbol is used by module constructors and not generated by gdc if =A0-nophoboslib was passed. As long as you don't run the module =A0constructors, you can add a fake _Dmodule_ref in a .c file: ------------ void* _Dmodule_ref; ------------ * The compiler defines version(Android) Here's my hello world: ------------ version(Android) { =A0 =A0pragma(msg, "Hello Android!"); } extern(C) { =A0 =A0int printf(in char* format, ...); } extern(C) void main() { =A0 =A0printf("Hello, %s!\n".ptr, "Android".ptr); } ------------ compile the _Dmodule_ref into hack.o, then use gdc -nophoboslib hello.d hack.o

Amazing! You sir, are a genius! I'm gonna have to have some fun with that after work tomorrow :) I reckon this binary distro should be put on d-p-l somewhere obvious.

I just tried with -mfpu=3Dneon, which should allow GCC to generate neon opcodes for the simd stuff, but it didn't seem to want to do that. In fact it generates really horrible code where it CALLS an intrinsic for each float in the vector... Any idea why this wouldn't work out of the box?

The android toolchain configures gcc with: +=3D --with-float=3Dsoft --with-fpu=3Dvfp --with-arch=3Darmv5te I could try to build an optimized build, but then you'll have to tell me what processor you're using. Cortex A8? I'm not sure if you can override that at runtime. You could probably try: -mfloat-abi=3Dhard -mcpu=3Dcortex-a8 -march=3Darmv7-a -mfpu=3Dneon

Actually, if the Android default is to build against softfloat ABI, you may be stuck with it. If Android doesn't require hardfloat to run and doesn't let developers provide multiple binaries for different platforms (which it might - I don't know), things get very hard. Also, with NEON, one of the things you don't really hear until you start working with these is that NEON isn't actually required in most if not all of the ARM CPU specs. I've specifically dealt with the Tegra 2, which is used in a lot of phones and has no NEON support even though it's ARM Cortex-A9.
Feb 05 2012
prev sibling next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
On 6 February 2012 01:07, Manu <turkeyman gmail.com> wrote:
 On 6 February 2012 02:25, Manu <turkeyman gmail.com> wrote:
 On 6 February 2012 00:04, Johannes Pfau <nospam example.com> wrote:
 Am Sun, 5 Feb 2012 18:04:12 +0100
 schrieb Johannes Pfau <nospam example.com>:

 I will probably need some more time to get this working...

I have some good news: http://www.mediafire.com/?107we120sh3xx I fixed that problem and then the whole build worked fine. I'll post build instructions soon, but the binaries are ready. I only did a simple gdc -c test.d to check the compiler, but it seems to work. Linking against druntime fails, as it uses functions which are not available on Android (backtrace, signal stuff). I also built a simple hello world on linux (printf, no runtime) and ran it on my android phone, and it worked! In case you haven't used GDC without runtime before, a short introduction: * use gdc -nophoboslib to make gdc not link against phobos (and afaik, =A0druntime) * theres also -nostdlib in case you need it * complex code may require -fno-section-anchors because of bug #120 * You'll get an error about a missing _Dmodule_ref symbol. That symbol =A0is used by module constructors and not generated by gdc if =A0-nophoboslib was passed. As long as you don't run the module =A0constructors, you can add a fake _Dmodule_ref in a .c file: ------------ void* _Dmodule_ref; ------------ * The compiler defines version(Android) Here's my hello world: ------------ version(Android) { =A0 =A0pragma(msg, "Hello Android!"); } extern(C) { =A0 =A0int printf(in char* format, ...); } extern(C) void main() { =A0 =A0printf("Hello, %s!\n".ptr, "Android".ptr); } ------------ compile the _Dmodule_ref into hack.o, then use gdc -nophoboslib hello.d hack.o

Amazing! You sir, are a genius! I'm gonna have to have some fun with that after work tomorrow :) I reckon this binary distro should be put on d-p-l somewhere obvious.

I just tried with -mfpu=3Dneon, which should allow GCC to generate neon opcodes for the simd stuff, but it didn't seem to want to do that. In fac=

 it generates really horrible code where it CALLS an intrinsic for each fl=

 in the vector...
 Any idea why this wouldn't work out of the box?

 I wanted to add ARM support to my std.simd work here as a better proof of
 concept.

 Iain: was there anything particularly special you needed to do to hook th=

 x86 SSE stuff to GDC which would need to be duplicated for ARM? gcc.built=

 doesn't seen to have any ARM intrinsics in there either...

Nope - its all arch agnostic. Just requires that: a) The target you are building for has the functions available b) The functions in question can be represented using D types. --=20 Iain Buclaw *(p < e ? p++ : p) =3D (c & 0x0f) + '0';
Feb 06 2012
prev sibling next sibling parent Johannes Pfau <nospam example.com> writes:
Am Mon, 6 Feb 2012 01:48:32 -0600
schrieb Andrew Wiley <wiley.andrew.j gmail.com>:

 
 Actually, if the Android default is to build against softfloat ABI,
 you may be stuck with it. If Android doesn't require hardfloat to run
 and doesn't let developers provide multiple binaries for different
 platforms (which it might - I don't know), things get very hard.
 
 Also, with NEON, one of the things you don't really hear until you
 start working with these is that NEON isn't actually required in most
 if not all of the ARM CPU specs. I've specifically dealt with the
 Tegra 2, which is used in a lot of phones and has no NEON support even
 though it's ARM Cortex-A9.

There's a official armv7-a ABI for android, it doesn't use 'hard', but at least 'softfp' instead of 'soft'. Just found the relevant documentation: See android-ndk-r7/docs/STANDALONE-TOOLCHAIN.html 4/ ABI Compatibility: ------------------------ If you want to target the 'armeabi-v7a' ABI, you will need ensure that the following two flags are being used: CFLAGS='-march=armv7-a -mfloat-abi=softfp' If you want to use Neon instructions, you will need one more compiler flag: CFLAGS='-march=armv7-a -mfloat-abi=softfp -mfpu=neon' Also, is is *required* to use the following linker flags that routes around a CPU bug in some Cortex-A8 implementations: LDFLAGS='-Wl,--fix-cortex-a8' ------------------------ so according to those docs, you simply pass those flags to the compiler, no need to recompile the compiler.
Feb 06 2012
prev sibling next sibling parent Andrew Wiley <wiley.andrew.j gmail.com> writes:
On Mon, Feb 6, 2012 at 1:40 AM, Johannes Pfau <nospam example.com> wrote:
 Am Mon, 6 Feb 2012 03:07:31 +0200
 schrieb Manu <turkeyman gmail.com>:

 On 6 February 2012 02:25, Manu <turkeyman gmail.com> wrote:

 On 6 February 2012 00:04, Johannes Pfau <nospam example.com> wrote:

 Am Sun, 5 Feb 2012 18:04:12 +0100
 schrieb Johannes Pfau <nospam example.com>:

 I will probably need some more time to get this working...

I have some good news: http://www.mediafire.com/?107we120sh3xx I fixed that problem and then the whole build worked fine. I'll post build instructions soon, but the binaries are ready. I only did a simple gdc -c test.d to check the compiler, but it seems to work. Linking against druntime fails, as it uses functions which are not available on Android (backtrace, signal stuff). I also built a simple hello world on linux (printf, no runtime) and ran it on my android phone, and it worked! In case you haven't used GDC without runtime before, a short introduction: * use gdc -nophoboslib to make gdc not link against phobos (and afaik, druntime) * theres also -nostdlib in case you need it * complex code may require -fno-section-anchors because of bug #120 * You'll get an error about a missing _Dmodule_ref symbol. That symbol is used by module constructors and not generated by gdc if =A0-nophoboslib was passed. As long as you don't run the module =A0constructors, you can add a fake _Dmodule_ref in a .c file: ------------ void* _Dmodule_ref; ------------ * The compiler defines version(Android) Here's my hello world: ------------ version(Android) { =A0 =A0pragma(msg, "Hello Android!"); } extern(C) { =A0 =A0int printf(in char* format, ...); } extern(C) void main() { =A0 =A0printf("Hello, %s!\n".ptr, "Android".ptr); } ------------ compile the _Dmodule_ref into hack.o, then use gdc -nophoboslib hello.d hack.o

Amazing! You sir, are a genius! I'm gonna have to have some fun with that after work tomorrow :) I reckon this binary distro should be put on d-p-l somewhere obvious.

I just tried with -mfpu=3Dneon, which should allow GCC to generate neon opcodes for the simd stuff, but it didn't seem to want to do that. In fact it generates really horrible code where it CALLS an intrinsic for each float in the vector... Any idea why this wouldn't work out of the box?

The android toolchain configures gcc with: +=3D --with-float=3Dsoft --with-fpu=3Dvfp --with-arch=3Darmv5te I could try to build an optimized build, but then you'll have to tell me what processor you're using. Cortex A8? I'm not sure if you can override that at runtime. You could probably try: -mfloat-abi=3Dhard -mcpu=3Dcortex-a8 -march=3Darmv7-a -mfpu=3Dneon

I'm pretty sure you have to rebuild the entire toolchain to switch from softfloat to hardfloat.
Feb 05 2012
prev sibling next sibling parent Johannes Pfau <nospam example.com> writes:
Am Mon, 6 Feb 2012 01:42:26 -0600
schrieb Andrew Wiley <wiley.andrew.j gmail.com>:

 
 I'm pretty sure you have to rebuild the entire toolchain to switch
 from softfloat to hardfloat.

I also thought that, but GCC docs say: -with-fpu=type --with-float=type These configure options provide **default** values for the -mschedule=, -march=, -mtune=, -mabi=, and -mfpu= options and for -mhard-float or -msoft-float. As with --with-cpu, which switches will be accepted and acceptable values of the arguments depend on the target. That also matches the Android NDK documentation.
Feb 06 2012
prev sibling next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
On 6 February 2012 08:11, Johannes Pfau <nospam example.com> wrote:
 Am Mon, 6 Feb 2012 01:48:32 -0600
 schrieb Andrew Wiley <wiley.andrew.j gmail.com>:

 Actually, if the Android default is to build against softfloat ABI,
 you may be stuck with it. If Android doesn't require hardfloat to run
 and doesn't let developers provide multiple binaries for different
 platforms (which it might - I don't know), things get very hard.

 Also, with NEON, one of the things you don't really hear until you
 start working with these is that NEON isn't actually required in most
 if not all of the ARM CPU specs. I've specifically dealt with the
 Tegra 2, which is used in a lot of phones and has no NEON support even
 though it's ARM Cortex-A9.

There's a official armv7-a ABI for android, it doesn't use 'hard', but at least 'softfp' instead of 'soft'. Just found the relevant documentation: See android-ndk-r7/docs/STANDALONE-TOOLCHAIN.html 4/ ABI Compatibility: ------------------------ If you want to target the 'armeabi-v7a' ABI, you will need ensure that the following two flags are being used: =A0CFLAGS=3D'-march=3Darmv7-a -mfloat-abi=3Dsoftfp' If you want to use Neon instructions, you will need one more compiler flag: =A0CFLAGS=3D'-march=3Darmv7-a -mfloat-abi=3Dsoftfp -mfpu=3Dneon' Also, is is *required* to use the following linker flags that routes around a CPU bug in some Cortex-A8 implementations: =A0LDFLAGS=3D'-Wl,--fix-cortex-a8' ------------------------ so according to those docs, you simply pass those flags to the compiler, no need to recompile the compiler.

From the ARM Neon Intrinisics page:

"These built-in intrinsics for the ARM Advanced SIMD extension are available when the -mfpu=3Dneon switch is used." --=20 Iain Buclaw *(p < e ? p++ : p) =3D (c & 0x0f) + '0';
Feb 06 2012
prev sibling next sibling parent Manu <turkeyman gmail.com> writes:
--20cf300faaf10ee30b04b8480ba5
Content-Type: text/plain; charset=UTF-8

On 6 February 2012 09:40, Johannes Pfau <nospam example.com> wrote:

 Am Mon, 6 Feb 2012 03:07:31 +0200
 schrieb Manu <turkeyman gmail.com>:

 On 6 February 2012 02:25, Manu <turkeyman gmail.com> wrote:

 On 6 February 2012 00:04, Johannes Pfau <nospam example.com> wrote:

 Am Sun, 5 Feb 2012 18:04:12 +0100
 schrieb Johannes Pfau <nospam example.com>:

 I will probably need some more time to get this working...

I have some good news: http://www.mediafire.com/?107we120sh3xx I fixed that problem and then the whole build worked fine. I'll post build instructions soon, but the binaries are ready. I only did a simple gdc -c test.d to check the compiler, but it seems to work. Linking against druntime fails, as it uses functions which are not available on Android (backtrace, signal stuff). I also built a simple hello world on linux (printf, no runtime) and ran it on my android phone, and it worked! In case you haven't used GDC without runtime before, a short introduction: * use gdc -nophoboslib to make gdc not link against phobos (and afaik, druntime) * theres also -nostdlib in case you need it * complex code may require -fno-section-anchors because of bug #120 * You'll get an error about a missing _Dmodule_ref symbol. That symbol is used by module constructors and not generated by gdc if -nophoboslib was passed. As long as you don't run the module constructors, you can add a fake _Dmodule_ref in a .c file: ------------ void* _Dmodule_ref; ------------ * The compiler defines version(Android) Here's my hello world: ------------ version(Android) { pragma(msg, "Hello Android!"); } extern(C) { int printf(in char* format, ...); } extern(C) void main() { printf("Hello, %s!\n".ptr, "Android".ptr); } ------------ compile the _Dmodule_ref into hack.o, then use gdc -nophoboslib hello.d hack.o

Amazing! You sir, are a genius! I'm gonna have to have some fun with that after work tomorrow :) I reckon this binary distro should be put on d-p-l somewhere obvious.

I just tried with -mfpu=neon, which should allow GCC to generate neon opcodes for the simd stuff, but it didn't seem to want to do that. In fact it generates really horrible code where it CALLS an intrinsic for each float in the vector... Any idea why this wouldn't work out of the box?

The android toolchain configures gcc with: += --with-float=soft --with-fpu=vfp --with-arch=armv5te I could try to build an optimized build, but then you'll have to tell me what processor you're using. Cortex A8? I'm not sure if you can override that at runtime. You could probably try: -mfloat-abi=hard -mcpu=cortex-a8 -march=armv7-a -mfpu=neon

That's interesting. I seem to recall in a recent NDK noticing that they had changed to armv7 by default... but looking at the R6 NDK, it looks like it's configured basically identical to your toolchain. I must just be missing a whole function of compile options, but I can't see any option in the standard build scripts to enable hardware fpu :/ The options I see that are supplied are: -ffast-math -mfloat-abi=softfp -march=armv7-a I imagine all android 2+ devices have at least armv7's with a hardware fpu... Interesting that NEON is not supported on all hardware. Annoying to do runtime detection to take advantage of stuff like that >_<
 I wanted to add ARM support to my std.simd work here as a better
 proof of concept.

 Iain: was there anything particularly special you needed to do to
 hook the x86 SSE stuff to GDC which would need to be duplicated for
 ARM? gcc.builtins doesn't seen to have any ARM intrinsics in there
 either...


--20cf300faaf10ee30b04b8480ba5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On 6 February 2012 09:40, Johannes Pfau <span di= r=3D"ltr">&lt;<a href=3D"mailto:nospam example.com" target=3D"_blank">nospa= m example.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" st= yle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Am Mon, 6 Feb 2012 03:07:31 +0200<br> schrieb Manu &lt;<a href=3D"mailto:turkeyman gmail.com" target=3D"_blank">t= urkeyman gmail.com</a>&gt;:<br> <div><br> &gt; On 6 February 2012 02:25, Manu &lt;<a href=3D"mailto:turkeyman gmail.c= om" target=3D"_blank">turkeyman gmail.com</a>&gt; wrote:<br> &gt;<br> </div><div><div>&gt; &gt; On 6 February 2012 00:04, Johannes Pfau &lt;<a hr= ef=3D"mailto:nospam example.com" target=3D"_blank">nospam example.com</a>&g= t; wrote:<br> &gt; &gt;<br> &gt; &gt;&gt; Am Sun, 5 Feb 2012 18:04:12 +0100<br> &gt; &gt;&gt; schrieb Johannes Pfau &lt;<a href=3D"mailto:nospam example.co= m" target=3D"_blank">nospam example.com</a>&gt;:<br> &gt; &gt;&gt;<br> &gt; &gt;&gt; &gt; I will probably need some more time to get this working.= ..<br> &gt; &gt;&gt; &gt;<br> &gt; &gt;&gt;<br> &gt; &gt;&gt; I have some good news:<br> &gt; &gt;&gt; <a href=3D"http://www.mediafire.com/?107we120sh3xx" target=3D= "_blank">http://www.mediafire.com/?107we120sh3xx</a><br> &gt; &gt;&gt;<br> &gt; &gt;&gt; I fixed that problem and then the whole build worked fine. I&= #39;ll<br> &gt; &gt;&gt; post build instructions soon, but the binaries are ready. I o= nly<br> &gt; &gt;&gt; did a simple gdc -c test.d to check the compiler, but it seem= s to<br> &gt; &gt;&gt; work.<br> &gt; &gt;&gt;<br> &gt; &gt;&gt; Linking against druntime fails, as it uses functions which ar= e not<br> &gt; &gt;&gt; available on Android (backtrace, signal stuff).<br> &gt; &gt;&gt;<br> &gt; &gt;&gt; I also built a simple hello world on linux (printf, no runtim= e)<br> &gt; &gt;&gt; and ran it on my android phone, and it worked!<br> &gt; &gt;&gt;<br> &gt; &gt;&gt; In case you haven&#39;t used GDC without runtime before, a sh= ort<br> &gt; &gt;&gt; introduction:<br> &gt; &gt;&gt;<br> &gt; &gt;&gt; * use gdc -nophoboslib to make gdc not link against phobos (a= nd<br> &gt; &gt;&gt; afaik, druntime)<br> &gt; &gt;&gt; * theres also -nostdlib in case you need it<br> &gt; &gt;&gt; * complex code may require -fno-section-anchors because of bu= g #120<br> &gt; &gt;&gt; * You&#39;ll get an error about a missing _Dmodule_ref symbol= . That<br> &gt; &gt;&gt; symbol is used by module constructors and not generated by gd= c if<br> &gt; &gt;&gt; =C2=A0-nophoboslib was passed. As long as you don&#39;t run t= he module<br> &gt; &gt;&gt; =C2=A0constructors, you can add a fake _Dmodule_ref in a .c f= ile:<br> &gt; &gt;&gt;<br> &gt; &gt;&gt; ------------<br> &gt; &gt;&gt; void* _Dmodule_ref;<br> &gt; &gt;&gt; ------------<br> &gt; &gt;&gt;<br> &gt; &gt;&gt; * The compiler defines version(Android)<br> &gt; &gt;&gt;<br> &gt; &gt;&gt; Here&#39;s my hello world:<br> &gt; &gt;&gt; ------------<br> &gt; &gt;&gt; version(Android)<br> &gt; &gt;&gt; {<br> &gt; &gt;&gt; =C2=A0 =C2=A0pragma(msg, &quot;Hello Android!&quot;);<br> &gt; &gt;&gt; }<br> &gt; &gt;&gt;<br> &gt; &gt;&gt; extern(C)<br> &gt; &gt;&gt; {<br> &gt; &gt;&gt; =C2=A0 =C2=A0int printf(in char* format, ...);<br> &gt; &gt;&gt; }<br> &gt; &gt;&gt;<br> &gt; &gt;&gt; extern(C) void main()<br> &gt; &gt;&gt; {<br> &gt; &gt;&gt; =C2=A0 =C2=A0printf(&quot;Hello, %s!\n&quot;.ptr, &quot;Andro= id&quot;.ptr);<br> &gt; &gt;&gt; }<br> &gt; &gt;&gt; ------------<br> &gt; &gt;&gt;<br> &gt; &gt;&gt; compile the _Dmodule_ref into hack.o, then use<br> &gt; &gt;&gt; gdc -nophoboslib hello.d hack.o<br> &gt; &gt;&gt;<br> &gt; &gt;<br> &gt; &gt; Amazing! You sir, are a genius!<br> &gt; &gt; I&#39;m gonna have to have some fun with that after work tomorrow= :)<br> &gt; &gt;<br> &gt; &gt; I reckon this binary distro should be put on d-p-l somewhere<br> &gt; &gt; obvious.<br> &gt; &gt;<br> &gt;<br> </div></div><div>&gt; I just tried with -mfpu=3Dneon, which should allow GC= C to generate neon<br> &gt; opcodes for the simd stuff, but it didn&#39;t seem to want to do that.= In<br> &gt; fact it generates really horrible code where it CALLS an intrinsic<br> &gt; for each float in the vector...<br> &gt; Any idea why this wouldn&#39;t work out of the box?<br> <br> </div>The android toolchain configures gcc with: +=3D --with-float=3Dsoft<b= r> --with-fpu=3Dvfp --with-arch=3Darmv5te<br> <br> I could try to build an optimized build, but then you&#39;ll have to tell<b= r> me what processor you&#39;re using. Cortex A8?<br> <br> I&#39;m not sure if you can override that at runtime. You could probably<br=

-mfloat-abi=3Dhard -mcpu=3Dcortex-a8 -march=3Darmv7-a -mfpu=3Dneon<br></blo= ckquote><div><br></div><div>That&#39;s interesting. I seem to recall in a r= ecent NDK noticing that they had changed to armv7 by default... but looking= at=C2=A0the R6 NDK, it looks like it&#39;s configured basically identical = to your toolchain.</div> <div>I must just be missing a whole function of compile options, but I can&= #39;t see any option in the standard build scripts to enable hardware fpu := /</div><div>The options I see that are supplied are:=C2=A0-ffast-math -mflo= at-abi=3Dsoftfp -march=3Darmv7-a</div> <div><br></div><div>I imagine all android 2+ devices have at least armv7&#3= 9;s with a hardware fpu...</div><div><br></div><div>Interesting that NEON i= s not supported on all hardware. Annoying to do runtime detection to take a= dvantage of stuff like that &gt;_&lt;</div> <div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8= ex;border-left:1px #ccc solid;padding-left:1ex"> <div><div>&gt; I wanted to add ARM support to my std.simd work here as a be= tter<br> &gt; proof of concept.<br> &gt;<br> &gt; Iain: was there anything particularly special you needed to do to<br> &gt; hook the x86 SSE stuff to GDC which would need to be duplicated for<br=

<br> &gt; either...<br> &gt;<br> <br> </div></div></blockquote></div><br> --20cf300faaf10ee30b04b8480ba5--
Feb 06 2012
prev sibling parent Manu <turkeyman gmail.com> writes:
--20cf3074b0b2e63ddc04b84816e7
Content-Type: text/plain; charset=UTF-8

On 6 February 2012 10:11, Johannes Pfau <nospam example.com> wrote:

 Am Mon, 6 Feb 2012 01:48:32 -0600
 schrieb Andrew Wiley <wiley.andrew.j gmail.com>:

 Actually, if the Android default is to build against softfloat ABI,
 you may be stuck with it. If Android doesn't require hardfloat to run
 and doesn't let developers provide multiple binaries for different
 platforms (which it might - I don't know), things get very hard.

 Also, with NEON, one of the things you don't really hear until you
 start working with these is that NEON isn't actually required in most
 if not all of the ARM CPU specs. I've specifically dealt with the
 Tegra 2, which is used in a lot of phones and has no NEON support even
 though it's ARM Cortex-A9.

There's a official armv7-a ABI for android, it doesn't use 'hard', but at least 'softfp' instead of 'soft'. Just found the relevant documentation: See android-ndk-r7/docs/STANDALONE-TOOLCHAIN.html 4/ ABI Compatibility: ------------------------ If you want to target the 'armeabi-v7a' ABI, you will need ensure that the following two flags are being used: CFLAGS='-march=armv7-a -mfloat-abi=softfp' If you want to use Neon instructions, you will need one more compiler flag: CFLAGS='-march=armv7-a -mfloat-abi=softfp -mfpu=neon' Also, is is *required* to use the following linker flags that routes around a CPU bug in some Cortex-A8 implementations: LDFLAGS='-Wl,--fix-cortex-a8' ------------------------ so according to those docs, you simply pass those flags to the compiler, no need to recompile the compiler.

Sorry, missed this one. Did spot those flags in the build scripts, so yeah, just missed them last night >_< Sorry about that. I'll try again this evening and see how it looks. --20cf3074b0b2e63ddc04b84816e7 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On 6 February 2012 10:11, Johannes Pfau <span di= r=3D"ltr">&lt;<a href=3D"mailto:nospam example.com">nospam example.com</a>&= gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 = 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Am Mon, 6 Feb 2012 01:48:32 -0600<br> schrieb Andrew Wiley &lt;<a href=3D"mailto:wiley.andrew.j gmail.com">wiley.= andrew.j gmail.com</a>&gt;:<br> <div class=3D"im"><br> &gt;<br> &gt; Actually, if the Android default is to build against softfloat ABI,<br=

run<br> &gt; and doesn&#39;t let developers provide multiple binaries for different= <br> &gt; platforms (which it might - I don&#39;t know), things get very hard.<b= r> &gt;<br> &gt; Also, with NEON, one of the things you don&#39;t really hear until you= <br> &gt; start working with these is that NEON isn&#39;t actually required in m= ost<br> &gt; if not all of the ARM CPU specs. I&#39;ve specifically dealt with the<= br> &gt; Tegra 2, which is used in a lot of phones and has no NEON support even= <br> &gt; though it&#39;s ARM Cortex-A9.<br> <br> </div>There&#39;s a official armv7-a ABI for android, it doesn&#39;t use &#= 39;hard&#39;, but<br> at least &#39;softfp&#39; instead of &#39;soft&#39;.<br> <br> Just found the relevant documentation: See<br> android-ndk-r7/docs/STANDALONE-TOOLCHAIN.html 4/ ABI Compatibility:<br> ------------------------<br> If you want to target the &#39;armeabi-v7a&#39; ABI, you will need ensure t= hat<br> the following two flags are being used:<br> <br> =C2=A0CFLAGS=3D&#39;-march=3Darmv7-a -mfloat-abi=3Dsoftfp&#39;<br> <br> If you want to use Neon instructions, you will need one more compiler<br> flag:<br> <br> =C2=A0CFLAGS=3D&#39;-march=3Darmv7-a -mfloat-abi=3Dsoftfp -mfpu=3Dneon&#39= ;<br> <br> Also, is is *required* to use the following linker flags that routes<br> around a CPU bug in some Cortex-A8 implementations:<br> <br> =C2=A0LDFLAGS=3D&#39;-Wl,--fix-cortex-a8&#39;<br> ------------------------<br> so according to those docs, you simply pass those flags to the<br> compiler, no need to recompile the compiler.<br> </blockquote></div><br><div>Sorry, missed this one. Did spot those flags in= the build scripts, so yeah, just missed them last night &gt;_&lt;</div><di= v>Sorry about that. I&#39;ll try again this evening and see how it looks.</= div> --20cf3074b0b2e63ddc04b84816e7--
Feb 06 2012