tech-toolchain archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: evbarm build using exorbitant disk space during build
I implemented something similar (but slightly different).
Attached patch to config does:
- rename the undocumented parser debug option from -D to -d
- add -U and -D options used to define or undefine "makeoptions"
via the command line
Then the build system patch uses config -U DEBUG in etc/Makefile when
configuring the release build kernels and provides a new kernel.gdb=MYCONF
action for build.sh.
The third patch to the kernel makefile provides a new variable
KERNEL_DEBUG_INFO, which is used (if defined) as default value
for DEBUG in kernel builds - so adding KERNEL_DEBUG_INFO=-g to
/etc/mk.conf makes all kernel builds always create netbsd.gdb.
Comments?
Martin
Index: config.1
===================================================================
RCS file: /cvsroot/src/usr.bin/config/config.1,v
retrieving revision 1.13
diff -u -p -r1.13 config.1
--- config.1 30 Aug 2012 12:42:41 -0000 1.13
+++ config.1 2 May 2014 12:33:59 -0000
@@ -40,6 +40,8 @@
.Op Fl Ppv
.Op Fl b Ar builddir
.Op Fl s Ar srcdir
+.Op Fl D Ar var=value
+.Op Fl U Ar value
.Op Ar config-file
.Nm
.Fl x
@@ -109,6 +111,11 @@ Use
.Ar builddir
as the kernel build directory, instead of computing and creating one
automatically.
+.It Fl D Ar var=value
+Define a makeoptions variable to the given value.
+This is equivalent to appending a
+.Li makeoptions var=value
+line to the config file.
.It Fl L
Generate a lint configuration.
See section
@@ -131,6 +138,12 @@ is used to prepare a kernel build direct
when it is used in combination with the
.Fl L
flag.
+.It Fl U Ar var
+Undefine the makeoption
+.Ar var .
+This is equivalent to appending the line
+.Li no makeoptions var
+to the config file.
.It Fl v
Increase verbosity by enabling some more warnings.
.It Fl x
Index: defs.h
===================================================================
RCS file: /cvsroot/src/usr.bin/config/defs.h,v
retrieving revision 1.44
diff -u -p -r1.44 defs.h
--- defs.h 8 Jun 2012 08:56:45 -0000 1.44
+++ defs.h 2 May 2014 12:33:59 -0000
@@ -107,7 +107,7 @@ extern const char *progname;
* The next two lines define the current version of the config(1) binary,
* and the minimum version of the configuration files it supports.
*/
-#define CONFIG_VERSION 20100430
+#define CONFIG_VERSION 20140502
#define CONFIG_MINVERSION 0
/*
Index: main.c
===================================================================
RCS file: /cvsroot/src/usr.bin/config/main.c,v
retrieving revision 1.51
diff -u -p -r1.51 main.c
--- main.c 1 Nov 2013 21:39:13 -0000 1.51
+++ main.c 2 May 2014 12:33:59 -0000
@@ -86,6 +86,7 @@ COPYRIGHT("@(#) Copyright (c) 1992, 1993
int vflag; /* verbose output */
int Pflag; /* pack locators */
int Lflag; /* lint config generation */
+int handling_cmdlineopts; /* currently processing -D/-U options */
int yyparse(void);
@@ -100,6 +101,7 @@ static struct nvlist **nextmkopt;
static struct nvlist **nextappmkopt;
static struct nvlist **nextcndmkopt;
static struct nvlist **nextfsopt;
+static struct nvlist *cmdlinedefs, *cmdlineundefs;
static void usage(void) __dead;
static void dependopts(void);
@@ -119,6 +121,9 @@ static int mkident(void);
static int devbase_has_dead_instances(const char *, void *, void *);
static int devbase_has_any_instance(struct devbase *, int, int, int);
static int check_dead_devi(const char *, void *, void *);
+static void add_makeopt(const char *);
+static void remove_makeopt(const char *);
+static void handle_cmdline_makeoptions(void);
static void kill_orphans(void);
static void do_kill_orphans(struct devbase *, struct attr *,
struct devbase *, int);
@@ -155,11 +160,11 @@ main(int argc, char **argv)
pflag = 0;
xflag = 0;
- while ((ch = getopt(argc, argv, "DLPgpvb:s:x")) != -1) {
+ while ((ch = getopt(argc, argv, "D:LPU:dgpvb:s:x")) != -1) {
switch (ch) {
#ifndef MAKE_BOOTSTRAP
- case 'D':
+ case 'd':
yydebug = 1;
break;
#endif
@@ -179,7 +184,7 @@ main(int argc, char **argv)
* do that for you, but you really should just
* put them in the config file.
*/
- warnx("-g is obsolete (use makeoptions DEBUG=\"-g\")");
+ warnx("-g is obsolete (use -D DEBUG=\"-g\")");
usage();
/*NOTREACHED*/
@@ -213,6 +218,14 @@ main(int argc, char **argv)
xflag = 1;
break;
+ case 'D':
+ add_makeopt(optarg);
+ break;
+
+ case 'U':
+ remove_makeopt(optarg);
+ break;
+
case '?':
default:
usage();
@@ -386,6 +399,11 @@ main(int argc, char **argv)
unlink(cname);
/*
+ * Handle command line overrides
+ */
+ handle_cmdline_makeoptions();
+
+ /*
* Detect and properly ignore orphaned devices
*/
kill_orphans();
@@ -469,6 +487,7 @@ static void
usage(void)
{
(void)fprintf(stderr, "Usage: %s [-Ppv] [-s srcdir] [-b builddir] "
+ "[-D var=value] [-U var] "
"[config-file]\n\t%s -x [kernel-file]\n"
"\t%s -L [-v] [-s srcdir] [config-file]\n",
getprogname(), getprogname(), getprogname());
@@ -1071,6 +1090,11 @@ undo_option(struct hashtab *ht, struct n
struct nvlist *nv;
if (ht_remove(ht, name)) {
+ /*
+ * -U command line option removals are always silent
+ */
+ if (handling_cmdlineopts)
+ return 0;
cfgerror("%s `%s' is not defined", type, name);
return (1);
}
@@ -1770,3 +1794,56 @@ kill_orphans(void)
{
ht_enumerate(devroottab, kill_orphans_cb, NULL);
}
+
+static void
+add_makeopt(const char *opt)
+{
+ struct nvlist *p;
+ char *buf = estrdup(opt);
+ char *eq = strchr(buf, '=');
+
+ if (!eq)
+ errx(EXIT_FAILURE, "-D %s is not in var=value format", opt);
+
+ *eq = 0;
+ p = newnv(estrdup(buf), estrdup(eq+1), NULL, 0, NULL);
+ free(buf);
+ p->nv_next = cmdlinedefs;
+ cmdlinedefs = p;
+}
+
+static void
+remove_makeopt(const char *opt)
+{
+ struct nvlist *p;
+
+ p = newnv(estrdup(opt), NULL, NULL, 0, NULL);
+ p->nv_next = cmdlineundefs;
+ cmdlineundefs = p;
+}
+
+static void
+handle_cmdline_makeoptions(void)
+{
+ struct nvlist *p, *n;
+
+ handling_cmdlineopts = 1;
+ for (p = cmdlineundefs; p; p = n) {
+ n = p->nv_next;
+ delmkoption(intern(p->nv_name));
+ free(__UNCONST(p->nv_name));
+ nvfree(p);
+ }
+ for (p = cmdlinedefs; p; p = n) {
+ const char *name = intern(p->nv_name);
+
+ n = p->nv_next;
+ delmkoption(name);
+ addmkoption(name, intern(p->nv_str));
+ free(__UNCONST(p->nv_name));
+ free(__UNCONST(p->nv_str));
+
+ nvfree(p);
+ }
+ handling_cmdlineopts = 0;
+}
Index: build.sh
===================================================================
RCS file: /cvsroot/src/build.sh,v
retrieving revision 1.280
diff -u -r1.280 build.sh
--- build.sh 29 Apr 2014 11:52:51 -0000 1.280
+++ build.sh 2 May 2014 12:34:47 -0000
@@ -922,6 +922,8 @@
install=idir Run "make installworld" to \`idir' to install all sets
except \`etc'. Useful after "distribution" or
"release"
kernel=conf Build kernel with config file \`conf'
+ kernel.gdb=conf Build kernel (including netbsd.gdb) with config
+ file \`conf'
releasekernel=conf Install kernel built by kernel=conf to RELEASEDIR.
installmodules=idir Run "make installmodules" to \`idir' to install all
kernel modules.
@@ -1220,7 +1222,7 @@
op=install_image # used as part of a variable name
;;
- kernel=*|releasekernel=*)
+ kernel=*|releasekernel=*|kernel.gdb=*)
arg=${op#*=}
op=${op%%=*}
[ -n "${arg}" ] ||
@@ -1861,7 +1863,7 @@
[ -x "${TOOLDIR}/bin/${toolprefix}config" ] \
|| bomb "${TOOLDIR}/bin/${toolprefix}config does not exist. You need to
\"$0 tools\" first."
${runcmd} "${TOOLDIR}/bin/${toolprefix}config" -b "${kernelbuildpath}" \
- -s "${TOP}/sys" "${kernelconfpath}" ||
+ ${ksymopts} -s "${TOP}/sys" "${kernelconfpath}" ||
bomb "${toolprefix}config failed for ${kernelconf}"
make_in_dir "${kernelbuildpath}" depend
make_in_dir "${kernelbuildpath}" all
@@ -2100,7 +2102,11 @@
arg=${op#*=}
buildkernel "${arg}"
;;
-
+ kernel.gdb=*)
+ arg=${op#*=}
+ ksymopts="-D DEBUG=-g"
+ buildkernel "${arg}"
+ ;;
releasekernel=*)
arg=${op#*=}
releasekernel "${arg}"
Index: etc/Makefile
===================================================================
RCS file: /cvsroot/src/etc/Makefile,v
retrieving revision 1.412
diff -u -r1.412 Makefile
--- etc/Makefile 27 Jan 2014 21:37:17 -0000 1.412
+++ etc/Makefile 2 May 2014 12:34:47 -0000
@@ -558,7 +558,7 @@
build_kernels: kern-${configfile}
kern-${configfile}: .PHONY .MAKE
cd ${KERNCONFDIR} && ${TOOL_CONFIG} -s ${KERNSRCDIR} \
- -b ${KERNOBJDIR}/${configfile:C/.*\///} ${configfile}
+ -U DEBUG -b ${KERNOBJDIR}/${configfile:C/.*\///} ${configfile}
.if ${MKUPDATE} == "no"
cd ${KERNOBJDIR}/${configfile:C/.*\///} && ${MAKE} distclean
.endif
Index: Makefile.kern.inc
===================================================================
RCS file: /cvsroot/src/sys/conf/Makefile.kern.inc,v
retrieving revision 1.167
diff -u -r1.167 Makefile.kern.inc
--- Makefile.kern.inc 10 Mar 2014 02:36:50 -0000 1.167
+++ Makefile.kern.inc 2 May 2014 12:35:40 -0000
@@ -17,6 +17,11 @@
#
# all ports are expected to include bsd.own.mk for toolchain settings
+# Default DEBUG to KERNEL_DEBUG_INFO if set
+.if defined(KERNEL_DEBUG_INFO)
+DEBUG?=${KERNEL_DEBUG_INFO}
+.endif
+
##
## (0) toolchain settings for things that aren't part of the standard
## toolchain
Home |
Main Index |
Thread Index |
Old Index