Adrian's blog; last part

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Adrian's blog; last part

Chris Cunnington
I made it right down to the last "make" at the end of section four, when an error popped up. This is the last thing to make it work, so any insight into solving this last part would be greatly appreciated. I did use a 4.1 Squeak image for my VMMaker and such. But I can't figure that's what's making the error. It's in "gnu-interp.c", I think.

Chris

[ 76%] Built target SurfacePlugin
Scanning dependencies of target AioPlugin
[ 77%] Building C object AioPlugin/CMakeFiles/AioPlugin.dir/Users/chriscunnington/Desktop/vmbuilding/platforms/unix/src/vm/intplugins/AioPlugin/AioPlugin.c.o
Linking C static library libAioPlugin.a
[ 77%] Built target AioPlugin
[ 77%] Generating version.c
[ 78%] Generating gnu-interp.c
Scanning dependencies of target squeakvm
[ 79%] Building C object CMakeFiles/squeakvm.dir/gnu-interp.c.o
/Users/chriscunnington/Desktop/vmbuilding/platforms/build_new/gnu-interp.c:673: error: conflicting types for ‘readImageFromFileHeapSizeStartingAt’
/Users/chriscunnington/Desktop/vmbuilding/platforms/Cross/vm/sq.h:349: error: previous declaration of ‘readImageFromFileHeapSizeStartingAt’ was here
/Users/chriscunnington/Desktop/vmbuilding/platforms/build_new/gnu-interp.c:22711: error: conflicting types for ‘readImageFromFileHeapSizeStartingAt’
/Users/chriscunnington/Desktop/vmbuilding/platforms/Cross/vm/sq.h:349: error: previous declaration of ‘readImageFromFileHeapSizeStartingAt’ was here
make[2]: *** [CMakeFiles/squeakvm.dir/gnu-interp.c.o] Error 1
make[1]: *** [CMakeFiles/squeakvm.dir/all] Error 2
make: *** [all] Error 2

_______________________________________________
VM-beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners
Reply | Threaded
Open this post in threaded view
|

Re: Adrian's blog; last part

johnmci
readImageFromFileHeapSizeStartingAt 
is defined/was defined/could be defined/who knows? differently in the thrunk svn versus what cog has/did have/might have. 

I'd suggest comparing the source in the trunk svn tree /platform/iOS/vm/src/vm/interp.c 
to understand the trunk expectations of readImageFromFileHeapSizeStartingAt and the definition in sq.h, then look at what you have 
I believe 

sqInt readImageFromFileHeapSizeStartingAt(sqImageFile f, usqInt desiredHeapSize, squeakFileOffsetType imageOffset);

is the correct flavor to address issues with 64bit computers and the like, although Cog doesn't support 64bit compiles the API was altered to ensure you could pass a desired heap size > 2GB... without the number going negative... 

since the OLD definition likely looked like this and desiredHeapSize being a signed evil entity would flipout the world when it went over 2GB and slid into a negative world...

sqInt readImageFromFileHeapSizeStartingAt(sqImageFile  f, sqInt desiredHeapSize, squeakFileOffsetType  imageOffset);



On 2010-12-08, at 12:21 PM, Chris Cunnington wrote:

I made it right down to the last "make" at the end of section four, when an error popped up. This is the last thing to make it work, so any insight into solving this last part would be greatly appreciated. I did use a 4.1 Squeak image for my VMMaker and such. But I can't figure that's what's making the error. It's in "gnu-interp.c", I think.

Chris

