# make buildworld fails with bad value ( -O2 -pipe)



## lalebarde (Dec 2, 2010)

Hi all,
I am new to FreeBSD :stud. I am setting up a web server. I am at the stage to rebuild world. It fails  with : 
	
	



```
# make buildworld
--------------------------------------------------------------
>>> World build started on Thu Dec  2 16:09:09 CET 2010
--------------------------------------------------------------

--------------------------------------------------------------
>>> Rebuilding the temporary build tree
--------------------------------------------------------------
rm -rf /usr/obj/usr/src/tmp
rm -rf /usr/obj/usr/src/lib32
mkdir -p /usr/obj/usr/src/tmp/lib
mkdir -p /usr/obj/usr/src/tmp/usr
mkdir -p /usr/obj/usr/src/tmp/legacy/usr
mtree -deU -f /usr/src/etc/mtree/BSD.usr.dist  -p /usr/obj/usr/src/tmp/legacy/usr >/dev/null
mtree -deU -f /usr/src/etc/mtree/BSD.usr.dist  -p /usr/obj/usr/src/tmp/usr >/dev/null
mtree -deU -f /usr/src/etc/mtree/BSD.include.dist  -p /usr/obj/usr/src/tmp/usr/include >/dev/null
ln -sf /usr/src/sys /usr/obj/usr/src/tmp

--------------------------------------------------------------
>>> stage 1.1: legacy release compatibility shims
--------------------------------------------------------------
cd /usr/src; MAKEOBJDIRPREFIX=/usr/obj/usr/src/tmp  INSTALL="sh /usr/src/tools/install.sh"  
PATH=/usr/obj/usr/src/tmp/legacy/usr/sbin:/usr/obj/usr/src/tmp/legacy/usr/bin:/usr/obj/usr/src/tmp/legacy/usr/games:/sbin:/bin:/usr/sbin:/usr/b
in  WORLDTMP=/usr/obj/usr/src/tmp  VERSION="FreeBSD 8.1-RELEASE amd64 801000"  MAKEFLAGS="-m /usr/src/tools/build/mk  -m /usr/src/share/mk" 
make -f Makefile.inc1  DESTDIR=  BOOTSTRAPPING=801000  SSP_CFLAGS=  -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN  -DNO_PIC -
DWITHOUT_PROFILE -DNO_SHARED  -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF legacy
===> tools/build (obj,includes,depend,all,install)
/usr/obj/usr/src/tmp/usr/src/tools/build created for /usr/src/tools/build
cd /usr/src/tools/build; make buildincludes; make installincludes
rm -f .depend
mkdep -f .depend -a    -I/usr/obj/usr/src/tmp/legacy/usr/include /usr/src/tools/build/dummy.c
cc "-march= -O2 -pipe"   -I/usr/obj/usr/src/tmp/legacy/usr/include -c /usr/src/tools/build/dummy.c
/usr/src/tools/build/dummy.c:1: error: bad value ( -O2 -pipe) for -march= switch
/usr/src/tools/build/dummy.c:1: error: bad value ( -O2 -pipe) for -mtune= switch
*** Error code 1

Stop in /usr/src/tools/build.
*** Error code 1

Stop in /usr/src.
*** Error code 1

Stop in /usr/src.
*** Error code 1

Stop in /usr/src.
```
*Any idea please ?* Here are some details :

My machine :
	
	



```
# uname -a
FreeBSD xxxx.com 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:36:49 UTC 2010     root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  
amd64
```


```
# dmesg
CPU: QEMU Virtual CPU version 0.13.0 (2792.85-MHz K8-class CPU)
  Origin = "GenuineIntel"  Id = 0x623  Family = 6  Model = 2  Stepping = 3
  Features=0x783fbfd<FPU,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE,SSE2>
  Features2=0x80802001<SSE3,CX16,POPCNT,<b31>>
  AMD Features=0x20100800<SYSCALL,NX,LM>
  AMD Features2=0x1<LAHF>
```
My make.conf :
	
	



