Solved Buildworld fails with error: invalid argument '-std=gnu99' not allowed with 'C++'

Hello,

I'm following this guide to update FreeBSD 14.0-STABLE and I keep getting this:
Code:
===> usr.sbin/config (obj,all,install)
[Creating objdir /usr/obj/usr/src/amd64.amd64/tmp/obj-tools/usr.sbin/config...]
yacc -d  /usr/src/usr.sbin/config/config.y
yacc: 3 rules never reduced
cp y.tab.c config.c
lex   -olang.c /usr/src/usr.sbin/config/lang.l
file2c 'char kernconfstr[] = {' ',0};' <  /usr/src/usr.sbin/config/kernconf.tmpl > kernconf.c
echo config.full: /usr/lib/libc.a /usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/lib/libegacy.a >> .depend
echo config.full: /usr/lib/libc++.a >> .depend
/usr/local/bin/ccache clang  -O2 -pipe -O -O2 -pipe -march=skylake -fno-common -I. -I/usr/src/usr.sbin/config  -g -gz=zlib -MD  -MF.depend.config.o -MTconfig.o -std=gnu99 -Wno-format-zero-length -Wsystem-headers -Wall -Wno-format-y2k >
/usr/local/bin/ccache clang++  -O2 -pipe -O -O2 -pipe -march=skylake -fno-common -I. -I/usr/src/usr.sbin/config -g -gz=zlib -MD -MF.depend.main.o -MTmain.o -Wno-format-zero-length -Wsystem-headers -Wall -Wno-format-y2k -W -Wno-unused->
error: invalid argument '-std=gnu99' not allowed with 'C++'
*** Error code 1

Stop.
make[3]: stopped in /usr/src/usr.sbin/config
*** Error code 1

Stop.
make[2]: stopped in /usr/src
        8.11 real         4.98 user         2.96 sys
*** Error code 1

Stop.
make[1]: stopped in /usr/src
*** Error code 1

Stop.
make: stopped in /usr/src
Code:
$ uname -a
FreeBSD redbox 14.0-STABLE FreeBSD 14.0-STABLE GENERIC amd64
Code:
# cat /etc/make.conf

CPUTYPE=skylake
CFLAGS+= -O -O2 -pipe -march=${CPUTYPE}
CXXFLAGS+=${CFLAGS}
MACHINE_CPU+= avx2 avx sse42 sse41 ssse3 sse3 sse2 sse amd64 f16c mmx
MAKE_JOBS_NUMBER= 16

OPTIONS_UNSET+= QT5 QT6 CUPS VESA SCFB TWM XCONSOLE XCLOCK GNOME KDE EXAMPLES \
                DEBUG ASPELL

CC=clang
CXX=clang++
CPP=clang-cpp   

# To compile just the kernel with special optimizations, you should use
# this instead of CFLAGS (which is not applicable to kernel builds anyway).
# There is very little to gain by using higher optimization levels, and doing
# so can cause problems.
#
COPTFLAGS= -O -2 -pipe   <<<<< do I need this? the statement above is a bit confusing! 

NO_SENDMAIL=true
Code:
# cat /etc/src.conf

WITH_CCACHE_BUILD=yes
WITHOUT_SENDMAIL=yes
WITHOUT_TALK=yes
WITHOUT_TELNET=yes
WITHOUT_TFTP=yes
WITHOUT_IPFILTER=yes
WITHOUT_FLOPPY=yes
WITHOUT_GAMES=yes

Threads I read and didn't help solve this issue (I'm not trying to use GCC and I'd like to stay with LLVM/clang if possible):

https://forums.freebsd.org/threads/trying-to-build-a-linux-c-program-on-freebsd-14-with-gcc9.92731/
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=251170
 
Remove CFLAGS and CXXFLAGS, they're incorrect and causes more issues than what they solve
Remove MACHINE_CPU (unnecessary), remove MAKE_JOBS_NUMBER (the framework will figure out this one on its own)
Drop CC, CXX and CPP variables (this will break things)
Remove COPTFLAGS, not needed and incorrect
Remove NO_SENDMAIL (incorrect)

Drop WITH_CCACHE_BUILD from /etc/src.conf

What are you updating to (and what branch are you using)?
 
Last edited:
Remove CFLAGS and CXXFLAGS, they're incorrect and causes more issues than they solve
Remove MACHINE_CPU (unnecessary), remove MAKE_JOBS_NUMBER (the framerwork will figure out this one on its own)
Drop CC, CXX and CPP variables (this will break things)
Remove COPTFLAGS, not needed and incorrect
Remove NO_SENDMAIL (incorrect)

Drop WITH_CCACHE_BUILD from /etc/src.conf

What are you updating to (and what branch are you using)?
Removing those options didn't solve the issue. I'm still getting the same error!

14-STABLE to the latest snapshot on https://git.freebsd.org/src.git as defined in the guide in OP.
 
Did you do a make clean before retrying the build?
Yes.

I commented out CXXFLAGS+=${CFLAGS} & corrected CPUTYPE?=skylake in /etc/make.conf, deleted the contents of /usr/src, cloned it again and it worked.

I did run into other issues not related to this thread but I had to give up on STABLE and decided to use RELEASE to make my life easier.

Thanks gents.
 
Back
Top