[ 76%] Built target SurfacePlugin
Scanning dependencies of target AioPlugin
[ 77%] Building C object AioPlugin/CMakeFiles/AioPlugin.dir/Users/chriscunnington/Desktop/vmbuilding/platforms/unix/src/vm/intplugins/AioPlugin/AioPlugin.c.o
Linking C static library libAioPlugin.a
[ 77%] Built target AioPlugin
[ 77%] Generating version.c
[ 78%] Generating gnu-interp.c
Scanning dependencies of target squeakvm
[ 79%] Building C object CMakeFiles/squeakvm.dir/gnu-interp.c.o
/Users/chriscunnington/Desktop/vmbuilding/platforms/build_new/gnu-interp.c:673: error: conflicting types for ‘readImageFromFileHeapSizeStartingAt’
/Users/chriscunnington/Desktop/vmbuilding/platforms/Cross/vm/sq.h:349: error: previous declaration of ‘readImageFromFileHeapSizeStartingAt’ was here
/Users/chriscunnington/Desktop/vmbuilding/platforms/build_new/gnu-interp.c:22711: error: conflicting types for ‘readImageFromFileHeapSizeStartingAt’
/Users/chriscunnington/Desktop/vmbuilding/platforms/Cross/vm/sq.h:349: error: previous declaration of ‘readImageFromFileHeapSizeStartingAt’ was here
make[2]: *** [CMakeFiles/squeakvm.dir/gnu-interp.c.o] Error 1
make[1]: *** [CMakeFiles/squeakvm.dir/all] Error 2
make: *** [all] Error 2
_______________________________________________
VM-beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners

--
===========================================================================
John M. McIntosh <[hidden email]>   Twitter:  squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================





_______________________________________________
VM-beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners
Reply | Threaded
Open this post in threaded view
|

Re: Adrian's blog; last part

David T. Lewis
In reply to this post by Chris Cunnington
On Wed, Dec 08, 2010 at 03:21:57PM -0500, Chris Cunnington wrote:

> I made it right down to the last "make" at the end of section four, when
> an error popped up. This is the last thing to make it work, so any
> insight into solving this last part would be greatly appreciated. I did
> use a 4.1 Squeak image for my VMMaker and such. But I can't figure
> that's what's making the error. It's in "gnu-interp.c", I think.
>
> Chris
>
> [ 76%] Built target SurfacePlugin
> Scanning dependencies of target AioPlugin
> [ 77%] Building C object
> AioPlugin/CMakeFiles/AioPlugin.dir/Users/chriscunnington/Desktop/vmbuilding/platforms/unix/src/vm/intplugins/AioPlugin/AioPlugin.c.o
> Linking C static library libAioPlugin.a
> [ 77%] Built target AioPlugin
> [ 77%] Generating version.c
> [ 78%] Generating gnu-interp.c
> Scanning dependencies of target squeakvm
> [ 79%] Building C object CMakeFiles/squeakvm.dir/gnu-interp.c.o
> /Users/chriscunnington/Desktop/vmbuilding/platforms/build_new/gnu-interp.c:673:
> error: conflicting types for 'readImageFromFileHeapSizeStartingAt'
> /Users/chriscunnington/Desktop/vmbuilding/platforms/Cross/vm/sq.h:349:
> error: previous declaration of 'readImageFromFileHeapSizeStartingAt' was
> here
> /Users/chriscunnington/Desktop/vmbuilding/platforms/build_new/gnu-interp.c:22711:
> error: conflicting types for 'readImageFromFileHeapSizeStartingAt'
> /Users/chriscunnington/Desktop/vmbuilding/platforms/Cross/vm/sq.h:349:
> error: previous declaration of 'readImageFromFileHeapSizeStartingAt' was
> here
> make[2]: *** [CMakeFiles/squeakvm.dir/gnu-interp.c.o] Error 1
> make[1]: *** [CMakeFiles/squeakvm.dir/all] Error 2
> make: *** [all] Error 2

Hi Chris,

Your compiler is complaining that there is a function in gnu-interp.c
that does not match the function declaration in the header file sq.h.
The sq.h header was included by the gnu-interp.c module, and that is
why the compiler is checking it for you. Of course the compiler is
going to be right about this, but the question is why?

The sq.h header is located at platforms/Cross/vm/sq.h. It contains
declarations that are supposed to be in sync with the VM source
code that is maintained in the VMMaker package, as well as with
the supporting C modules in the platforms directory (stored in
Subversion). Sometimes the code in VMMaker may be out of sync
with the code in platforms because somebody is introducing some
new change or feature, and sometimes (and this is very common) they
it be out of sync because someone is accidentally trying to compile
an old version of VMMaker with a new version of the platforms code
or vice versa. In any case, it is the job of the C compiler to check
this and complain if the declarations do no not match properly,
and that is what is happening here.

