# Kernel compile error on 9.1-RELEASE-p4



## hoyanf (Jun 28, 2013)

Hi,

_I e_ncountered _an_ error when trying to compile _a_ custom kernel. I've tried compiling using GENERIC and my custom configuration with different errors. _The s_ource is at revision 252359.

GENERIC

```
cc -c -O2 -frename-registers -pipe -fno-strict-aliasing  -std=c99 -g -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions  -Wmissing-include-dirs -fdiagnostics-show-option   -nostdinc  -I. -I/usr/src/sys -I/usr/src/sys/contrib/altq -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000  -fno-omit-frame-pointer -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fstack-protector -Werror  /usr/src/sys/fs/nfsserver/nfs_nfsdport.c
cc1: warnings being treated as errors
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c: In function 'nfsrv_sattr':
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2313: warning: implicit declaration of function 'NFSGETTIME'
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2313: warning: nested extern declaration of 'NFSGETTIME' [-Wnested-externs]
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c: In function 'nfsv4_sattr':
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2443: warning: passing argument 1 of 'nfsv4_strtouid' from incompatible pointer type
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2443: warning: passing argument 2 of 'nfsv4_strtouid' makes pointer from integer without a cast
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2443: warning: passing argument 3 of 'nfsv4_strtouid' makes integer from pointer without a cast
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2443: warning: passing argument 4 of 'nfsv4_strtouid' from incompatible pointer type
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2443: error: too few arguments to function 'nfsv4_strtouid'
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2469: warning: passing argument 1 of 'nfsv4_strtogid' from incompatible pointer type
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2469: warning: passing argument 2 of 'nfsv4_strtogid' makes pointer from integer without a cast
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2469: warning: passing argument 3 of 'nfsv4_strtogid' makes integer from pointer without a cast
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2469: warning: passing argument 4 of 'nfsv4_strtogid' from incompatible pointer type
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2469: error: too few arguments to function 'nfsv4_strtogid'
*** [nfs_nfsdport.o] Error code 1

Stop in /usr/obj/usr/src/sys/GENERIC.
*** [buildkernel] Error code 1

Stop in /usr/src.
*** [buildkernel] Error code 1

Stop in /usr/src.
```


MYKERNEL

```
cc -c -O2 -frename-registers -pipe -fno-strict-aliasing  -std=c99 -g -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions  -Wmissing-include-dirs -fdiagnostics-show-option   -nostdinc  -I. -I/usr/src/sys -I/usr/src/sys/contrib/altq -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000  -fno-omit-frame-pointer -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fstack-protector -Werror  /usr/src/sys/vm/vm_map.c
cc1: warnings being treated as errors
/usr/src/sys/vm/vm_map.c:731: warning: no previous prototype for 'vmspace_wired_count' [-Wmissing-prototypes]
*** [vm_map.o] Error code 1

Stop in /usr/obj/usr/src/sys/MYKERNEL.
*** [buildkernel] Error code 1

Stop in /usr/src.
*** [buildkernel] Error code 1

Stop in /usr/src.
```

Anything that I might have done wrong? _I d_idn't encountered any problem on my other systems.

Thanks.


----------



## wblock@ (Jun 28, 2013)

Builds here.  Have you set custom CFLAGS in /etc/make.conf?


----------



## hoyanf (Jun 29, 2013)

Nothing on /etc/make.conf.


----------



## jozze (Jun 29, 2013)

First of all, are you sure you didn't make any changes to your GENERIC kernel configuration file?

Maybe your previous builds are getting in the way. Run

```
# cd /usr/src
# chflags -R noschg /usr/obj/*
# rm -rf /usr/obj/*
# make clean cleanworld cleandir
# make cleandir
```
The `# make cleandir` is meant to be run twice, like I wrote. After that, try to build the kernel again, starting with the GENERIC kernel.


----------



## wblock@ (Jun 29, 2013)

jozze said:
			
		

> ```
> # cd /usr/src
> # chflags -R noschg /usr/obj/*
> # rm -rf /usr/obj/*
> ```



That's enough.  The clean targets do the same thing only slower.

Actually, I just do `# rm -rf /usr/obj/usr`.


----------



## jozze (Jun 29, 2013)

The 25.7.16.6. What do I do if something goes wrong? suggests to do two consecutive `# make cleandir` commands as well, to be absolutely sure nothing will remain from the previous build, so that's why I suggested it. I didn't know they both did the same.


----------



## wblock@ (Jun 29, 2013)

They can be different if you are building only a certain program.  But not for buildworld.


----------



## hoyanf (Jun 29, 2013)

