bison and m4 with uclibs linuxthreads (new): error: field '_sp' has incomplete type

Rob Landley rob at landley.net
Sun Oct 31 20:53:36 UTC 2010


On Tuesday 26 October 2010 01:51:29 Khem Raj wrote:
> On (23/10/10 14:57), Rob Landley wrote:
> > On Tuesday 30 March 2010 06:11:44 Michael Deutschmann wrote:
> > > On Tue, 30 Mar 2010, Natanael Copa wrote:
> > > > and with m4-1.4.14 i get this:
> > > >
> > > > In file included from pipe.c:48:
> > > > ./spawn.h:112: error: field '_sp' has incomplete type
> > > > make[3]: *** [pipe.o] Error 1
> > >
> > > This sounds like a problem I've had on my own system, which is
> > > threadless.  So linuxthreads has nothing to do with it.
> > >
> > > My local patch to m4, supressing the bug, is appended.  The comment
> > > next to the conditional I've spiked makes it clear what is going on.
> > > Apparently, glibc's headers expose the full definition of "struct
> > > sched_param" in cases not required by the standard, and gnulib attempts
> > > to optimize based on this. uClibc does not share glibc's behavior in
> > > this one case, but since it defines __GLIBC__, gnulib sees no need for
> > > caution.
> >
> > That's not actually the problem, although your workaround does work.  (So
> > does using struct __sched_param instead of struct sched_param for the _sp
> > definition in the struct.)
> >
> > But the actual problem is that uClibc hasn't got posix_spawn(), thus no
> >
> > /usr/include/spawn.h.  In m4's lib/spawn.in.h:
> > >#if @REPLACE_POSIX_SPAWN@ || !@HAVE_POSIX_SPAWNATTR_T@
> > >typedef struct
> > >{
> > >  short int _flags;
> > >  pid_t _pgrp;
> > >  sigset_t _sd;
> > >  sigset_t _ss;
> > >  struct sched_param _sp;
> > >  int _policy;
> > >  int __pad[16];
> > >} posix_spawnattr_t;
> > >#endif
> >
> > ./configure sets HAVE_POSIX_SPAWNATTR_T to 1 for glibc, 0 for uClibc.  So
> > this chunk of code doesn't get sucked in for glibc (#if 0 || !1) because
> > because the struct is defined in /usr/include/spawn.h.  For uClibc (#if 0
> > || !0) it gets sucked in, but never gets triggered due to the if #
> > __GLIBC__ (making it work for BSD).
> >
> > So the fix is either:
> >
> > 1) Don't claim to be glibc.
> > 2) Provide posix_spawn() so it doesn't try to replace it.
> > 3) Patch multiple upstream packages that have copied code from each
> > other. 4) export CFLAGS=-Dsched_param=__sched_param
> > 5) Tweak our bits/sched.h to always provide sched_param when it provides
> > __sched_param, which is what the upstream packages seem to expect.
> >
> > I went with #5, using the attached patch to uClibc.
>
> you should investigate why __need_schedparam is not defined in this case.

You should phrase your requiests for more information as questions, rather 
than as orders telling a volunteer what they must spend more of their free 
time doing.  I replied to a message that's been otherwise ignored for six 
months to let other people know I had a fix that Works For Me, and rather than 
you following up on it yourself you told me to do more work.

If you had bothered to spend 30 seconds doing the minimal check on a uClibc 
install:

  $ cd /usr/include
  $ find . -type f | xargs grep need_schedparam
  ./bits/pthreadtypes.h:#define __need_schedparam
  ./bits/sched.h:#ifndef __need_schedparam
  ./bits/sched.h:    && (defined __need_schedparam || defined _SCHED_H)
  ./bits/sched.h:# undef __need_schedparam

You would have noticed that #including pthreadtypes.h is the only thing that 
ever defines the symbol.  The bits/sched.h header is also #included from 
sched.h at the top level, but it does not define that symbol.  So code that 
includes <sched.h> doesn't get this, only code that #includes pthreads does.

More to the point, _when_ I dug down into it I found out (and explained in the 
above email) that this codepath only triggers when we _haven't_ got 
posix_spawn(), and as far as I can tell it wouldn't work in glibc either but 
since they do have posix_spawn() it doesn't come up.

I also note that this is a vestigial symbol we inherited from glibc, and in 
semi-current glibc as far as I can tell it's never set by anything anymore.  
From my crufty old ubuntu 9.04 laptop:

  $ grep -r __need_schedparam /usr/include
  /usr/include/bits/sched.h:#ifndef __need_schedparam
  /usr/include/bits/sched.h:    && (defined __need_schedparam || defined
    _SCHED_H)
  /usr/include/bits/sched.h:# undef __need_schedparam

This is because glibc went to nptl, which hasn't got bits/pthreadtypes.h so 
the only #define for it the headers ever had no longer exists, but the only 
test for that symbol that isn't || something else checks that it is _not_ 
defined.

I.E. giant red herring due to us copying cruft from glibc.

By the way, as long as you're ordering me to do more work, I note that this is 
from 2008:

http://repository.timesys.com/buildsources/u/uClibc/uClibc-0.9.30/uClibc-0.9.30-
unexport_ruserpass.patch

It fixes the fact that building linux from scratch 6.7 under uClibc breaks 
whiel trying to build ftpd, due to a symbol name conflict.  When I checked the 
repository for it last week, we were still exporting this symbol that glibc 
doesn't.  (I bumped into this trying to build LFS under uClibc, and google 
found the fix.)

Rob
-- 
GPLv3: as worthy a successor as The Phantom Menace, as timely as Duke Nukem 
Forever, and as welcome as New Coke.





More information about the uClibc mailing list