Solved buildkernel/buildworld forces warnings to errors. How do I disable on make commandline?

The subject probably seems like a FAQ, but bear with me.

I'm trying to come up with a way to cross compile kernel/world on an older version of FreeBSD (12.1-R) that works on both 12.x and 13.x systems.

I'm in a situation where a newer version of LLVM emits a misleading indentation warning during kernel build, and because the -Werror option is added by the makefile it aborts the build process.

To avoid this I've tried (on a 12.3-R system)

1. make -DWITHOUT_WARNS ... (from src.conf(5)) ... still includes -Werror

2. make -DNO_WERROR ... ... still includes -Werror

3. make CFLAGS+=-Wno-misleading-indentation ... but this clears CFLAGS, rather than appending (note I used "+="), so build quickly bombs out

4. Adding NO_WERROR= and WERROR= to /etc/src.conf ... still includes -Werror

I can manually compile the single source file it complains about, but as this build process will be part of a HOWTO I'd prefer it to be less hacky. For the same reason, an edit of the source to fix the warning is not really viable.

I've spent some time on this and nothing seems to work. I think #3 is probably the best option as it bypasses only one specific warning, but perhaps += doesn't work on the commandline.

What am I missing? Thanks.
 
make WARNS=0 something
Thanks, but this doesn't work. -Werror is still present, and the build still aborts.

Example build commandline:

make WARNS=0 CROSS_TOOLCHAIN=llvm10 NO_MODULES=yes TARGET=arm TARGET_ARCH=armv7 KERNCONF=ODROIDC1 buildkernel

And the generated commandline for the file which errors out:
Code:
/usr/local/bin/clang10 -target armv7-gnueabihf-freebsd12.1 --sysroot=/usr/obj/usr/home/rowan/tmpsrc/arm.armv7/tmp -B/var/empty -c -O -pipe  -g -nostdinc  -I. -I/usr/home/rowan/tmpsrc/sys -I/usr/home/rowan/tmpsrc/sys/contrib/ck/include -I/usr/home/rowan/tmpsrc/sys/contrib/libfdt -I/usr/home/rowan/tmpsrc/sys/gnu/dts/include -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -march=armv7a -funwind-tables -MD  -MF.depend.identcpu-v6.o -MTidentcpu-v6.o -fdebug-prefix-map=./machine=/usr/home/rowan/tmpsrc/sys/arm/include -ffreestanding -fwrapv -gdwarf-2 -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mfpu=none  -std=iso9899:1999 [b]-Werror[/b]  /usr/home/rowan/tmpsrc/sys/arm/arm/identcpu-v6.c
 
When I try compiling world or kernel or ports - I often see the 'misleading identation' message from LLVM, but it comes up as a warning, rather than an error. I didn't try any special make.conf or command-line flags, I just went with defaults, following the Handbook. Well, my intent was to work through the steps, and get a re-compiled kernel/world with just the default settings. YMMV.
 
add MK_WERROR=no
Still no change; -Werror persists.


I tried starting from scratch in a VM, and the same thing happens...

- Clean install of 12.2-RELEASE in a VM (x86 amd64)
- Update to 12.3-RELEASE via freebsd-update:

Code:
# uname -a
FreeBSD vultr.guest 12.3-RELEASE FreeBSD 12.3-RELEASE r371126 GENERIC  amd64
# freebsd-version -kru
12.3-RELEASE
12.3-RELEASE
12.3-RELEASE

Then prepare and make:

Code:
# mkdir /root/tmpsrc
# cd /root/tmpsrc
# svnlite checkout https://svn.freebsd.org/base/releng/12.1 .
# fetch -o /root/tmpsrc/sys/gnu/dts/arm/meson.dtsi "https://svnweb.freebsd.org/base/releng/11.1/sys/gnu/dts/arm/meson.dtsi?revision=320486&view=co&pathrev=324819"
# pkg install llvm10
# make clean
# make WARNS=0 CROSS_TOOLCHAIN=llvm10 NO_MODULES=yes TARGET=arm TARGET_ARCH=armv7 KERNCONF=ODROIDC1 buildkernel

[... snip lots of successful compile info ... UNTIL...]

/usr/local/bin/clang10 -target armv7-gnueabihf-freebsd12.1 --sysroot=/usr/obj/root/tmpsrc/arm.armv7/tmp -B/var/empty -c -O -pipe  -g -nostdinc  -I. -I/root/tmpsrc/sys -I/root/tmpsrc/sys/contrib/ck/include -I/root/tmpsrc/sys/contrib/libfdt -I/root/tmpsrc/sys/gnu/dts/include -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -march=armv7a -funwind-tables -MD  -MF.depend.identcpu-v6.o -MTidentcpu-v6.o -fdebug-prefix-map=./machine=/root/tmpsrc/sys/arm/include -ffreestanding -fwrapv -gdwarf-2 -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mfpu=none  -std=iso9899:1999 -Werror  /root/tmpsrc/sys/arm/arm/identcpu-v6.c
/root/tmpsrc/sys/arm/arm/identcpu-v6.c:227:5: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
                                if (val & CPUV7_CT_CTYPE_RA)
                                ^