On your system, if you open the sq.h file and look at the declaration
for the readImageFromFileHeapSizeStartingAt() function, then open
the gnu-interp.c file and find the readImageFromFileHeapSizeStartingAt()
in that file, I think that you will find that the declarations are
slightly different. Perhaps one will have a "sqInt" where the other
has a "usqInt". This will be the cause of the compiler error, so now
the question is what's wrong?

The declaration in sq.h is part of the platform support code, and
you can pretty safely assume that it is correct as far as the rest of
the platform code is concerned. But it may or may not match up with
the readImageFromFileHeapSizeStartingAt() function in gnu-interp.c,
so where did that come from?

The gnu-interp.c file comes from the interp.c file. It's really
just an optimized version on interp.c that is created when you run
"make". So interp.c is the real source file, and you will find the
readImageFromFileHeapSizeStartingAt() function in interp.c also.

OK, so where does interp.c come from? It looks like a C program
file, and it is, but it really originates as a Smalltalk program.
It comes from the classes ObjectMemory and Interpreter, which
represent the actual Squeak virtual machine. These are Smalltalk
classes that can be run in your Squeak image (with the help of some
support classes) to serve as an actual VM written in and running
inside of Squeak. This is what people are talking about when they
speak of the InterpreterSimulator, which is the real VM running
in Squeak with some assistance from InterpreterSimulator to replace
the functions that would otherwise be implimented in the platform
support code.

Apologies for that slight diversion, and back to the subject;
what is the source of that readImageFromFileHeapSizeStartingAt()
function that the compiler is complaining about? Take a look
at class Interpreter (you need to have VMMaker loaded of course),
and in the "image save/restore" methods you will find the method
#readImageFromFile:HeapSize:StartingAt: that is responsible for
reading an image file. If you run this method in the interpreter
simulator, you will see it open and read an image file to load
the object memory. When it is compiled into the real VM, it
does the same thing, but to do this it must first be translated
into C and compiled into the VM executable.

So here's the trick. The Smalltalk class
Interpreter>>readImageFromFile:HeapSize:StartingAt: needs to be
translated to C, compiled, and linked in with your platform
support code. And in the process the version that you translate
out of the Interpreter needs to match up nicely with the declared
format in sq.h, otherwise your C compiler is going to have words
with you.

The VMMaker package includes the C translator that converts
simple Smalltalk into C (the "simple Smalltalk" is what we call
Slang for short). In the process of doing this conversion, it
takes the method named #readImageFromFile:HeapSize:StartingAt:
and removes the colons, converting it to a C function called
readImageFromFileHeapSizeStartingAt(), and converting the
arguments of the Smalltalk method into parameters for the C
function. Along the way there may be pragma annotations in the
Smalltalk that specify data types for the C declarations in
order to make the pieces fit together.

So there you have it. The Smalltalk method in VMMaker has
some pragma annotations (aka variable declarations) that do
not match the declarations in the sq.h header file. The C
compiler noticed the problem and complained about it.

Now that we understand the problem, but why did it happen?
It is usually one of two things.

1) You are generating your VM source code from some version of
VMMaker (from SqueakSource) that does not match the version of
platforms code (from Subversion).

2) You are not using VMMaker at all, but instead are relying
an old copy of code that somebody else generated from VMMaker.
For example, you might be trying to compile the source in the
platforms/unix/src directory along with the rest of the source
in platforms, but now find that the old code saved in the
platforms/unix/src/ directory no longer matches the more recently
updated code elsewhere in the platforms development tree.

You probably should not read the next paragraph until after
you resolve the above problem and get your first successful
VM build. But save this and read it later:

  I like to encourage people to try opening a VMMaker window
  and play around with it. Start with the "help" button and
  spend a few minutes reading. Then try generating your own
  source code to compile with the latest version of platform
  sources from the Subversion repository. You will have the
  satisfaction of doing it all yourself, and you will not need
  to rely on anybody else to provide you with the "right version"
  of this that or the other. And last but not least, you will
  end up with an up-to-date VM that works and that builds
  without errors.

Good luck and have fun,

Dave
_______________________________________________
VM-beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners