www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Compiling DMD for the iPhone simulator

reply Jacob Carlborg <doob me.com> writes:
I'm trying to compile DMD for the iPhone simulator. I've modified the 
makefile to point to the files (SDK, g++ and so on) in 
<path>/iPhoneSimulator.platform. DMD compiles successfully but when I 
run DMD without any flags it prints:

"read error, errno = 2"

And then the regular usage information. When I try to compile a file it 
says:

	read error, errno = 2
	read error, errno = 2
Error: cannot read file main.d

-- 
/Jacob Carlborg
Apr 25 2012
parent reply Michel Fortin <michel.fortin michelf.com> writes:
On 2012-04-25 20:00:42 +0000, Jacob Carlborg <doob me.com> said:

 I'm trying to compile DMD for the iPhone simulator. I've modified the 
 makefile to point to the files (SDK, g++ and so on) in 
 <path>/iPhoneSimulator.platform. DMD compiles successfully but when I 
 run DMD without any flags it prints:
 
 "read error, errno = 2"
 
 And then the regular usage information. When I try to compile a file it says:
 
 	read error, errno = 2
 	read error, errno = 2
 Error: cannot read file main.d
Are you running it straight from the command line? I suspect libraries in the simulator SDK need the simulator's environment to work, which is a pile of undocumented things. I'm also quite curious about what you're trying to achieve. -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Apr 25 2012
parent reply Jacob Carlborg <doob me.com> writes:
On 2012-04-26 01:51, Michel Fortin wrote:
 On 2012-04-25 20:00:42 +0000, Jacob Carlborg <doob me.com> said:

 I'm trying to compile DMD for the iPhone simulator. I've modified the
 makefile to point to the files (SDK, g++ and so on) in
 <path>/iPhoneSimulator.platform. DMD compiles successfully but when I
 run DMD without any flags it prints:

 "read error, errno = 2"

 And then the regular usage information. When I try to compile a file
 it says:

 read error, errno = 2
 read error, errno = 2
 Error: cannot read file main.d
It turned out to be a problem with DMD. It had declared a type as "unsigned int" instead of "size_t". stat.st_size appears to be 64bit in the iPhone simulator SDK. Then I got a new problem. When I compile druntime it complains about conflicting module names. Somehow it seems the package name disappears.
 Are you running it straight from the command line? I suspect libraries
 in the simulator SDK need the simulator's environment to work, which is
 a pile of undocumented things.
Yes, just as you can, I assume, with the compilers already present in <path>/iPhoneSimulator.platform.
 I'm also quite curious about what you're trying to achieve.
I was planning to try and run a D program in the iPhone simulator. As a first step, I thought it would be much easier then running it on the real device. The simulator runs 32bit code and not ARM. If we eventual can run D program on iOS devices I'm pretty sure we also want to run them on the simulator. Can't hurt to try and see what it takes :) -- /Jacob Carlborg
Apr 25 2012
parent reply Michel Fortin <michel.fortin michelf.com> writes:
On 2012-04-26 06:56:02 +0000, Jacob Carlborg <doob me.com> said:

 It turned out to be a problem with DMD. It had declared a type as 
 "unsigned int" instead of "size_t". stat.st_size appears to be 64bit in 
 the iPhone simulator SDK.
:-)
 Then I got a new problem. When I compile druntime it complains about 
 conflicting module names. Somehow it seems the package name disappears.
:-(
 Are you running it straight from the command line? I suspect libraries
 in the simulator SDK need the simulator's environment to work, which is
 a pile of undocumented things.
Yes, just as you can, I assume, with the compilers already present in <path>/iPhoneSimulator.platform.
You are assuming those compilers linked to the iOS SDK, but they could be "cross compilers" in the sense that the compiler is linked to Mac libraries (just like a normal Mac compiler) but creates executables for the iOS Simulator platform. (Obviously, the ARM ones are true cross compilers.) My suspicion is that you could use the same Mac DMD compiler as long as all the generated code is linked with the iOS SDK. As far as I know, the only ABI difference is that the Objective-C runtime for the simulator is the Modern runtime while the Mac is still using the Legacy runtime for 32-bit. So you can't use the same Objective-C compiler, but beside Objective-C I'd expect all the generated code to be the same.
 I'm also quite curious about what you're trying to achieve.
I was planning to try and run a D program in the iPhone simulator. As a first step, I thought it would be much easier then running it on the real device. The simulator runs 32bit code and not ARM. If we eventual can run D program on iOS devices I'm pretty sure we also want to run them on the simulator. Can't hurt to try and see what it takes :)
Indeed, it's the first logical step. -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Apr 26 2012
parent reply Jacob Carlborg <doob me.com> writes:
On 2012-04-26 12:20, Michel Fortin wrote:

 You are assuming those compilers linked to the iOS SDK, but they could
 be "cross compilers" in the sense that the compiler is linked to Mac
 libraries (just like a normal Mac compiler) but creates executables for
 the iOS Simulator platform. (Obviously, the ARM ones are true cross
 compilers.)
Yes, exactly. I was hoping I could do the same with DMD.
 My suspicion is that you could use the same Mac DMD compiler as long as
 all the generated code is linked with the iOS SDK. As far as I know, the
 only ABI difference is that the Objective-C runtime for the simulator is
 the Modern runtime while the Mac is still using the Legacy runtime for
 32-bit. So you can't use the same Objective-C compiler, but beside
 Objective-C I'd expect all the generated code to be the same.
I assume I would need change DMD to use the gcc located in the iPhone simulator SDK instead of the "regular" one. -- /Jacob Carlborg
Apr 26 2012
parent reply Michel Fortin <michel.fortin michelf.com> writes:
On 2012-04-26 11:40:57 +0000, Jacob Carlborg <doob me.com> said:

 On 2012-04-26 12:20, Michel Fortin wrote:
 
 You are assuming those compilers linked to the iOS SDK, but they could
 be "cross compilers" in the sense that the compiler is linked to Mac
 libraries (just like a normal Mac compiler) but creates executables for
 the iOS Simulator platform. (Obviously, the ARM ones are true cross
 compilers.)
Yes, exactly. I was hoping I could do the same with DMD.
 My suspicion is that you could use the same Mac DMD compiler as long as
 all the generated code is linked with the iOS SDK. As far as I know, the
 only ABI difference is that the Objective-C runtime for the simulator is
 the Modern runtime while the Mac is still using the Legacy runtime for
 32-bit. So you can't use the same Objective-C compiler, but beside
 Objective-C I'd expect all the generated code to be the same.
I assume I would need change DMD to use the gcc located in the iPhone simulator SDK instead of the "regular" one.
That might help. Although I'd suspect that all that's really needed is to specify the simulator's SDK as the system root with a linker flag (--sysroot=<path>) when linking D code. I'd suggest you try that first. -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Apr 26 2012
parent Jacob Carlborg <doob me.com> writes:
On 2012-04-26 15:23, Michel Fortin wrote:

 That might help. Although I'd suspect that all that's really needed is
 to specify the simulator's SDK as the system root with a linker flag
 (--sysroot=<path>) when linking D code. I'd suggest you try that first.
That's a good idea. Unfortunately I haven't managed to compile druntime yet due to the conflict module names. When I manage to get to the linking phase I'll keep this in mind. -- /Jacob Carlborg
Apr 26 2012