Subject: Re: xosview and machine/cpu.h problems
To: Armen Babikyan <synapse@lethargy.mit.edu>
From: Brian C. Grayson <bgrayson@ece.utexas.edu>
List: port-mac68k
Date: 12/30/1997 18:20:41
Armen Babikyan wrote:
> 
> Bill wrote:
> > Brian wrote:
> > > After a bit of digging,
> > > it appears that including /usr/include/sys/sysctl.h in a C file
> > > will pull in /usr/include/machine/pmap.h, which on mac68k pulls
> > > in /usr/include/machine/cpu.h, which contains the following:
> > > 
> > > int     astpending;     /* need to trap before returning to user mode */
> > > int     want_resched;   /* resched() was called */
> > > 
> > >   Two different files (memmeter.cc and pagemeter.cc) in the
> > > xosview-1.5.1 NetBSD tree pull in /usr/include/sys/sysctl.h, so
> > > at link time, the linker sees multiple astpendings and want_rescheds.
> > 
> > Are you sure the error's "multiply defined variables?" I ask as
> > a lot of files in the kernel include machine/cpu.h, and they
> > don't get errors.
> 
> when i tried compiling xosview yesterday, i got errors right at the end
> that looked something to the effect of "multiply defined".

  Here's the output from PR#4731 from Steve Allen:

c++  -L./netbsd -L/usr/X11R6/lib -o xosview llist.o  Host.o 
      xwin.o  Xrm.o  defaultstring.o  meter.o  fieldmeter.o 
      fieldmeterdecay.o  bitmeter.o  xosview.o  main.o -lmeter -lX11 -lkvm
./netbsd/libmeter.a(memmeter.o): Definition of symbol `_astpending' (multiply defined)
./netbsd/libmeter.a(memmeter.o): Definition of symbol `_want_resched' (multiply defined)
./netbsd/libmeter.a(pagemeter.o): Definition of symbol `_astpending' (multiply defined)
./netbsd/libmeter.a(pagemeter.o): Definition of symbol `_want_resched' (multiply defined)
*** Error code 1   

> > It's my understanding that such a reference in a file just adds a
> > reference to the variable, and saying something like astpending=1; in
> > the body of the code would actually allocate the storage. So I
> > think the messages should be "<symbol> referenced from text" or 
> > something like that.

  Under gcc on i386, a file that contains only "int foo;" ends
up looking like the following, according to nm:
00000000 t ___gnu_compiled_c
00000004 C _foo
00000000 t gcc2_compiled.

  So it appears that a declaration is sufficient to cause
allocation?  Or is the mac gcc different?

> > I ask as a lot of files in the kernel include machine/cpu.h, and they
> > don't get errors.                                          

  Hm.  I don't know.  Perhaps something about the particular
sequence of includes in pagemeter.cc is causing something
weird.  Some generation of cpp-output files may be helpful --
compare pagemeter.cpp and <kernel-file>.cpp, and see if there
are any major differences with respect to astpending and
derived macros.  Or an nm on the appropriate kernel object
files may be helpful.  But without a Mac, I don't think I can
be of much further help besides pure speculation!

  Brian
-- 
Brian Grayson (bgrayson@ece.utexas.edu)
Graduate Student, Electrical and Computer Engineering
The University of Texas at Austin
Office:  ENS 406       (512) 471-8011
Finger bgrayson@orac.ece.utexas.edu for PGP key.