From rmh@io.debian.net  Wed Apr 26 06:48:08 2006
Return-Path: <rmh@io.debian.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id CE21F16A402
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 26 Apr 2006 06:48:08 +0000 (UTC)
	(envelope-from rmh@io.debian.net)
Received: from io.debian.net (io.ethz.ch [129.132.80.17])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 6C01C43D45
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 26 Apr 2006 06:48:08 +0000 (GMT)
	(envelope-from rmh@io.debian.net)
Received: from rmh by io.debian.net with local (Exim 4.61)
	(envelope-from <rmh@io.debian.net>)
	id 1FYdok-000CiR-8U
	for FreeBSD-gnats-submit@freebsd.org; Wed, 26 Apr 2006 08:48:06 +0200
Message-Id: <E1FYdok-000CiR-8U@io.debian.net>
Date: Wed, 26 Apr 2006 08:48:06 +0200
From: Robert Millan <rmh@aybabtu.com>
Reply-To: Robert Millan <rmh@aybabtu.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] disable build of modules that are already in kernel image
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         96346
>Category:       kern
>Synopsis:       [modules] [patch] disable build of modules that are already in kernel image
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 26 06:50:18 GMT 2006
>Closed-Date:    
>Last-Modified:  Wed Apr 26 10:40:08 GMT 2006
>Originator:     Robert Millan
>Release:        GNU/kFreeBSD 5.4-1-586 i586
>Organization:
>Environment:
System: GNU/kFreeBSD io.debian.net 5.4-1-586 #0 Mon Dec 5 19:45:10 CET 2005 i586 i386 AMD-K6(tm) 3D processor GNU/kFreeBSD
Architecture: i586

	
>Description:
	Unless explicitly overriden, in a kernel build all modules are also built;
	even those that are already part of the kernel image.  These modules are
	useless since they can't be loaded.  My patch disables them.

>How-To-Repeat:
	
>Fix:

Index: usr.sbin/config/mkmakefile.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/config/mkmakefile.c,v
retrieving revision 1.86
diff -u -r1.86 mkmakefile.c
--- usr.sbin/config/mkmakefile.c	3 Feb 2006 06:12:10 -0000	1.86
+++ usr.sbin/config/mkmakefile.c	26 Apr 2006 06:39:05 -0000
@@ -70,6 +70,7 @@
 static void do_rules(FILE *);
 static void do_xxfiles(char *, FILE *);
 static void do_objs(FILE *);
+static void do_without_modules(FILE *);
 static void do_before_depend(FILE *);
 static int opteq(const char *, const char *);
 static void read_files(void);
@@ -143,6 +144,8 @@
 		}
 		if (eq(line, "%BEFORE_DEPEND\n"))
 			do_before_depend(ofp);
+		else if (eq(line, "%WITHOUT_MODULES\n"))
+			do_without_modules(ofp);
 		else if (eq(line, "%OBJS\n"))
 			do_objs(ofp);
 		else if (strncmp(line, "%FILES.", 7) == 0)
@@ -613,6 +616,28 @@
 }
 
 static void
