# how to recover from missing headers in /usr/include ?



## mecano (Jul 21, 2009)

Hello,
having troubles with some port builds (x11vnc as example, package build runs fine) after upgrading from FressBSD 6.4 to 7.2 (both RELEASE) producing segmentation fault 11 on launch (they build fine, looks like a thread problem, pthread maybe related), I did clean old headers in /usr/include with a

```
find /usr/include/ -mtime +60 | xargs rm -r
```
then did a

```
portupgrade -af
```
I then added missing headers by hand from /usr/src/sys/ (/usr/src/sys/i386/include/ and /usr/src/sys/sys/ when errors popped out. After 3 successfully recover (copying header files from /usr/src/sys/ to /usr/include), I thought that I just could copy all files and did a global copy.

```
cp /usr/src/sys/sys/* /usr/include/
cp /usr/src/sys/i386/* /usr/include/
```
but graphics/libglut still does not want to compile chocking on wchar.h

```
/usr/local/include/X11/Xlib.h:1123: error: expected specifier-qualifier-list before 'wchar_t'
/usr/local/include/X11/Xlib.h:1282: error: expected specifier-qualifier-list before 'wchar_t'
/usr/local/include/X11/Xlib.h:1316: error: expected specifier-qualifier-list before 'wchar_t'
/usr/local/include/X11/Xlib.h:3678: warning: type defaults to 'int' in declaration of 'wchar_t'
/usr/local/include/X11/Xlib.h:3678: error: expected ';', ',' or ')' before '*' token
```
So I guess, it doesn't like the wchar.h I just put in, then I noticed there is a Makefile in /usr/src/include so I 'cd' to it and did a

```
make install
```
now libglut is passing the previous error, butâ€¦ my /usr/include/ should be pretty messy, is there a simple way to recover from this ?

note :
I did add my CPUTYPE in make.conf after the 7.2 upgrade (it was not set previously), rebuilt the kernel and all ports.


----------



## DutchDaemon (Jul 21, 2009)

Did you run _all_ the necessary steps after updating the OS, so including make delete-old, mergemaster, and make delete-old-libs? Sounds like you've compiled stuff against older libs, or mixed old and new libs, confusing applications.


----------



## mecano (Jul 21, 2009)

Yes indeed it looks like, I followed the process from the handbook starting at 24.2.3. After finding out troubles, I did a make delete-olds but no mergemaster, I thought freebsd-update did it because it asked me several times about diff conf files I had to edit/validate by hand.
Maybe I should have been more carefully reading the handbook previous 24.2.3â€¦
What about forcing a system update (just as one can do with ports with portupgrade -f), is it possible ?


----------



## DutchDaemon (Jul 21, 2009)

I didn't realise you used freebsd-update. I was referring to the source-based upgrade procedure. I'll leave it to someone more versed in freebsd-update to come up with a possible fix. In the meantime you could use the procedure in 24.2.4 to see how 'off' your current installation currently is.


----------



## mecano (Jul 21, 2009)

thanks DutchDaemon and sorry I didn't specify I used freebsd-update, I'll try to be more verbose next time. Going to check 24.2.4, thanks again.


----------



## mecano (Jul 21, 2009)

nothing fancy with freebsd-update ids outputâ€¦ just five headers, some known conf files and the whole ssh crewâ€¦ I guess, I'd better cvsup source tree (and previously edit my supfile for sources to match RELENG_7_2) and rebuild world (as in 24.6), then kernel, etc.
This should do the job doesn't it ?


----------



## mecano (Jul 22, 2009)

after cvsup on sources, I now get this while 'make buildworld'


```
cc -c -I /usr/src/gnu/usr.bin/cc/cc_tools/../libiberty -O2 -fno-strict-aliasing -pipe -I. -DIN_GCC -DHAVE_CONFIG_H \
-DPREFIX=\"/usr\" -I/usr/obj/usr/src/gnu/usr.bin/cc/cc_tools/../cc_tools -I/usr/src/gnu/usr.bin/cc/cc_tools/../cc_tools \
-I/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcc -I/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcc/config \
-I/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcclibs/include \
-I/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcclibs/libcpp/include \
-I/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcclibs/libdecnumber -g -DGENERATOR_FILE -DHAVE_CONFIG_H  \
-I/usr/obj/usr/src/tmp/legacy/usr/include -o safe-ctype.o
/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcclibs/libiberty/safe-ctype.c
/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcclibs/libiberty/safe-ctype.c:161: \
error: '_sch_isnvsp' undeclared here (not in a function)
/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcclibs/libiberty/safe-ctype.c:161: \
error: '_sch_iscntrl' undeclared here (not in a function)
/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcclibs/libiberty/safe-ctype.c:162: \
error: '_sch_isspace' undeclared here (not in a function)
/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcclibs/libiberty/safe-ctype.c:162: \
error: '_sch_isblank' undeclared here (not in a function)
/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcclibs/libiberty/safe-ctype.c:162: \
error: '_sch_isvsp' undeclared here (not in a function)
/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcclibs/libiberty/safe-ctype.c:165: \
error: '_sch_isprint' undeclared here (not in a function)
/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcclibs/libiberty/safe-ctype.c:165: \
error: '_sch_ispunct' undeclared here (not in a function)
/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcclibs/libiberty/safe-ctype.c:167: \
error: '_sch_isdigit' undeclared here (not in a function)
/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcclibs/libiberty/safe-ctype.c:167: \
error: '_sch_isxdigit' undeclared here (not in a function)
/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcclibs/libiberty/safe-ctype.c:169: \
error: '_sch_isupper' undeclared here (not in a function)
/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcclibs/libiberty/safe-ctype.c:169: \
error: '_sch_isidst' undeclared here (not in a function)
/usr/src/gnu/usr.bin/cc/cc_tools/../../../../contrib/gcclibs/libiberty/safe-ctype.c:173: \
error: '_sch_islower' undeclared here (not in a function)
*** Error code 1
```

I read several people experiencing the same in freebsd current list (http://www.mailinglistarchive.com/freebsd-current@freebsd.org/msg10161.html). I'm a bit clueless here, any hint? I suspect some faulty previous update (6.2<6.4) on my side.
I tried running cvsup again, make clean in /usr/srcâ€¦


----------



## mecano (Jul 22, 2009)

Maybe the safe-ctype.h in /usr/src/gnu/usr.bin/cc/cc_tools/ is faulty?
I made a

```
diff /usr/src/contrib/binutils/include/safe-ctype.h /usr/src/gnu/usr.bin/cc/cc_tools/safe-ctype.h > safe1.diff
```

and indeed /usr/src/gnu/usr.bin/cc/cc_tools/safe-ctype.h seems to lack some definitions.
outputs : http://pastebin.com/m58c734ad

here is my cvsupfile for info :

```
*default host=cvsup3.fr.FreeBSD.org
*default base=/var/db
*default prefix=/usr
*default release=cvs tag=RELENG_7_2
*default delete use-rel-suffix

src-all
```

(I removed compress option on second attempt, all attempts reported successfull)


----------



## DutchDaemon (Jul 22, 2009)

After a c(v)sup, make sure to remove /usr/obj before trying a new build. 


```
rm -rf /usr/obj && cd /usr/src && make cleandir
```

should give you a clean build environment.


----------



## mecano (Jul 22, 2009)

and here is my /etc/make.conf

```
CPUTYPE?=athlon-tbird
CFLAGS= -O2 -fno-strict-aliasing -pipe 
CXXFLAGS+= -fconserve-space
MAKE_SHELL?=sh
COPTFLAGS= -O -pipe
MTREE_FOLLOWS_SYMLINKS= -L

PRINTERDEVICE= ascii
BOOTWAIT=0
DOC_LANG=       en_US.ISO8859-1


PPP_NO_NAT=true         # do not build with NAT support (see make.conf(5))
PPP_NO_NETGRAPH=true    # do not build with Netgraph support
PPP_NO_RADIUS=true      # do not build with RADIUS support
PPP_NO_SUID=true

# added by use.perl 2009-07-21 13:16:33
PERL_VERSION=5.10.0
```


----------



## mecano (Jul 22, 2009)

DutchDaemon said:
			
		

> After a c(v)sup, make sure to remove /usr/obj before trying a new build.
> 
> 
> ```
> ...



thanks will try it right now !


----------



## mecano (Jul 22, 2009)

ahah ! now it stops at 

```
/usr/src/gnu/usr.bin/cc/cc_int/insn-modes.c:311: error: 'V1DImode' undeclared here (not in a function)
/usr/src/gnu/usr.bin/cc/cc_int/insn-modes.c:318: error: 'V8DImode' undeclared here (not in a function)
/usr/src/gnu/usr.bin/cc/cc_int/insn-modes.c:324: error: 'V16SFmode' undeclared here (not in a function)
/usr/src/gnu/usr.bin/cc/cc_int/insn-modes.c:325: error: 'V8DFmode' undeclared here (not in a function)
/usr/src/gnu/usr.bin/cc/cc_int/insn-modes.c:508: error: conflicting types for 'real_format_for_mode'
/usr/src/gnu/usr.bin/cc/cc_int/../../../../contrib/gcc/real.h:165: error: previous declaration of 'real_format_for_mode' was here
*** Error code 1
```


----------



## mecano (Jul 22, 2009)

V* machmode.def defs are missing from /usr/obj/usr/src/gnu/usr.bin/cc/cc_tools/insn-modes.h, only V* config/i386/i386-modes.def defs are in.
Could it be, somewhere something is not catching the CPUTYPE?=athlon-tbird and stick to i386 only? So /usr/obj/usr/src/gnu/usr.bin/cc/cc_tools/insn-modes.h was created without taking CPUTYPE in account while building cc is picking it hence the error?
Or is it that the CPU is not a thunderbird? I'll have a look with cpuid!


----------



## mecano (Jul 22, 2009)

OMG! I got a Palomino (ok a A4 one but still)! Yepee! cpuid rulez!
Sorry for the noise folks and remember kids:
"Always check with cpuid before putting anything as CPUTYPE in /etc/make.conf"


----------

