From a4786b575c66435f4836105312400f6567d1ce4f Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 16 Feb 2004 19:57:39 +0000 Subject: [PATCH] Compile the kernel with -fno-common to guarentee that we do not accidently put non-extern'd variable declarations in header files. Our module loader no longer deals with commons so duplicate declarations can cause kldloaded modules to fail, and its sloppy programming anyway. --- sys/conf/Makefile.amd64 | 4 ++-- sys/conf/Makefile.i386 | 4 ++-- sys/conf/bsd.kern.mk | 7 ++++++- sys/conf/files.i386 | 6 +++--- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/sys/conf/Makefile.amd64 b/sys/conf/Makefile.amd64 index 3a1d1997a7..ec59b89dc9 100644 --- a/sys/conf/Makefile.amd64 +++ b/sys/conf/Makefile.amd64 @@ -1,7 +1,7 @@ # Makefile.amd64 -- with config changes. # Copyright 1990 W. Jolitz # from: @(#)Makefile.i386 7.1 5/10/91 -# $DragonFly: src/sys/conf/Attic/Makefile.amd64,v 1.1 2004/02/02 08:05:56 dillon Exp $ +# $DragonFly: src/sys/conf/Attic/Makefile.amd64,v 1.2 2004/02/16 19:57:39 dillon Exp $ # # Makefile for FreeBSD # @@ -176,7 +176,7 @@ assym.s: $S/kern/genassym.sh genassym.o sh $S/kern/genassym.sh genassym.o > ${.TARGET} genassym.o: $S/$M/$M/genassym.c - ${CC} -c ${CFLAGS} $S/$M/$M/genassym.c + ${CC} -c ${CFLAGS:N-fno-common} $S/$M/$M/genassym.c ${SYSTEM_OBJS} genassym.o vers.o: opt_global.h diff --git a/sys/conf/Makefile.i386 b/sys/conf/Makefile.i386 index 2fc328dc6b..a6464b56e2 100644 --- a/sys/conf/Makefile.i386 +++ b/sys/conf/Makefile.i386 @@ -2,7 +2,7 @@ # Copyright 1990 W. Jolitz # from: @(#)Makefile.i386 7.1 5/10/91 # $FreeBSD: src/sys/conf/Makefile.i386,v 1.179.2.16 2002/11/18 11:26:49 ru Exp $ -# $DragonFly: src/sys/conf/Attic/Makefile.i386,v 1.11 2003/11/17 00:54:39 asmodai Exp $ +# $DragonFly: src/sys/conf/Attic/Makefile.i386,v 1.12 2004/02/16 19:57:39 dillon Exp $ # # Makefile for FreeBSD # @@ -177,7 +177,7 @@ assym.s: $S/kern/genassym.sh genassym.o sh $S/kern/genassym.sh genassym.o > ${.TARGET} genassym.o: $S/$M/$M/genassym.c - ${CC} -c ${CFLAGS} $S/$M/$M/genassym.c + ${CC} -c ${CFLAGS:N-fno-common} $S/$M/$M/genassym.c ${SYSTEM_OBJS} genassym.o vers.o: opt_global.h diff --git a/sys/conf/bsd.kern.mk b/sys/conf/bsd.kern.mk index 02b3952f11..c1135254f0 100644 --- a/sys/conf/bsd.kern.mk +++ b/sys/conf/bsd.kern.mk @@ -1,5 +1,5 @@ # $FreeBSD: src/share/mk/bsd.kern.mk,v 1.17.2.1 2001/08/01 16:56:56 obrien Exp $ -# $DragonFly: src/sys/conf/bsd.kern.mk,v 1.3 2004/02/04 21:09:17 rob Exp $ +# $DragonFly: src/sys/conf/bsd.kern.mk,v 1.4 2004/02/16 19:57:39 dillon Exp $ # # Warning flags for compiling the kernel and components of the kernel. @@ -40,6 +40,11 @@ CFLAGS+= -mpreferred-stack-boundary=2 CFLAGS+= -mno-fp-regs -Wa,-mev56 .endif +# Require the proper use of 'extern' for variables. -fno-common will +# cause duplicate declarations to generate a link error. +# +CFLAGS+= -fno-common + # Prevent GCC 3.x from making certain libc based inline optimizations # CFLAGS+= -ffreestanding diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index 735b5c2373..eced46313f 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -2,7 +2,7 @@ # files marked standard are always included. # # $FreeBSD: src/sys/conf/files.i386,v 1.307.2.38 2003/01/02 20:41:33 kan Exp $ -# $DragonFly: src/sys/conf/Attic/files.i386,v 1.13 2004/02/14 21:12:38 dillon Exp $ +# $DragonFly: src/sys/conf/Attic/files.i386,v 1.14 2004/02/16 19:57:39 dillon Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -10,13 +10,13 @@ # linux_genassym.o optional compat_linux \ dependency "$S/emulation/linux/i386/linux_genassym.c" \ - compile-with "${CC} ${CFLAGS} -c ${.IMPSRC}" \ + compile-with "${CC} ${CFLAGS:N-fno-common} -c ${.IMPSRC}" \ no-obj no-implicit-rule \ clean "linux_genassym.o" # svr4_genassym.o optional compat_svr4 \ dependency "$S/emulation/svr4/i386/svr4_genassym.c" \ - compile-with "${CC} ${CFLAGS} -c ${.IMPSRC}" \ + compile-with "${CC} ${CFLAGS:N-fno-commmon} -c ${.IMPSRC}" \ no-obj no-implicit-rule \ clean "svr4_genassym.o" # -- 2.41.0