+do_without_modules(FILE *fp)
+{
+	struct device *dp;
+	int lpos, len;
+	char *cp, *sp;
+
+	fprintf(fp, "MKMODULESENV+= WITHOUT_MODULES=\"");
+	lpos = 34;
+	STAILQ_FOREACH(dp, &dtab, d_next) {
+		sp = dp->d_name;
+		cp = sp + (len = strlen(sp)) - 1;
+		if (len + lpos > 72) {
+			lpos = 8;
+			fprintf(fp, "\\\n\t");
+		}
+		fprintf(fp, "%s ", sp);
+		lpos += len + 1;
+	}
+	fprintf(fp, "\"\n");
+}
+
+static void
 do_xxfiles(char *tag, FILE *fp)
 {
 	struct file_list *tp;
Index: sys/conf/Makefile.alpha
===================================================================
RCS file: /home/ncvs/src/sys/conf/Makefile.alpha,v
retrieving revision 1.140
diff -u -r1.140 Makefile.alpha
--- sys/conf/Makefile.alpha	28 Nov 2005 17:51:30 -0000	1.140
+++ sys/conf/Makefile.alpha	26 Apr 2006 06:39:42 -0000
@@ -28,6 +28,8 @@
 .endif
 .include "$S/conf/kern.pre.mk"
 
+%WITHOUT_MODULES
+
 %BEFORE_DEPEND
 
 %OBJS
Index: sys/conf/Makefile.amd64
===================================================================
RCS file: /home/ncvs/src/sys/conf/Makefile.amd64,v
retrieving revision 1.22
diff -u -r1.22 Makefile.amd64
--- sys/conf/Makefile.amd64	28 Nov 2005 17:51:30 -0000	1.22
+++ sys/conf/Makefile.amd64	26 Apr 2006 06:39:42 -0000
@@ -38,6 +38,8 @@
 
 MKMODULESENV+= MACHINE=amd64
 
+%WITHOUT_MODULES
+
 %BEFORE_DEPEND
 
 %OBJS
Index: sys/conf/Makefile.arm
===================================================================
RCS file: /home/ncvs/src/sys/conf/Makefile.arm,v
retrieving revision 1.26
diff -u -r1.26 Makefile.arm
--- sys/conf/Makefile.arm	27 Mar 2006 00:32:46 -0000	1.26
+++ sys/conf/Makefile.arm	26 Apr 2006 06:39:42 -0000
@@ -94,6 +94,8 @@
 	rm ${KERNEL_KO}.tmp.gz ${KERNEL_KO}.tramp.noheader opt_kernname.h \
 	inflate-tramp.o
 
+%WITHOUT_MODULES
+
 %BEFORE_DEPEND
 
 %OBJS
Index: sys/conf/Makefile.i386
===================================================================
RCS file: /home/ncvs/src/sys/conf/Makefile.i386,v
retrieving revision 1.271
diff -u -r1.271 Makefile.i386
--- sys/conf/Makefile.i386	29 Jan 2006 03:32:19 -0000	1.271
+++ sys/conf/Makefile.i386	26 Apr 2006 06:39:42 -0000
@@ -34,6 +34,8 @@
 
 MKMODULESENV+=	MACHINE=${MACHINE}
 
+%WITHOUT_MODULES
+
 %BEFORE_DEPEND
 
 %OBJS
Index: sys/conf/Makefile.ia64
===================================================================
RCS file: /home/ncvs/src/sys/conf/Makefile.ia64,v
retrieving revision 1.67
diff -u -r1.67 Makefile.ia64
--- sys/conf/Makefile.ia64	28 Nov 2005 17:51:31 -0000	1.67
+++ sys/conf/Makefile.ia64	26 Apr 2006 06:39:42 -0000
@@ -38,6 +38,8 @@
 
 ASM_CFLAGS= -x assembler-with-cpp -Wa,-x -DLOCORE ${CFLAGS}
 
+%WITHOUT_MODULES
+
 %BEFORE_DEPEND
 
 %OBJS
Index: sys/conf/Makefile.pc98
===================================================================
RCS file: /home/ncvs/src/sys/conf/Makefile.pc98,v
retrieving revision 1.173
diff -u -r1.173 Makefile.pc98
--- sys/conf/Makefile.pc98	29 Jan 2006 03:32:19 -0000	1.173
+++ sys/conf/Makefile.pc98	26 Apr 2006 06:39:42 -0000
@@ -34,6 +34,8 @@
 
 MKMODULESENV+=	MACHINE=${MACHINE}
 
+%WITHOUT_MODULES
+
 %BEFORE_DEPEND
 
 %OBJS
Index: sys/conf/Makefile.powerpc
===================================================================
RCS file: /home/ncvs/src/sys/conf/Makefile.powerpc,v
retrieving revision 1.283
diff -u -r1.283 Makefile.powerpc
--- sys/conf/Makefile.powerpc	28 Nov 2005 17:51:31 -0000	1.283
+++ sys/conf/Makefile.powerpc	26 Apr 2006 06:39:42 -0000
@@ -37,6 +37,8 @@
 CFLAGS+=	-fno-omit-frame-pointer
 .endif
 
+%WITHOUT_MODULES
+
 %BEFORE_DEPEND
 
 %OBJS
Index: sys/conf/Makefile.sparc64
===================================================================
RCS file: /home/ncvs/src/sys/conf/Makefile.sparc64,v
retrieving revision 1.38
diff -u -r1.38 Makefile.sparc64
--- sys/conf/Makefile.sparc64	28 Nov 2005 17:51:31 -0000	1.38
+++ sys/conf/Makefile.sparc64	26 Apr 2006 06:39:42 -0000
@@ -32,6 +32,8 @@
 
 MDOBJS=	exception.o interrupt.o
 
+%WITHOUT_MODULES
+
 %BEFORE_DEPEND
 
 %OBJS
>Release-Note:
>Audit-Trail:

From: "Andrey V. Elsukov" <bu7cher@yandex.ru>
To: Robert Millan <rmh@aybabtu.com>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: kern/96346: [PATCH] disable build of modules that are already
 in	kernel image
Date: Wed, 26 Apr 2006 11:18:16 +0400

 Robert Millan wrote:
 >> Description:
 > 	Unless explicitly overriden, in a kernel build all modules are also built;
 > 	even those that are already part of the kernel image.  These modules are
 > 	useless since they can't be loaded.  My patch disables them.
 
 You can build a new kernel with -DNO_MODULES and reinstall it. In this 
 case you will lost modules, which you can have deleted from kernel.
 
 -- 
 WBR, Andrey V. Elsukov
 

From: Robert Millan <rmh@aybabtu.com>
To: "Andrey V. Elsukov" <bu7cher@yandex.ru>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: kern/96346: [PATCH] disable build of modules that are already in	kernel image
Date: Wed, 26 Apr 2006 09:27:12 +0200

 On Wed, Apr 26, 2006 at 11:18:16AM +0400, Andrey V. Elsukov wrote:
 > Robert Millan wrote:
 > >>Description:
 > >	Unless explicitly overriden, in a kernel build all modules are also 
 > >	built;
 > >	even those that are already part of the kernel image.  These modules 
 > >	are
 > >	useless since they can't be loaded.  My patch disables them.
 > 
 > You can build a new kernel with -DNO_MODULES and reinstall it. In this 
 > case you will lost modules, which you can have deleted from kernel.
 
 I don't understand.  Does -DNO_MODULES disable all modules, or just those that
 are already built in kernel?
 
 And if it disables only those in kernel, why isn't this enabled by default?
 
 Thanks,
 
 -- 
 Robert Millan

From: "Andrey V. Elsukov" <bu7cher@yandex.ru>
To: Robert Millan <rmh@aybabtu.com>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: kern/96346: [PATCH] disable build of modules that are already
 in	kernel image
Date: Wed, 26 Apr 2006 12:08:23 +0400

 Robert Millan wrote:
 > I don't understand.  Does -DNO_MODULES disable all modules, or just those that
 > are already built in kernel?
 
 No, NO_MODULES is a make option, that can made a kernel build much 
 faster. And command `make buildkernel reinstallkernel -DNO_MODULES 
 KERNCONF=SOMEKERNEL' can be used for the fast kernel reinstallation.
 You can remove some options from kernel and rebuild and reinstall it 
 without building modules. With your patch you will lost some modules in 
 this case.
 But i think that your option WITHOUT_MODULES can be usable for build of 
 some smallest systems based on FreeBSD.
 
 > And if it disables only those in kernel, why isn't this enabled by default?
 
 It disables all modules.
 
 -- 
 WBR, Andrey V. Elsukov
 

From: Robert Millan <rmh@aybabtu.com>
To: "Andrey V. Elsukov" <bu7cher@yandex.ru>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: kern/96346: [PATCH] disable build of modules that are already in	kernel image
Date: Wed, 26 Apr 2006 12:35:17 +0200

 On Wed, Apr 26, 2006 at 12:08:23PM +0400, Andrey V. Elsukov wrote:
 > Robert Millan wrote:
 > >I don't understand.  Does -DNO_MODULES disable all modules, or just those 
 > >that
 > >are already built in kernel?
 > 
 > No, NO_MODULES is a make option, that can made a kernel build much 
 > faster. And command `make buildkernel reinstallkernel -DNO_MODULES 
 > KERNCONF=SOMEKERNEL' can be used for the fast kernel reinstallation.
 > You can remove some options from kernel and rebuild and reinstall it 
 > without building modules. With your patch you will lost some modules in 
 > this case.
 > But i think that your option WITHOUT_MODULES can be usable for build of 
 > some smallest systems based on FreeBSD.
 > 
 > >And if it disables only those in kernel, why isn't this enabled by default?
 > 
 > It disables all modules.
 
 My concern is with disk space, rather than build time.  For example, when
 shipping modules in an mfsroot.gz, this is a big problem.  Even bigger when
 this is embedded system or old hardware with not much RAM.
 
 In my setup (which is very close to GENERIC), we could save ~4 MB by doing this.
 
 -- 
 Robert Millan
>Unformatted:
