Skip to content

Commit

Permalink
Ensure that the install media are built with a consistent set of
Browse files Browse the repository at this point in the history
compiler flags.  Pass DIST_CFLAGS from the crunchgen-generated .mk
file.

Compile the install media with -fno-unwind-tables to avoid emitting
.eh_frame sections.  This saves substantial space on amd64.

with/ok kettenis@
  • Loading branch information
naddy committed Oct 18, 2018
1 parent 91aac16 commit 24a45e1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion distrib/special/Makefile.inc
@@ -1,6 +1,6 @@
# options for all the directories below

COPTS+=-Oz -fno-stack-protector
COPTS+=-Oz -fno-stack-protector -fno-unwind-tables
MAN=
LDSTATIC=-static
NOPIE=
Expand Down
4 changes: 1 addition & 3 deletions share/mk/bsd.lib.mk
@@ -1,4 +1,4 @@
# $OpenBSD: bsd.lib.mk,v 1.93 2018/06/06 00:14:29 mortimer Exp $
# $OpenBSD: bsd.lib.mk,v 1.94 2018/10/18 14:25:14 naddy Exp $
# $NetBSD: bsd.lib.mk,v 1.67 1996/01/17 20:39:26 mycroft Exp $
# @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91

Expand Down Expand Up @@ -34,8 +34,6 @@ CXXFLAGS+= ${NOPIE_FLAGS}
AFLAGS+= ${NOPIE_FLAGS}
.endif

DIST_CFLAGS+= -Oz -fno-stack-protector

.c.o:
@echo "${COMPILE.c} ${.IMPSRC} -o ${.TARGET}"
@${COMPILE.c} ${DFLAGS} ${.IMPSRC} -o ${.TARGET}.o
Expand Down
7 changes: 5 additions & 2 deletions usr.sbin/crunchgen/crunchgen.c
@@ -1,4 +1,4 @@
/* $OpenBSD: crunchgen.c,v 1.20 2018/02/06 00:05:24 henning Exp $ */
/* $OpenBSD: crunchgen.c,v 1.21 2018/10/18 14:25:14 naddy Exp $ */

/*
* Copyright (c) 1994 University of Maryland
Expand Down Expand Up @@ -895,6 +895,8 @@ top_makefile_rules(FILE * outmk)
fprintf(outmk, ".include <bsd.own.mk>\n");
fprintf(outmk, "CFLAGS+=$(NOPIE_FLAGS)\n");
fprintf(outmk, "CFLAGS+=-Oz\n");
fprintf(outmk, "CFLAGS+=-fno-stack-protector\n");
fprintf(outmk, "CFLAGS+=-fno-unwind-tables\n");
fprintf(outmk, "LDFLAGS+=$(NOPIE_LDFLAGS)\n");
fprintf(outmk, "STRIP?=strip\n");
fprintf(outmk, "LINK=$(LD) -dc -r ${LDFLAGS}\n");
Expand Down Expand Up @@ -934,7 +936,8 @@ top_makefile_rules(FILE * outmk)
fprintf(outmk, ".olist.a:\n");
fprintf(outmk, "\t@rm -f ${.TARGET}\n");
fprintf(outmk, "\t@cd ${SRCLIBDIR}/${.PREFIX} &&\t\t\t\t\\\n");
fprintf(outmk, "\t${MAKE} DIST_OBJS=\"`cat ${.OBJDIR}/${.IMPSRC}`\"\t\t\\\n");
fprintf(outmk, "\t${MAKE} DIST_CFLAGS=\"${CFLAGS}\"\t\t\t\t\\\n");
fprintf(outmk, "\t DIST_OBJS=\"`cat ${.OBJDIR}/${.IMPSRC}`\"\t\t\\\n");
fprintf(outmk, "\t DIST_LIB=${.OBJDIR}/${.TARGET} ${.OBJDIR}/${.TARGET}\n\n");

fprintf(outmk, "%s.map: %s.o $(CRUNCHED_OBJS)\n", execfname, execfname);
Expand Down

0 comments on commit 24a45e1

Please sign in to comment.