Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Jan 2013 09:23:41 +0100
From:      Erik Cederstrand <erik@cederstrand.dk>
To:        "toolchain@freebsd.org" <toolchain@freebsd.org>
Subject:   [patch] DEBUG_FLAGS cleanup
Message-ID:  <0CBACA33-7420-4045-AD0C-852983CD64CF@cederstrand.dk>

index | next in thread | raw e-mail

[-- Attachment #1 --]
Hello folks,

Attached is a patch to clean up unconditional use of "-g" in Makefiles, instead respecting the global DEBUG_FLAGS setting.

I need this as part of my quest to support deterministic builds. Currently, debug information contains stuff like timestamps, absolute paths etc. that make binaries non-deterministic, and Clang lacks the necessary flags to rectify this. So I'd like DEBUG_FLAGS="" to actually work everywhere.

I'd be thankful for feedback and help committing the changes if it's OK.

Thanks,
Erik


[-- Attachment #2 --]
Index: head/usr.bin/tar/Makefile
===================================================================
--- head/usr.bin/tar/Makefile	(revision 242791)
+++ head/usr.bin/tar/Makefile	(working copy)
@@ -38,7 +38,6 @@
 CFLAGS+=	-I${LIBARCHIVEDIR}/libarchive_fe
 SYMLINKS=	bsdtar ${BINDIR}/tar
 MLINKS=	bsdtar.1 tar.1
-DEBUG_FLAGS=-g
 
 .PHONY: check test clean-test
 check test: $(PROG) bsdtar.1.gz
Index: head/gnu/usr.bin/cc/cc_tools/Makefile
===================================================================
--- head/gnu/usr.bin/cc/cc_tools/Makefile	(revision 242791)
+++ head/gnu/usr.bin/cc/cc_tools/Makefile	(working copy)
@@ -6,7 +6,7 @@
 
 .include "../Makefile.inc"
 
-CFLAGS+=	-g
+CFLAGS+=	$(DEBUG_FLAGS)
 CFLAGS+=	-DGENERATOR_FILE -DHAVE_CONFIG_H
 
 # Override LIBIBERTY set by Makefile.inc, We use our own for
Index: head/usr.sbin/bluetooth/bthidd/Makefile
===================================================================
--- head/usr.sbin/bluetooth/bthidd/Makefile	(revision 242791)
+++ head/usr.sbin/bluetooth/bthidd/Makefile	(working copy)
@@ -8,7 +8,6 @@
 		session.c
 
 CFLAGS+=	-I${.CURDIR}
-DEBUG_FLAGS=	-g
 
 DPADD=          ${LIBBLUETOOTH} ${LIBUSBHID}
 LDADD=		-lbluetooth -lusbhid
Index: head/lib/libufs/Makefile
===================================================================
--- head/lib/libufs/Makefile	(revision 242791)
+++ head/lib/libufs/Makefile	(working copy)
@@ -21,7 +21,6 @@
 
 WARNS?=	2
 
-DEBUG_FLAGS = -g
 CFLAGS+= -D_LIBUFS
 .if defined(LIBUFS_DEBUG)
 CFLAGS+= -D_LIBUFS_DEBUGGING
Index: head/crypto/openssl/crypto/Makefile
===================================================================
--- head/crypto/openssl/crypto/Makefile	(revision 242791)
+++ head/crypto/openssl/crypto/Makefile	(working copy)
@@ -8,7 +8,7 @@
 INCLUDE=	-I. -I$(TOP) -I../include $(ZLIB_INCLUDE)
 # INCLUDES targets sudbirs!
 INCLUDES=	-I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include $(ZLIB_INCLUDE)
-CFLAG=		-g
+CFLAG=		$(DEBUG_FLAGS)
 MAKEDEPPROG=	makedepend
 MAKEDEPEND=	$(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
 MAKEFILE=       Makefile
Index: head/contrib/gcc/Makefile.in
===================================================================
--- head/contrib/gcc/Makefile.in	(revision 242791)
+++ head/contrib/gcc/Makefile.in	(working copy)
@@ -154,9 +154,9 @@
 TCFLAGS =
 CFLAGS = @CFLAGS@
 LDFLAGS = @LDFLAGS@
-STAGE1_CFLAGS = -g @stage1_cflags@
+STAGE1_CFLAGS = $(DEBUG_FLAGS) @stage1_cflags@
 STAGE1_CHECKING_CFLAGS = -DENABLE_CHECKING -DENABLE_ASSERT_CHECKING
-BOOT_CFLAGS = -g -O2
+BOOT_CFLAGS = $(DEBUG_FLAGS) -O2
 
 # Flags to determine code coverage. When coverage is disabled, this will
 # contain the optimization flags, as you normally want code coverage
@@ -553,7 +553,7 @@
 
 # Options to use when compiling libgcc2.a.
 #
-LIBGCC2_DEBUG_CFLAGS = -g
+LIBGCC2_DEBUG_CFLAGS = $(DEBUG_FLAGS)
 LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(TARGET_LIBGCC2_CFLAGS) \
 		 $(LIBGCC2_DEBUG_CFLAGS) $(GTHREAD_FLAGS) \
 		 -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED \
Index: head/contrib/gdtoa/makefile
===================================================================
--- head/contrib/gdtoa/makefile	(revision 242791)
+++ head/contrib/gdtoa/makefile	(working copy)
@@ -25,7 +25,7 @@
 
 .SUFFIXES: .c .o
 CC = cc
-CFLAGS = -g
+CFLAGS = $(DEBUG_FLAGS)
 
 .c.o:
 	$(CC) -c $(CFLAGS) $*.c
Index: head/cddl/usr.bin/ctfconvert/Makefile
===================================================================
--- head/cddl/usr.bin/ctfconvert/Makefile	(revision 242791)
+++ head/cddl/usr.bin/ctfconvert/Makefile	(working copy)
@@ -3,8 +3,6 @@
 .PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/tools/ctf/common
 .PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/tools/ctf/cvt
 
-DEBUG_FLAGS=	-g
-
 PROG=		ctfconvert
 SRCS=		alist.c \
 		ctf.c \
Index: head/cddl/usr.sbin/lockstat/Makefile
===================================================================
--- head/cddl/usr.sbin/lockstat/Makefile	(revision 242791)
+++ head/cddl/usr.sbin/lockstat/Makefile	(working copy)
@@ -18,7 +18,7 @@
 		-I${OPENSOLARIS_SYS_DISTDIR}/compat \
 		-I${.CURDIR}/../../../sys
 
-CFLAGS+=	-DNEED_ERRLOC -g
+CFLAGS+=	-DNEED_ERRLOC $(DEBUG_FLAGS)
 
 #YFLAGS+=	-d
 
Index: head/sys/modules/sfxge/Makefile
===================================================================
--- head/sys/modules/sfxge/Makefile	(revision 242822)
+++ head/sys/modules/sfxge/Makefile	(working copy)
@@ -20,6 +20,6 @@
SRCS+=	siena_mac.c siena_nic.c siena_nvram.c siena_phy.c
SRCS+=	siena_sram.c siena_vpd.c 

-DEBUG_FLAGS= -g -DDEBUG=1
+DEBUG_FLAGS+= -DDEBUG=1

.include <bsd.kmod.mk>
Index: head/sys/modules/cxgb/cxgb/Makefile
===================================================================
--- head/sys/modules/cxgb/cxgb/Makefile	(revision 242822)
+++ head/sys/modules/cxgb/cxgb/Makefile	(working copy)
@@ -13,7 +13,7 @@
SRCS+=	opt_inet.h opt_inet6.h opt_zero.h opt_sched.h
SRCS+=	uipc_mvec.c

-CFLAGS+= -g -DDEFAULT_JUMBO -I${CXGB}
+CFLAGS+= ${DEBUG_FLAGS} -DDEFAULT_JUMBO -I${CXGB}

.if !defined(KERNBUILDDIR)
.if ${MK_INET_SUPPORT} != "no"
Index: head/sys/modules/cxgb/cxgb_t3fw/Makefile
===================================================================
--- head/sys/modules/cxgb/cxgb_t3fw/Makefile	(revision 242822)
+++ head/sys/modules/cxgb/cxgb_t3fw/Makefile	(working copy)
@@ -1,10 +1,12 @@
# $FreeBSD$

+.include <bsd.own.mk>
+
CXGB = ${.CURDIR}/../../../dev/cxgb
.PATH: ${CXGB} 

KMOD= cxgb_t3fw
SRCS+= cxgb_t3fw.c
-CFLAGS+= -g -I${CXGB}
+CFLAGS+= ${DEBUG_FLAGS} -I${CXGB}

.include <bsd.kmod.mk>
help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0CBACA33-7420-4045-AD0C-852983CD64CF>