Jump to page: 1 2 3
Thread overview
[Tutorial][Binaries] gdc for android
Feb 04, 2012
Johannes Pfau
Feb 04, 2012
Nick Sabalausky
Feb 04, 2012
Iain Buclaw
Feb 04, 2012
Johannes Pfau
Feb 05, 2012
Manu
Feb 05, 2012
Johannes Pfau
Feb 05, 2012
Johannes Pfau
Feb 05, 2012
maarten van damme
Feb 06, 2012
Manu
Feb 06, 2012
Manu
Feb 06, 2012
Johannes Pfau
Feb 06, 2012
Andrew Wiley
Feb 06, 2012
Johannes Pfau
Feb 06, 2012
Iain Buclaw
Feb 06, 2012
Manu
Feb 06, 2012
Andrew Wiley
Feb 06, 2012
Johannes Pfau
Feb 06, 2012
Manu
Feb 06, 2012
Iain Buclaw
Feb 05, 2012
Sönke Ludwig
Feb 05, 2012
Johannes Pfau
February 04, 2012
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.
February 04, 2012
"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.


February 04, 2012
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-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.
>
>
> 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. :þ

-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';
February 04, 2012
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-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.
> >
> >
> > 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. :þ
> 

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 ;-)

February 05, 2012
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
> > >>
> 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.
> > >
> > >
> > > 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. :þ
> >
>
> 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


February 05, 2012
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.
February 05, 2012
Am Sun, 05 Feb 2012 12:21:43 +0100
schrieb Sönke 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.

February 05, 2012
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:
> 
> > 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-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.
> > > >
> > > >
> > > > 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. :þ
> > >
> >
> > 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
> 

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...

February 05, 2012
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
February 05, 2012
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
« First   ‹ Prev
1 2 3