/root/tmpsrc/sys/arm/arm/identcpu-v6.c:225:4: note: previous statement is here
                        if (val & CPUV7_CT_CTYPE_WB)
                        ^
1 error generated.
*** Error code 1

Stop.
make[2]: stopped in /usr/obj/root/tmpsrc/arm.armv7/sys/ODROIDC1
*** Error code 1
*** Error code 1
 
In the list of things you tried, one line explicitly refers to src.conf(5)... Did you try actually putting that recipe into /etc/src.conf?
Also, you mentioned a couple of things that you did put into src.conf, but none of them is documented for src.conf...
 
i don't see MK_WERROR=no in the cmd line

Not in the specific sequence of steps I posted above, but I did try it prior, and MK_WERROR=no doesn't seem to change behaviour.

make MK_WERROR=no CROSS_TOOLCHAIN=llvm10 NO_MODULES=yes TARGET=arm TARGET_ARCH=armv7 KERNCONF=ODROIDC1 buildkernel

[...]
Code:
cc -target armv7-gnueabihf-freebsd12.1 --sysroot=/usr/obj/usr/home/rowan/tmpsrc/arm.armv7/tmp -B/usr/obj/usr/home/rowan/tmpsrc/arm.armv7/tmp/usr/bin -c -O -pipe  -g -nostdinc  -I. -I/usr/home/rowan/tmpsrc/sys -I/usr/home/rowan/tmpsrc/sys/contrib/ck/include -I/usr/home/rowan/tmpsrc/sys/contrib/libfdt -I/usr/home/rowan/tmpsrc/sys/gnu/dts/include -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -march=armv7a -funwind-tables -MD  -MF.depend.cam_periph.o -MTcam_periph.o -fdebug-prefix-map=./machine=/usr/home/rowan/tmpsrc/sys/arm/include -ffreestanding -fwrapv -gdwarf-2 -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mfpu=none  -std=iso9899:1999 [B]-Werror[/B]  /usr/home/rowan/tmpsrc/sys/cam/cam_periph.c

In the list of things you tried, one line explicitly refers to src.conf(5)... Did you try actually putting that recipe into /etc/src.conf?
Also, you mentioned a couple of things that you did put into src.conf, but none of them is documented for src.conf...

The only thing put into /etc/src.conf is:

Code:
# This setting to build world without -Werror:
NO_WERROR=
# This setting to build kernel without -Werror:
WERROR=

I also tried same in /etc/make.conf, again without success.

Every other directive (like -DNO_WERROR) was part of the make ... commandline.

Basically nothing I do changes behaviour: with the exception of CFLAGS (which causes other fatal problems), -Werror always appears on the generated commandline. That's what is so confusing.

I'm wondering if it has anything to do with me building from a different source directory. Is /usr/src hardcoded anywhere?
 
Workaround: Build the file you mean by hand, if that is possible, then do the make run with
NO_CLEAN=YES
this will prevent the object from being removed, and the make has a chance to not rebuild it. This could work.
 
for kernel build use make WERROR= buildkernel
Finally it works, kernel build is complete! I narrowed it down to include only -Wno-misleading-indentation:

make WERROR=-Wno-misleading-indentation CROSS_TOOLCHAIN=llvm10 NO_MODULES=yes TARGET=arm TARGET_ARCH=armv7 KERNCONF=ODROIDC1 buildkernel

Why are there so many different options related to suppressing errors?
 
Because the most elegant and simple solution to such should be and continue to be to fix that error.

Agree in principle, but to clarify, I was referring to the different FreeBSD-specific build directives I came across on Google, and a few more which were offered in this thread. Wouldn't it be better to just have a single warning-to-error related directive that can be used for building kernel and world? (The same misleading indentation warning is now happening with buildworld, but it seems WERROR=... is not the directive to use for this, so I have to try the other 6 again, and hope one works.)

I do have a bit of an unusual setup. The issue is that the 'host' system gets a newer LLVM version which introduces one or more situations where a new warning is emitted, but it's compiling older source which has not been updated to eliminate those warnings. I'd prefer to work around the warning rather than hack the source.
 
rowan194 , in case I was not clear, my point was that src.conf(5) documents options WITHOUT_WARNS and WITHOUT_WERROR.
But for some reason you are not putting those options into src.conf. Instead you are putting some other things that are not mentioned in the documentation.
Why?
 
rowan194 , in case I was not clear, my point was that src.conf(5) documents options WITHOUT_WARNS and WITHOUT_WERROR.
But for some reason you are not putting those options into src.conf. Instead you are putting some other things that are not mentioned in the documentation.
Why?
I was trying to avoid changing the system's config for a single cross-compile. For me, such a temporary change would have likely been forgotten. As you can see in the OP, I did end up trying that, in desperation, although obviously with the incorrect option.
 
Back
Top