[Tutorial][Binaries] gdc for android

maarten van damme maartenvd1994 at gmail.com
Sun Feb 5 15:01:07 PST 2012


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ønne Petersen <xtzgzorex at 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 at example.com>:
>>
>>  I will probably need some more time to get this working...
>>>
>>>
>> I have some good news:
>> http://www.mediafire.com/?**107we120sh3xx<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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/d.gnu/attachments/20120206/f2d7992b/attachment.html>


More information about the D.gnu mailing list