Hi, still on the same error for GENERIC kernel configuration even after the cleanup on the /usr/src. Nothing in /etc/make.conf.


```
# cd /usr/src
# chflags -R noschg /usr/obj/*
# rm -rf /usr/obj/*
# make clean cleanworld cleandir
# make cleandir
```


```
cc -c -O2 -frename-registers -pipe -fno-strict-aliasing  -std=c99 -g -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions  -Wmissing-include-dirs -fdiagnostics-show-option   -nostdinc  -I. -I/usr/src/sys -I/usr/src/sys/contrib/altq -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000  -fno-omit-frame-pointer -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fstack-protector -Werror  /usr/src/sys/fs/nfsserver/nfs_nfsdport.c
cc1: warnings being treated as errors
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c: In function 'nfsrv_sattr':
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2313: warning: implicit declaration of function 'NFSGETTIME'
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2313: warning: nested extern declaration of 'NFSGETTIME' [-Wnested-externs]
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c: In function 'nfsv4_sattr':
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2443: warning: passing argument 1 of 'nfsv4_strtouid' from incompatible pointer type
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2443: warning: passing argument 2 of 'nfsv4_strtouid' makes pointer from integer without a cast
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2443: warning: passing argument 3 of 'nfsv4_strtouid' makes integer from pointer without a cast
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2443: warning: passing argument 4 of 'nfsv4_strtouid' from incompatible pointer type
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2443: error: too few arguments to function 'nfsv4_strtouid'
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2469: warning: passing argument 1 of 'nfsv4_strtogid' from incompatible pointer type
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2469: warning: passing argument 2 of 'nfsv4_strtogid' makes pointer from integer without a cast
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2469: warning: passing argument 3 of 'nfsv4_strtogid' makes integer from pointer without a cast
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2469: warning: passing argument 4 of 'nfsv4_strtogid' from incompatible pointer type
/usr/src/sys/fs/nfsserver/nfs_nfsdport.c:2469: error: too few arguments to function 'nfsv4_strtogid'
*** [nfs_nfsdport.o] Error code 1

Stop in /usr/obj/usr/src/sys/GENERIC.
*** [buildkernel] Error code 1

Stop in /usr/src.
*** [buildkernel] Error code 1

Stop in /usr/src.
```

C*PU* type :

```
CPU: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz (3209.42-MHz K8-class CPU)
  Origin = "GenuineIntel"  Id = 0x206a2  Family = 6  Model = 2a  Stepping = 2
  Features=0x1fe3fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT>
  Features2=0x9e982203<SSE3,PCLMULQDQ,SSSE3,CX16,SSE4.1,SSE4.2,POPCNT,AESNI,XSAVE,OSXSAVE,AVX,HV>
  AMD Features=0x28100800<SYSCALL,NX,RDTSCP,LM>
  AMD Features2=0x1<LAHF>
  TSC: P-state invariant
```

Any chance it could be related to http://www.scip.ch/en/?vuldb.8580*?*

Thanks.


----------



## jozze (Jun 29, 2013)

What about /etc/src.conf? Do you have any settings there?

You can try to completely remove /usr/src and create again a fresh checkout with devel/subversion. Before you do that, don't forget to save your own custom kernel configuration file somewhere safe. After that you again run `# rm -rf /usr/obj/*` and retry the compilation.

As for that link you suggested: at the first glance it seems more like a security vulnerability than a bug that could affect the build process, however, I'm no expert and I could be wrong.


----------



## wblock@ (Jun 29, 2013)

If you have a custom kernel config, put it in /root and make a soft link to it in /usr/src.  Then it is somewhat safer from accidental deletion, and if /usr/src is removed, only the link needs to be recreated.


----------



## hoyanf (Jun 29, 2013)

Hi, I believe there is a change on the source tree as the revision is different and the errors on both config_s_ are at the same place /usr/src/sys/amd64/acpica/acpi_switch.S*.*

/etc/src.conf

```
cat /etc/src.conf
cat: /etc/src.conf: No such file or directory
```

/etc/make.conf

```
cat /etc/make.conf
cat: /etc/make.conf: No such file or directory
```

Previous source revision info

```
svn info /usr/src/
Path: /usr/src
Working Copy Root Path: /usr/src
URL: https://svn0.us-west.freebsd.org/base/stable/9
Repository Root: https://svn0.us-west.freebsd.org/base
Repository UUID: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Revision: [file]252359[/file]
Node Kind: directory
Schedule: normal
Last Changed Author: jhb
Last Changed Rev: 252350
Last Changed Date: 2013-06-29 02:25:04 +0800 (Sat, 29 Jun 2013)
```

