D.gnu - iphone + D, getting closer!
- Dan Olson (14/14) Nov 11 2012 Ok, D is not there yet, but I managed to build a crippled gcc-4.8 (with
- Jacob Carlborg (4/16) Nov 11 2012 Cool, I'm really looking forward to this. How did it go with the simulat...
- Dan Olson (12/13) Nov 12 2012 D for the iphone simulator worked without changes to gcc-4.8 src since
- Jacob Carlborg (4/13) Nov 12 2012 Sounds like a great start :)
- Johannes Pfau (7/22) Nov 12 2012 _Dmodule_ref?
- Timo Sintonen (16/31) Nov 12 2012 Module initialization code seems to use _Dmodule_ref to make some
- Dan Olson (7/12) Nov 12 2012 I might try that. It will give me a warm+fuzy before I get all of
- Iain Buclaw (6/20) Nov 12 2012 Doesn't Apple forbid any language except Objective-C ? Or is that a
- Bernard Helyer (3/3) Nov 12 2012 On Monday, 12 November 2012 at 23:45:37 UTC, Iain Buclaw wrote:
- Iain Buclaw (5/8) Nov 13 2012 Far out man. :o)
- Dan Olson (3/5) Nov 12 2012 I think it once was so, but no longer.
- Jacob Carlborg (9/11) Nov 12 2012 We actually do need Objective-D if we're going to run D on iOS.
- Denis V. Shelomovskij (7/10) Nov 16 2012 As XCode natively supports C++ and that MonoTouch gays sells
- Jacob Carlborg (6/8) Nov 16 2012 Xcode has had support for C++ long before iPhone was developed.
Ok, D is not there yet, but I managed to build a crippled gcc-4.8 (with D) targeting arm-apple-darwin and I can compile simple C functions to .o files and link them into an iphone app. And run it on my iphone. The D and C++ compilers built, but I have probably a potpourri of issues since I gave 4.8 a arm-darwin target by selectively copying apple's 4.2 changes for arm-darwin. gcc-4.8 was configured to use tools (as, ld) in the apple iphone SDK. The biggest hassle is that apple's version of arm as is different than binutils as. So I am learning what it wants for debug and pseudo op differences. Even a simple D module with just a extern(C) function depends on something in druntime, so I have to get part of that to build first. -- dano
Nov 11 2012
On 2012-11-12 02:38, Dan Olson wrote:Ok, D is not there yet, but I managed to build a crippled gcc-4.8 (with D) targeting arm-apple-darwin and I can compile simple C functions to .o files and link them into an iphone app. And run it on my iphone. The D and C++ compilers built, but I have probably a potpourri of issues since I gave 4.8 a arm-darwin target by selectively copying apple's 4.2 changes for arm-darwin. gcc-4.8 was configured to use tools (as, ld) in the apple iphone SDK. The biggest hassle is that apple's version of arm as is different than binutils as. So I am learning what it wants for debug and pseudo op differences. Even a simple D module with just a extern(C) function depends on something in druntime, so I have to get part of that to build first.Cool, I'm really looking forward to this. How did it go with the simulator? -- /Jacob Carlborg
Nov 11 2012
Jacob Carlborg <doob me.com> writes:Cool, I'm really looking forward to this. How did it go with the simulator?D for the iphone simulator worked without changes to gcc-4.8 src since it targets i686 darwin fine. To get it to work it was more of finding the right config recipe. I did have to use my druntme changes for osx. For the simulator, I built an i686-apple-darwin target and had it use the iphone simulator sdk + as, ld toolchain. To run D code in the iphone sim, the D code is compiled to .o files on the command line then added to an xcode project along with libgphobos2.a and libgcc_eh.a. I give my D code an extern(C) entry point so I can kick it off. -- dano
Nov 12 2012
On 2012-11-12 16:28, Dan Olson wrote:D for the iphone simulator worked without changes to gcc-4.8 src since it targets i686 darwin fine. To get it to work it was more of finding the right config recipe. I did have to use my druntme changes for osx. For the simulator, I built an i686-apple-darwin target and had it use the iphone simulator sdk + as, ld toolchain. To run D code in the iphone sim, the D code is compiled to .o files on the command line then added to an xcode project along with libgphobos2.a and libgcc_eh.a. I give my D code an extern(C) entry point so I can kick it off.Sounds like a great start :) -- /Jacob Carlborg
Nov 12 2012
Am Sun, 11 Nov 2012 17:38:08 -0800 schrieb Dan Olson <zans.is.for.cans yahoo.com>:Ok, D is not there yet, but I managed to build a crippled gcc-4.8 (with D) targeting arm-apple-darwin and I can compile simple C functions to .o files and link them into an iphone app. And run it on my iphone. The D and C++ compilers built, but I have probably a potpourri of issues since I gave 4.8 a arm-darwin target by selectively copying apple's 4.2 changes for arm-darwin. gcc-4.8 was configured to use tools (as, ld) in the apple iphone SDK. The biggest hassle is that apple's version of arm as is different than binutils as. So I am learning what it wants for debug and pseudo op differences. Even a simple D module with just a extern(C) function depends on something in druntime, so I have to get part of that to build first._Dmodule_ref? You can just declare it as extern(C) __gshared void* _Dmodule_ref; (But IIRC you have to compile with -nophoboslib to make it work) It's used by the runtime/compiler to setup the ModuleInfos but you don't have to initialize it, it just needs to be declared.
Nov 12 2012
On Monday, 12 November 2012 at 08:31:32 UTC, Johannes Pfau wrote:Am Sun, 11 Nov 2012 17:38:08 -0800 schrieb Dan Olson <zans.is.for.cans yahoo.com>:Module initialization code seems to use _Dmodule_ref to make some kind of linked list of module constructors even when we do not have any. I disabled module stuff from d-glue.cc:2828. The only unresolved reference I get now is __aeabi_unwind_cpp_pr1, which is found in libgcc.a. This library may not be searched by default in cross compilers, but has to be given separately. In arm compiler it should be checked in gcc sources that the right library for the target processor is generated (Cortex libraries for example are not generated by default) The file is in one in gcc-source/gcc/config/arm/t-* . If the library is there it has to be checked that the linker finds the right one. Command gcc -print-libgcc-file-name tells the library name and gcc -print-multi-lib tells the available libraries I have now a minimum libdruntime library for arm-eabi. If there are any other unresolved symbols, please let us know.Even a simple D module with just a extern(C) function depends on something in druntime, so I have to get part of that to build first._Dmodule_ref? You can just declare it as extern(C) __gshared void* _Dmodule_ref; (But IIRC you have to compile with -nophoboslib to make it work) It's used by the runtime/compiler to setup the ModuleInfos but you don't have to initialize it, it just needs to be declared.
Nov 12 2012
Johannes Pfau <nospam example.com> writes:_Dmodule_ref? You can just declare it as extern(C) __gshared void* _Dmodule_ref; (But IIRC you have to compile with -nophoboslib to make it work) It's used by the runtime/compiler to setup the ModuleInfos but you don't have to initialize it, it just needs to be declared.I might try that. It will give me a warm+fuzy before I get all of libgdruntime built. It would just be a simple "Hello D" to the console using puts(). My main task now is creating a arm-*-darwin target for libgcc. Last time I worked on gcc for a custom toolchain, libgcc was configured as part of gcc.
Nov 12 2012
Dan Olson <zans.is.for.cans yahoo.com> writes:Johannes Pfau <nospam example.com> writes:Ok, that gave me an arm object file with simple D code. I linked in to an iphone app. When I run, module init code get called (yeah) but soon tries a move from an bad address. Probably my own doing with my port of arm-darwin. I'll look through Timo post, see if it is related. Later this week I will compare my toolchain's D assembler output with a D arm-eabi chain, see what's up._Dmodule_ref? You can just declare it as extern(C) __gshared void* _Dmodule_ref; (But IIRC you have to compile with -nophoboslib to make it work) It's used by the runtime/compiler to setup the ModuleInfos but you don't have to initialize it, it just needs to be declared.I might try that. It will give me a warm+fuzy before I get all of libgdruntime built. It would just be a simple "Hello D" to the console using puts().
Nov 12 2012
Dan Olson <zans.is.for.cans yahoo.com> writes:Dan Olson <zans.is.for.cans yahoo.com> writes:Well, I got some time to work on this again. More progress, although a baby step. D compiled code running in an iphone. Looks like my modified gcc-4.8 -fPIC assembler output is not correct, but it (and PIE) is the default for an iphone toolchain. So for now I turn off PIC and then can compile and execute a simple D module that needs no druntime support or emutls. That's it for now. I include some of the details below if anyone is interested in following this. ncc is an alias to a freshly built xgcc as I work on the gcc build: alias ncc='/Users/dan/projects/gdc/ios-arm-obj/./gcc/xgcc -B/Users/dan/projects/gdc/ios-arm-obj/./gcc/ -B/usr/local/gdc-iosim/arm-apple-darwin/bin/ -B/usr/local/gdc-iosim/arm-apple-darwin/lib/ -isystem /usr/local/gdc-iosim/arm-apple-darwin/include -isystem /usr/local/gdc-iosim/arm-apple-darwin/sys-include --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk' Build a .o (I have some warnings to look at): $ ncc -O2 -fno-pic -I ~/projects/gdc/devnew/libphobos/libdruntime -c dhello.d cc1d: warning: command line option '-fno-builtin-strcat' is valid for C/C++/ObjC/ObjC++ but not for D cc1d: warning: command line option '-fno-builtin-strcpy' is valid for C/C++/ObjC/ObjC++ but not for D cc1d: warning: this target does not support '-fsection-anchors' The linker complains about not being able to use PIE (because I am cheating with -fno-pic). Also, link complains about CPU_SUBTYPE_ARM_ALL subtype is deprecated, so I need to look into that. ---- dhello.d ---- extern (C) { __gshared void* _Dmodule_ref; int puts(const(char) *str); int write(int fd, const(void*) buf, int len); } extern(C) int dhello() { puts("dhello is puts()ing this message"); realDfunc(); return 2012; } // shared, otherwise need emutls shared string s = "A message from a D string\n"; void realDfunc() { // need druntime support //auto m = s ~ "\n"; foreach (c; s) { write(1, &c, 1); } } --- D output from my iphone (on xcode gdb console) ---- dhello is puts()ing this message A message from a D string dhello() returned 2012Johannes Pfau <nospam example.com> writes:Ok, that gave me an arm object file with simple D code. I linked in to an iphone app. When I run, module init code get called (yeah) but soon tries a move from an bad address. Probably my own doing with my port of arm-darwin. I'll look through Timo post, see if it is related. Later this week I will compare my toolchain's D assembler output with a D arm-eabi chain, see what's up._Dmodule_ref? You can just declare it as extern(C) __gshared void* _Dmodule_ref; (But IIRC you have to compile with -nophoboslib to make it work) It's used by the runtime/compiler to setup the ModuleInfos but you don't have to initialize it, it just needs to be declared.I might try that. It will give me a warm+fuzy before I get all of libgdruntime built. It would just be a simple "Hello D" to the console using puts().
Nov 16 2012
On 12 November 2012 01:38, Dan Olson <zans.is.for.cans yahoo.com> wrote:Ok, D is not there yet, but I managed to build a crippled gcc-4.8 (with D) targeting arm-apple-darwin and I can compile simple C functions to .o files and link them into an iphone app. And run it on my iphone. The D and C++ compilers built, but I have probably a potpourri of issues since I gave 4.8 a arm-darwin target by selectively copying apple's 4.2 changes for arm-darwin. gcc-4.8 was configured to use tools (as, ld) in the apple iphone SDK. The biggest hassle is that apple's version of arm as is different than binutils as. So I am learning what it wants for debug and pseudo op differences. Even a simple D module with just a extern(C) function depends on something in druntime, so I have to get part of that to build first. -- danoDoesn't Apple forbid any language except Objective-C ? Or is that a misguided fallacy of mine? (Objective D, anyone? :-) -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
Nov 12 2012
On Monday, 12 November 2012 at 23:45:37 UTC, Iain Buclaw wrote: (Objective D, anyone? :-) Too far man. D:
Nov 12 2012
On 13 November 2012 01:19, Bernard Helyer <b.helyer gmail.com> wrote:On Monday, 12 November 2012 at 23:45:37 UTC, Iain Buclaw wrote: (Objective D, anyone? :-) Too far man. D:Far out man. :o) -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
Nov 13 2012
Iain Buclaw <ibuclaw ubuntu.com> writes:Doesn't Apple forbid any language except Objective-C ? Or is that a misguided fallacy of mine? (Objective D, anyone? :-)I think it once was so, but no longer. http://stackoverflow.com/questions/3949995/what-programming-languages-can-one-use-to-develop-iphone-ipod-touch-and-ipad-i
Nov 12 2012
On 2012-11-13 00:45, Iain Buclaw wrote:Doesn't Apple forbid any language except Objective-C ? Or is that a misguided fallacy of mine? (Objective D, anyone? :-)We actually do need Objective-D if we're going to run D on iOS. Fortunately we already have something, although it's not finished and it's getting old: http://michelf.ca/projects/d-objc This project makes it so much easier to interact with Objective-C. Which is needed on Mac OS X and iOS when you want to have a GUI. -- /Jacob Carlborg
Nov 12 2012
On Monday, 12 November 2012 at 23:45:37 UTC, Iain Buclaw wrote:Doesn't Apple forbid any language except Objective-C ? Or is that a misguided fallacy of mine? (Objective D, anyone? :-)As XCode natively supports C++ and that MonoTouch gays sells Objective-C". -- Денис В. Шеломовский Denis V. Shelomovskij
Nov 16 2012
On 2012-11-16 18:44, Denis V. Shelomovskij wrote:for iOS" fine Apple doesn't "forbid any language except Objective-C".Xcode has had support for C++ long before iPhone was developed. Originally the only allowed C, C++, Objective-C, HTML and JavaScript. Now they've removed that constraint and allows other languages. -- /Jacob Carlborg
Nov 16 2012