www.digitalmars.com         C & C++   DMDScript  

D.gnu - arm-wince D crosscompiler on the way, request help with mmap

reply Chad J <""gamerChad\" spamIsBad gmail.com"> writes:
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I've been working on a cross compiler that runs in linux and compiles D 
code for Windows CE/Windows Mobile on the Arm/Xscale processor.  I have 
a working C/C++ cross compiler that I configured myself, and I am 
currently building one with D included.

I've also run into a problem that I feel would be best handled by asking 
for help here.  While the xcompiler is building, it gets to the point 
where it checks for the C standard mmap function.  mmap does not exist. 
  Then the make fails.  I looked at phobos, and it seems like mmap isn't 
entirely essential because most of the code can use equivelant Windows 
calls, which are available in WinCE.  One exception to that seems to be 
in phobos/internal/gc/gcgcc.d, where the alternative to "version 
(GC_Use_Alloc_MMap)" has //TODO written in it and no code to show.  I 
suppose there could be more if I haven't looked in enough files.

This who thing raises a few questions for me:
- When checks result in "no", why do some cause errors and failure while 
others do not?  Is it that only the things absolutely essential to D's 
functioning will throw errors in the make process?
- If mmap is not needed or I modify phobos to fix this, how do I get the 
configure script/makefile to adjust to this?
- If I modify gdc's phobos (count on it), should I submit my changes 
somewhere?  If so, how do I go about that?
- Is this thing even compiling (or going to compile) phobos as a Windows 
version, or is it doing something unfortunate for me like assuming the 
target is linux?

It might also be nice if someone with more knowledge of this stuff would 
handle the lack of an alternative to mmap in that gcgcc.d file, if it's 
necessary.  I will probably try to do it myself pretty soon, but I may 
get it wrong.

OK so now some possibly helpful info...

This is the configure I used:
sh /root/gcc/gdc-3.3.3/configure \
   --prefix=/usr/local/arm-wince-pe \
   --disable-nls \
   --disable-shared \
   --enable-multilib=no \
   --enable-languages=c,d,c++ \
   --with-build-time-tools=/usr/local/arm-wince-pe/bin \
   --with-as=/usr/local/arm-wince-pe/bin/arm-wince-pe-as \
   --with-ld=/usr/local/arm-wince-pe/bin/arm-wince-pe-ld \
   --with-sysroot=/usr/local/arm-wince-pe \
   --enable-phobos-config-dir=/usr/local/arm-wince-pe/phobos-config \
   --target=arm-wince-pe

Stuff that make printed out, as well as the libphobos config.log are 
attached.
Apr 23 2006
parent reply Sean Kelly <sean f4.ca> writes:
Chad J > wrote:
 I've been working on a cross compiler that runs in linux and compiles D 
 code for Windows CE/Windows Mobile on the Arm/Xscale processor.  I have 
 a working C/C++ cross compiler that I configured myself, and I am 
 currently building one with D included.
 
 I've also run into a problem that I feel would be best handled by asking 
 for help here.  While the xcompiler is building, it gets to the point 
 where it checks for the C standard mmap function.  mmap does not exist. 

mmap isn't a standard C function, it's a POSIX function. Slight difference, but important.
  Then the make fails.  I looked at phobos, and it seems like mmap isn't 
 entirely essential because most of the code can use equivelant Windows 
 calls, which are available in WinCE.  One exception to that seems to be 
 in phobos/internal/gc/gcgcc.d, where the alternative to "version 
 (GC_Use_Alloc_MMap)" has //TODO written in it and no code to show.  I 
 suppose there could be more if I haven't looked in enough files.

It sounds like you're using the GDC Phobos library--the DMD version doesn't have that file. If you're targeting WinCE, the compiled code will probably be linking to the DMD Phobos. It has all the necessary Windows calls in place. Alternately, you may simply have to move some DMD Phobos code into GDC or compile a slightly different set of object files. If it's any help, the GC files needed for Windows are: gc.obj gcbits.obj gcx.obj win32.obj gcstats.obj is required as well, but that should build as a part of phobos/std. Sean
Apr 23 2006
next sibling parent kris <foo bar.com> writes:
Sean Kelly wrote:
 Chad J > wrote:
 
 I've been working on a cross compiler that runs in linux and compiles 
 D code for Windows CE/Windows Mobile on the Arm/Xscale processor.  I 
 have a working C/C++ cross compiler that I configured myself, and I am 
 currently building one with D included.

 I've also run into a problem that I feel would be best handled by 
 asking for help here.  While the xcompiler is building, it gets to the 
 point where it checks for the C standard mmap function.  mmap does not 
 exist. 