```
# cat /etc/make.conf
USA_RESIDENT=	NO
NO_X=true
NO_CPU_CFLAGS=		# Don't add -march=<cpu> to CFLAGS automatically
PUTYPE?=K8
CFLAGS="-march= -O2 -pipe"
COPTFLAGS= -O -pipe
LDFLAGS="-Wl,-O1"
INSTALL=install -C
BOOTWAIT=3
NO_BLUETOOTH=true       # do not build Bluetooth related stuff
NO_FORTRAN=true         # do not build g77 and related libraries
NO_GAMES=true           # do not build games (games/ subdir)
NO_I4B=true             # do not build isdn4bsd package
NO_INET6=true           # do not build IPv6 related programs and libraries
NO_PROFILE=true         # Avoid compiling profiled libraries
NO_RCMDS=true           # do not build or install BSD r* commands (rsh, etc).
NO_SENDMAIL=true        # do not build sendmail and related programs
NO_TCSH=true            # do not build and install /bin/csh (which is tcsh)
NO_USB=true             # do not build usbd(8) and related programs
PPP_NO_RADIUS=true      # do not build with RADIUS support ##//wireless
NO_BIND=true            # Do not build any part of BIND
MAKE_IDEA=true          # IDEA (128 bit symmetric encryption)
BOOTWAIT=0
DOC_LANG=       en_US.ISO8859-1
NO_WPA_SUPPLICANT_EAPOL=true
```


----------



## SirDice (Dec 2, 2010)

Remove all these from your make.conf:

```
USA_RESIDENT=	NO
NO_X=true
NO_CPU_CFLAGS=		# Don't add -march=<cpu> to CFLAGS automatically
PUTYPE?=K8
CFLAGS="-march= -O2 -pipe"
COPTFLAGS= -O -pipe
LDFLAGS="-Wl,-O1"
INSTALL=install -C
```

The only "optimization" you need to do is to set CPUTYPE (note the typo in your make.conf). Do NOT use CFLAGS or any of the other "optimizations" until you fully understand what they do.


Edit: Oh, also remove this one: NO_TCSH=true. That's root's default shell, you really want to keep it.


----------



## DutchDaemon (Dec 2, 2010)

You can put/leave in

```
WITHOUT_X11=yes
```

But other than that and CPUTYPE: remove.


----------



## lalebarde (Dec 2, 2010)

Thank you very much SirDice. It looks working (compiling) now.


----------



## lalebarde (Dec 2, 2010)

Could you explain the rational please ? Is there an expert mechanism that probes the architecture and set automatically the right options ?


----------



## fronclynne (Dec 3, 2010)

lalebarde said:
			
		

> Could you explain the rational please ? Is there an expert mechanism that probes the architecture and set automatically the right options ?



Almost.  Most everything is already aliased to That Which Works Best if you set CPUTYPE correctly.  See /usr/share/mk/bsd.cpu.mk* for more info.

*and his friends in /usr/share/mk/ & /usr/ports/Mk/


----------



## xibo (Dec 3, 2010)

Hello. This is the problem:


			
				lalebarde said:
			
		

> cc "-march= -O2 -pipe"   -I/usr/obj/usr/src/tmp/legacy/usr/include -c /usr/src/tools/build/dummy.c



Or more precisely, this:


			
				lalebarde said:
			
		

> cc "-march= -O2 -pipe" ...



which is supposed to be one the following

```
cc -O2 -pipe ... #probably the best that "just works"
cc -march=i686 -O2 -pipe ... #pentium pro and newer IBM-PC (32 bit mode)
cc "-march=i686" "-O2" "-pipe" ... #notice the spaces were left unescaped
```

All which are caused by the CFLAGS line of your make.conf. So either remove the quote characters, ie CFLAGS=-O2 -pipe ( unlike in gentoo linux' portage where most make.conf examples found by websearches belong to, freebsd's build system does not need you to quote or escape the rvalues in make.conf ) or escape each rvalue argument on it's own. You won't get errors with the LDFLAGS yet(!) because the -Wl,-O1 is one argument to gcc.

Also, do something about the -march option. For compiling the OS, I'd consider it countereffective to begin with, due to gcc's code generation bugs and the fact the OS doesn't use a lot of model-specific optimizable code like e.g. vector math anyway.


----------



## lalebarde (Dec 3, 2010)

:e:e:e Thank you very much all of you :e:e:e

```
--------------------------------------------------------------
>>> World build completed on Fri Dec  3 11:16:00 CET 2010
--------------------------------------------------------------
```
With :
	
	



```
USA_RESIDENT=   NO
WITHOUT_X11=yes
CPUTYPE?=k8
```
Here are the final options obtained :
	
	



```
cc -m32 -march=k8 -mfancy-math-387 -DCOMPAT_32BIT  -iprefix /usr/obj/usr/src/lib32/usr/  -L/usr/obj/usr/src/lib32/usr/lib32  -B/usr/obj/usr/src/lib32/usr/lib32 -O2 -pipe -Wall -DFREEBSD_ELF -DIN_RTLD -I/usr/src/libexec/rtld-elf/i386 -I/usr/src/libexec/rtld-elf -fpic -DPIC -elf -std=gnu99 -Wformat=2 -Wno-format-extra-args -Werror  -nostdlib -e .rtld_start -shared -Wl,-Bsymbolic -Wl,--version-script=Version.map -elf
```


----------