Removed object `rm -rf /usr/obj/*`.

Removed source `rm -fr /usr/src/*`.

Re-checkout source files `svn co [url]https://svn0.us-west.freebsd.org/base/stable/9/[/url] /usr/src/`.

Current source revision info

```
svn info /usr/src/
Path: /usr/src
Working Copy Root Path: /usr/src
URL: https://svn0.us-west.freebsd.org/base/stable/9
Repository Root: https://svn0.us-west.freebsd.org/base
Repository UUID: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Revision: [file]252364[/file]
Node Kind: directory
Schedule: normal
Last Changed Author: jhb
Last Changed Rev: 252350
Last Changed Date: 2013-06-29 02:25:04 +0800 (Sat, 29 Jun 2013)
```

Compiled custom kernel config `make buildkernel KERNCONF=MYKERNEL`

```
cc -c -x assembler-with-cpp -DLOCORE -O2 -frename-registers -pipe -fno-strict-aliasing  -std=c99  -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions  -Wmissing-include-dirs -fdiagnostics-show-option   -nostdinc  -I. -I/usr/src/sys -I/usr/src/sys/contrib/altq -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000  -fno-omit-frame-pointer -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fstack-protector  -Werror /usr/src/sys/amd64/acpica/acpi_switch.S
/usr/src/sys/amd64/acpica/acpi_switch.S: Assembler messages:
/usr/src/sys/amd64/acpica/acpi_switch.S:146: Error: no such instruction: `xsetbv'
/usr/src/sys/amd64/acpica/acpi_switch.S:147: Error: no such instruction: `xrstor (%rbx)'
*** [acpi_switch.o] Error code 1

Stop in /usr/obj/usr/src/sys/MYKERNEL.
*** [buildkernel] Error code 1

Stop in /usr/src.
*** [buildkernel] Error code 1

Stop in /usr/src.
```

Removed object `rm -rf /usr/obj/*`

Compiled kernel with generic config `make buildkernel KERNCONF=GENERIC`

```
cc -c -x assembler-with-cpp -DLOCORE -O2 -frename-registers -pipe -fno-strict-aliasing  -std=c99 -g -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions  -Wmissing-include-dirs -fdiagnostics-show-option   -nostdinc  -I. -I/usr/src/sys -I/usr/src/sys/contrib/altq -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000  -fno-omit-frame-pointer -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fstack-protector  -Werror /usr/src/sys/amd64/acpica/acpi_switch.S
/usr/src/sys/amd64/acpica/acpi_switch.S: Assembler messages:
/usr/src/sys/amd64/acpica/acpi_switch.S:146: Error: no such instruction: `xsetbv'
/usr/src/sys/amd64/acpica/acpi_switch.S:147: Error: no such instruction: `xrstor (%rbx)'
*** [acpi_switch.o] Error code 1

Stop in /usr/obj/usr/src/sys/GENERIC.
*** [buildkernel] Error code 1

Stop in /usr/src.
*** [buildkernel] Error code 1

Stop in /usr/src.
```

I guess I might just wait a[ ]bit before recompiling since there _are_ still changes on the source.

Thanks.


----------



## wblock@ (Jun 29, 2013)

When you update source to newer than what is currently installed, a buildworld has to be done before trying to build a new kernel.  That gets a toolchain with the necessary features in place.


----------



## kpa (Jun 29, 2013)

More specifically if you don't do `make buildworld` first, the kernel compilation will try to use the header files from /usr/include instead of the new headers that come with the updated source. So, always do `make buildworld` first, or at least `make kernel-toolchain`, when you have updated sources and want to compile a new kernel.


----------



## hoyanf (Jun 29, 2013)

Hi _a_ll, thanks for all the effort to troubleshoot this matter. I did a new clean install inclu_ding_ ports and src. 

_I c_ompiled and installed my initial custom kernel*,* updated src via _SVN_*,* `make buildworld`, compiled and installed _a_ new kernel based on the updated source*,* reboot _and_ `make installworld`*.*

Now *I* guess all are in good hands.

Thank you all again for the excellent assistance.


----------



## jozze (Jun 30, 2013)

Just to be sure, don't forget to run the `# mergemaster` command if you haven't done it yet. The `# make installworld` should be issued like this:

```
# mergemaster -p
# cd /usr/src && make installworld
# mergemaster
```
See the Handbook in case you don't know about this.


----------



## wblock@ (Jun 30, 2013)

mergemaster(8) becomes less painful when used with -Ui and set to ignore files that should not be merged in /etc/mergemaster.rc.


----------