mmap isn't a standard C function, it's a POSIX function. Slight difference, but important.
  Then the make fails.  I looked at phobos, and it seems like mmap 
 isn't entirely essential because most of the code can use equivelant 
 Windows calls, which are available in WinCE.  One exception to that 
 seems to be in phobos/internal/gc/gcgcc.d, where the alternative to 
 "version (GC_Use_Alloc_MMap)" has //TODO written in it and no code to 
 show.  I suppose there could be more if I haven't looked in enough files.

It sounds like you're using the GDC Phobos library--the DMD version doesn't have that file. If you're targeting WinCE, the compiled code will probably be linking to the DMD Phobos. It has all the necessary Windows calls in place. Alternately, you may simply have to move some DMD Phobos code into GDC or compile a slightly different set of object files. If it's any help, the GC files needed for Windows are: gc.obj gcbits.obj gcx.obj win32.obj gcstats.obj is required as well, but that should build as a part of phobos/std.

PocketPC compiler? That's great to hear! To make it easier on yourself, you might try to use Ares instead of Phobos? It's much smaller, much more concise, and Sean is very repsonsive in resolving any problem or question. http://dsource.org/projects/ares 2 Cents
Apr 23 2006
prev sibling parent reply Chad J <""gamerChad\" spamIsBad gmail.com"> writes:
Sean Kelly wrote:
 
 mmap isn't a standard C function, it's a POSIX function.  Slight 
 difference, but important.
 

Ah, good to know.
 
 
 It sounds like you're using the GDC Phobos library--the DMD version 
 doesn't have that file.  If you're targeting WinCE, the compiled code 
 will probably be linking to the DMD Phobos.  It has all the necessary 
 Windows calls in place.  Alternately, you may simply have to move some 
 DMD Phobos code into GDC or compile a slightly different set of object 
 files.  If it's any help, the GC files needed for Windows are:
 
     gc.obj
     gcbits.obj
     gcx.obj
     win32.obj
 
 gcstats.obj is required as well, but that should build as a part of 
 phobos/std.
 
 
 Sean

Interesting. I'd like to try that. One problem still remains though, how do I suppress the checking of functions like mmap so that I can build phobos and install the compiler? It also makes me wonder why exactly there is a different version of phobos for GDC.
Apr 23 2006
parent reply Chad J <""gamerChad\" spamIsBad gmail.com"> writes:
Chad J > wrote:
 
 One problem still remains though, 
 how do I suppress the checking of functions like mmap so that I can 
 build phobos and install the compiler?
 

Nevermind the suppression of checking, I figured that out. I ran into another issue, probably also related to the configure scripts. I managed to get it to start compiling phobos by commenting out some stuff in the d/phobos/configure script, and also had to add a case for the fragment files (it would only take premade frag- files from mingw... I had to change that). At that point I noticed that $target_os was set to "pe". I'm not sure, but that looks like it could cause issues. When I got phobos to start compiling, it ran into some errors, namely missing definitions for wchar_t in std/c/process.d. I noticed that those definitions were OS dependant. So I plopped the following into the std/c/process.d file: version( Win32 ) { pragma(msg, "OS version is Win32"); } else version( Windows ) { pragma(msg, "OS version is Windows"); } else version( linux ) { pragma(msg, "OS version is linux"); } else version( Unix ) { pragma(msg, "OS version is Unix"); } else { pragma(msg, "OS version is unknown!"); } Please let me know if I missed an important version. I ran make again, and surely enough it printed out "OS version is unknown!". I'd imagine not knowing what the OS is would kill a phobos build very fast. I also wonder if this problem is caused by what $target_os was set to in the configure script. I just looked and I don't see a GCC configure switch that lets me specify what the name of the OS is, and to do that so globally might be a bad idea anyways. So that leaves me with another question, how would I go about setting the reserved version identifiers for the D compiler? At some point I'll probably look through the configure scripts some more, but I find those things really difficult to follow at times, so it'd help if I at least knew where to look.
Apr 23 2006
next sibling parent Chad J <""gamerChad\" spamIsBad gmail.com"> writes:
I have an update on this:

I managed to get version(Win32) to work by adding a case in 
d/target-ver-syms.sh for "pe".  While I was at it I noticed the target 
cpu list, and add in a case for "arm" that makes version(ARM) work.

version(Windows) is still broken though.
Apr 25 2006
prev sibling parent Chad J <""gamerChad\" spamIsBad gmail.com"> writes:
I have an update on this:

I managed to get version(Win32) to work by adding a case in
d/target-ver-syms.sh for "pe".  While I was at it I noticed the target
cpu list, and add in a case for "arm" that makes version(ARM) work.

version(Windows) is still broken though.

edit:  I managed to get version(Windows) to work as well.
Apr 25 2006