NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
port-i386/52451: PMC support breaks build of kernels with COPTS=-Os
>Number: 52451
>Category: port-i386
>Synopsis: PMC support breaks build of kernels with COPTS=-Os
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: port-i386-maintainer
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Aug 01 23:45:00 +0000 2017
>Originator: John D. Baker
>Release: NetBSD/i386-8.99.1 after 201707121741Z, NetBSD/i386-8.0_BETA after 201708012319Z
>Organization:
>Environment:
NetBSD net4501b.technoskunk.fur 8.0_BETA NetBSD 8.0_BETA (NET4501_JDB) #70: Wed Jul 26 19:38:45 CDT 2017 sysop%x3650.technoskunk.fur@localhost:/r1/build/netbsd-8/obj/i386/sys/arch/i386/compile/NET4501_JDB i386
>Description:
Kernel configs like "NET4501" routinely include:
makeoptions "COPTS=-Os"
This causes GCC to emit warnings (treated as errors) if it thinks a
variable might be used uninitialized. For example, the following:
# compile NET4501_JDB/pmc.o
/r1/build/current/tools/amd64/bin/i486--netbsdelf-gcc -msoft-float -mno-mmx -mno-sse -mno-avx -ffreestanding -fno-zero-initialized-in-bss -g -Os -fstack-protector -Wstack-protector --param ssp-buffer-size=1 -fno-strict-aliasing -fno-common -std=gnu99 -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wno-unreachable-code -Wno-pointer-sign -Wno-attributes -Wextra -Wno-unused-parameter -Wold-style-definition -Wno-sign-compare --sysroot=/r1/build/current/DEST/i386 -Di386 -I. -I/x/current/src/sys/external/bsd/acpica/dist -I/x/current/src/sys/../common/lib/libx86emu -I/x/current/src/sys/../common/include -I/x/current/src/sys/arch -I/x/current/src/sys -nostdinc -DTIMER_FREQ=1189200 -D_KERNEL -D_KERNEL_OPT -std=gnu99 -I/x/current/src/sys/lib/libkern/../../../common/lib/libc/quad -I/x/current/src/sys/lib/libkern/../../../common/lib/libc/string -I/x/current/src/sys/lib/l
ibkern/../../../common/lib/libc/arch/i386/string -D_FORTIFY_SOURCE=2 -I/x/current/src/sys/dist/pf -c /x/current/src/sys/arch/x86/x86/pmc.c -o pmc.o
/x/current/src/sys/arch/x86/x86/pmc.c: In function 'pmc_nmi':
/x/current/src/sys/arch/x86/x86/pmc.c:168:2: error: 'pmc' may be used uninitialized in this function [-Werror=maybe-uninitialized]
wrmsr(pmc->ctrmsr, pmc->ctrinitval);
^
>How-To-Repeat:
Attempt to build NET4501 kernel on -current after 201707121741Z or
on 8.0_BETA after 201708012319Z.
>Fix:
Workaround:
Would the following patch be appropriate for appeasing GCC?
+Index: sys/arch/x86/x86/pmc.c
+===================================================================
+RCS file: /cvsroot/src/sys/arch/x86/x86/pmc.c,v
+retrieving revision 1.10
+diff -u -p -r1.10 pmc.c
+--- sys/arch/x86/x86/pmc.c 12 Jul 2017 17:33:29 -0000 1.10
++++ sys/arch/x86/x86/pmc.c 13 Jul 2017 19:08:13 -0000
+@@ -138,7 +138,7 @@ static int
+ pmc_nmi(const struct trapframe *tf, void *dummy)
+ {
+ struct cpu_info *ci = curcpu();
+- pmc_state_t *pmc;
++ pmc_state_t *pmc = (pmc_state_t *)NULL;
+ pmc_cpu_t *cpu;
+ uint64_t ctr;
+ size_t i;
Home |
Main Index |
Thread Index |
Old Index