[Vm-dev] Compiling Cog on FreeBSD

Frank Shearar frank.shearar at gmail.com
Thu Jan 31 21:21:14 UTC 2013


Ah, my build script is broken! It tries to find the Cog source and,
because the cleanup is insufficiently aggressive, then thinks that the
2664 is what it should build!

Thanks, Eliot!

frank

On 31 January 2013 21:11, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> Hi Frank,
>
> On Thu, Jan 31, 2013 at 1:06 PM, Frank Shearar <frank.shearar at gmail.com>
> wrote:
>>
>> Hi Eliot,
>>
>> What can I do to help with this? Did making that custom sqUnixMemory.c
>> give you enough info to solve the issue, or do you need me to write
>> that test program?
>
>
> I already integrated the relevant change, moving pageSize and pageMask
> outside of HAVE_MMAP.  So you should be able to build from the Cog sources
> directly.  Apologies for not giving feedback.
>
> cheers!
>>
>>
>> frank
>>
>> On 13 January 2013 13:25, Frank Shearar <frank.shearar at gmail.com> wrote:
>> > Hi Eliot,
>> >
>> > Given that the custom sqUnixMemory.c compiled successfully on FreeBSD,
>> > do you have sufficient information to fix the issue, or do you still
>> > need me to write a test program for mprotect?
>> >
>> > frank
>> >
>> > On 11 January 2013 18:18, Eliot Miranda <eliot.miranda at gmail.com> wrote:
>> >> Hi Frank,
>> >>
>> >>     from configure's output can you tell if does mprotect work?  If
>> >> not,
>> >> could you write a test program to test mprotect?  I expect something
>> >> like
>> >> the attached is appropriate.  Let me know.
>> >>
>> >>
>> >> On Fri, Jan 11, 2013 at 3:29 AM, Frank Shearar
>> >> <frank.shearar at gmail.com>
>> >> wrote:
>> >>>
>> >>>
>> >>> OK, the -E version of the source looks like this:
>> >>>
>> >>> void
>> >>> sqMakeMemoryExecutableFromTo(unsigned long startAddr, unsigned long
>> >>> endAddr)
>> >>> {
>> >>>  unsigned long firstPage = ((startAddr)&pageMask);
>> >>>  if (mprotect((void *)firstPage,
>> >>>      endAddr - firstPage + 1,
>> >>>      PROT_READ | PROT_WRITE | PROT_EXEC) < 0)
>> >>>   perror("mprotect(x,y,PROT_READ | PROT_WRITE | PROT_EXEC)");
>> >>> }
>> >>>
>> >>> but now I see no definition for pageMask! grepping just shows this:
>> >>>
>> >>> $ grep pageMask foo.i
>> >>>  unsigned long firstPage = ((startAddr)&pageMask);
>> >>>  unsigned long firstPage = ((startAddr)&pageMask);
>> >>>
>> >>> which is the problem. So I think I don't HAVE_MMAP defined. And if I
>> >>> look very carefully at configure's output, I see this:
>> >>>
>> >>> checking for working mmap... Segmentation fault
>> >>> no
>> >>>
>> >>> frank
>> >>>
>> >>> On 10 January 2013 23:59, Eliot Miranda <eliot.miranda at gmail.com>
>> >>> wrote:
>> >>> >
>> >>> > Hi Frank,
>> >>> >
>> >>> >     preprocess it using -P or -E and see what you get.  i.e. run the
>> >>> > compiler with all the same flags (except -c and/or -o) but suppling
>> >>> > either
>> >>> > -E or -P (if -P pipe the result into foo.i).  Then you can see what
>> >>> > source
>> >>> > the compiler is actually compiling.  Then grep for pageMask in the
>> >>> > result.
>> >>> > Let's see what mangling is actually happening.
>> >>> >
>> >>> > HTH
>> >>> >
>> >>> >
>> >>> > On Thu, Jan 10, 2013 at 2:21 PM, Frank Shearar
>> >>> > <frank.shearar at gmail.com>
>> >>> > wrote:
>> >>> >>
>> >>> >>
>> >>> >> I didn't express myself properly. pageMask occurs in a #define
>> >>> >> (line
>> >>> >> 293), but its definition is on line 100. But what confuses me is
>> >>> >> that
>> >>> >> since it's outside the function definition, it should surely be
>> >>> >> visible in the function. But the error I get says that on line 298,
>> >>> >> "error: 'pageMask' undeclared (first use in this function)".
>> >>> >>
>> >>> >> frank
>> >>> >>
>> >>> >> On 10 January 2013 21:43, Eliot Miranda <eliot.miranda at gmail.com>
>> >>> >> wrote:
>> >>> >> >
>> >>> >> > Hi Frank,
>> >>> >> >
>> >>> >> >     where's the #define of pageMask?  There shouldn't be one
>> >>> >> > pageMask is an unsigned int.  i.e.
>> >>> >> >
>> >>> >> > McStalker.oscogvm$ grep -n pageMask platforms/unix/vm/*
>> >>> >> > platforms/unix/vm/sqUnixMemory.c:100:static unsigned int pageMask
>> >>> >> > =
>> >>> >> > 0;
>> >>> >> > platforms/unix/vm/sqUnixMemory.c:102:#define valign(x)  ((x) &
>> >>> >> > pageMask)
>> >>> >> > platforms/unix/vm/sqUnixMemory.c:123:  pageMask= ~(pageSize - 1);
>> >>> >> > platforms/unix/vm/sqUnixMemory.c:125:
>> >>> >> > DPRINTF(("uxAllocateMemory:
>> >>> >> > pageSize 0x%x (%d), mask 0x%x\n", pageSize, pageSize, pageMask));
>> >>> >> > platforms/unix/vm/sqUnixMemory.c:178:      assert(0 == (newDelta
>> >>> >> > &
>> >>> >> > ~pageMask));
>> >>> >> > platforms/unix/vm/sqUnixMemory.c:179:      assert(0 == (newSize
>> >>> >> > &
>> >>> >> > ~pageMask));
>> >>> >> > platforms/unix/vm/sqUnixMemory.c:196:     assert(0 == (heapSize
>> >>> >> > &
>> >>> >> > ~pageMask));
>> >>> >> > platforms/unix/vm/sqUnixMemory.c:213:      assert(0 == (newDelta
>> >>> >> > &
>> >>> >> > ~pageMask));
>> >>> >> > platforms/unix/vm/sqUnixMemory.c:214:      assert(0 == (newSize
>> >>> >> > &
>> >>> >> > ~pageMask));
>> >>> >> > platforms/unix/vm/sqUnixMemory.c:231:     assert(0 == (heapSize
>> >>> >> > &
>> >>> >> > ~pageMask));
>> >>> >> > platforms/unix/vm/sqUnixMemory.c:293:# define
>> >>> >> > roundDownToPageBoundary(v) ((v)&pageMask)
>> >>> >> > platforms/unix/vm/sqUnixMemory.c:294:# define
>> >>> >> > roundUpToPageBoundary(v) (((v)+pageSize-1)&pageMask)
>> >>> >> >
>> >>> >> >
>> >>> >> > On Thu, Jan 10, 2013 at 1:40 PM, Frank Shearar
>> >>> >> > <frank.shearar at gmail.com> wrote:
>> >>> >> >>
>> >>> >> >>
>> >>> >> >> First, thanks Eliot for fixing up the UUID plugin.
>> >>> >> >>
>> >>> >> >> With that fixed, the next error I get when compiling (32 bit) on
>> >>> >> >> FreeBSD is this:
>> >>> >> >>
>> >>> >> >> sqUnixMemory.c
>> >>> >> >>
>> >>> >> >>
>> >>> >> >> /usr/home/jenkins/workspace/CogVM-FreeBSD/target/Squeak-vm-unix-4.6.0-Cog-2664-unofficial-src/platforms/unix/vm/sqUnixMemory.c:
>> >>> >> >> In function 'sqMakeMemoryExecutableFromTo':
>> >>> >> >>
>> >>> >> >>
>> >>> >> >> /usr/home/jenkins/workspace/CogVM-FreeBSD/target/Squeak-vm-unix-4.6.0-Cog-2664-unofficial-src/platforms/unix/vm/sqUnixMemory.c:298:
>> >>> >> >> error: 'pageMask' undeclared (first use in this function)
>> >>> >> >>
>> >>> >> >> The line number looks a bit wrong, because pageMask is in a
>> >>> >> >> #define
>> >>> >> >> on
>> >>> >> >> line 293. (Ah, it's because line 298 uses the #define.) At any
>> >>> >> >> rate,
>> >>> >> >> the relevant function + context looks like this:
>> >>> >> >>
>> >>> >> >> #if COGVM
>> >>> >> >> # define roundDownToPageBoundary(v) ((v)&pageMask)
>> >>> >> >> # define roundUpToPageBoundary(v) (((v)+pageSize-1)&pageMask)
>> >>> >> >> void
>> >>> >> >> sqMakeMemoryExecutableFromTo(unsigned long startAddr, unsigned
>> >>> >> >> long
>> >>> >> >> endAddr)
>> >>> >> >> {
>> >>> >> >>         unsigned long firstPage =
>> >>> >> >> roundDownToPageBoundary(startAddr);
>> >>> >> >>         if (mprotect((void *)firstPage,
>> >>> >> >>                                  endAddr - firstPage + 1,
>> >>> >> >>                                  PROT_READ | PROT_WRITE |
>> >>> >> >> PROT_EXEC)
>> >>> >> >> < 0)
>> >>> >> >>                 perror("mprotect(x,y,PROT_READ | PROT_WRITE |
>> >>> >> >> PROT_EXEC)");
>> >>> >> >> }
>> >>> >> >>
>> >>> >> >> void
>> >>> >> >> sqMakeMemoryNotExecutableFromTo(unsigned long startAddr,
>> >>> >> >> unsigned
>> >>> >> >> long endAddr)
>> >>> >> >> {
>> >>> >> >>         unsigned long firstPage =
>> >>> >> >> roundDownToPageBoundary(startAddr);
>> >>> >> >>         if (mprotect((void *)firstPage,
>> >>> >> >>                                  endAddr - firstPage + 1,
>> >>> >> >>                                  PROT_READ | PROT_WRITE) < 0)
>> >>> >> >>                 perror("mprotect(x,y,PROT_READ | PROT_WRITE)");
>> >>> >> >> }
>> >>> >> >> #endif /* COGVM */
>> >>> >> >>
>> >>> >> >> A bit confusing, given that pageMask is declared on line 100, as
>> >>> >> >> whatever C calls a top level form. A global?
>> >>> >> >>
>> >>> >> >> What can I do to make things work?
>> >>> >> >>
>> >>> >> >> The full ouput's viewable here:
>> >>> >> >> http://squeakci.org/job/CogVM-FreeBSD/13/console
>> >>> >> >>
>> >>> >> >> frank
>> >>> >> >
>> >>> >> >
>> >>> >> >
>> >>> >> >
>> >>> >> > --
>> >>> >> > best,
>> >>> >> > Eliot
>> >>> >> >
>> >>> >
>> >>> >
>> >>> >
>> >>> >
>> >>> > --
>> >>> > best,
>> >>> > Eliot
>> >>> >
>> >>
>> >>
>> >>
>> >>
>> >> --
>> >> best,
>> >> Eliot
>
>
>
>
> --
> best,
> Eliot


More information about the Vm-dev mailing list