Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

sys.mk broken for single-suffix rules since 1.144 (2021/11/09)



I just noticed that on my recently upgraded -current machines that I
couldn't build simple programs from single source files with a
"portable" Makefile any more.

Instead the program binaries were being put into foo.o files!

It looks like rev. 1.144 of sys.mk was a bit too over-zealous.

I'll send this as a PR also, but perhaps those running -current on
development machines might need a more urgent fix.

Here are my patches that include the fix, and also clean up the use of
various flags in LINK.* (remove CPPFLAGS and add LDSTATIC) and introduce
COMPILE_LINK.* macros to be used with the direct source to target binary
rules (single-suffix rules) such as ".c:" (and finally also split the
settings for debugger and optimizer flags).

The key parts are to revert the change to use ${OBJECT_TARGET} in the
single-suffix rules like ".c:" since ctfconvert(1) won't work on
(static?) linked binaries, and because of course we still need the
final output file to be the filename _without_ any suffix!

Index: sys.mk
===================================================================
RCS file: /cvs/master/m-NetBSD/main/src/share/mk/sys.mk,v
retrieving revision 1.144
diff -u -u -r1.144 sys.mk
--- sys.mk	9 Nov 2020 16:15:05 -0000	1.144
+++ sys.mk	21 Mar 2021 23:25:00 -0000
@@ -19,30 +19,35 @@
 AS?=		as
 AFLAGS?=
 COMPILE.s?=	${CC} ${AFLAGS} ${AFLAGS.${<:T}} -c
-LINK.s?=	${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${LDFLAGS}
+LINK.s?=	${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${LDSTATIC} ${LDFLAGS}
 _ASM_TRADITIONAL_CPP=	-x assembler-with-cpp
 COMPILE.S?=	${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} ${_ASM_TRADITIONAL_CPP} -c
-LINK.S?=	${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} ${LDFLAGS}
+LINK.S?=	${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${LDSTATIC} ${LDFLAGS}
+COMPILE_LINK.S?=${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} ${_ASM_TRADITIONAL_CPP} ${LDSTATIC} ${LDFLAGS}

 CC?=		cc
 .if ${MACHINE_ARCH} == "sh3el" || ${MACHINE_ARCH} == "sh3eb"
 # -O2 is too -falign-* zealous for low-memory sh3 machines
-DBG?=	-Os -freorder-blocks
+OPTIM?=	-Os -freorder-blocks
 .elif ${MACHINE_ARCH} == "m68k" || ${MACHINE_ARCH} == "m68000"
 # -freorder-blocks (enabled by -O2) produces much bigger code
-DBG?=	-O2 -fno-reorder-blocks
+OPTIM?=	-O2 -fno-reorder-blocks
 .elif ${MACHINE_ARCH} == "coldfire"
+OPTIM?=	-O1
 DBG?=	-O1
 .else
-DBG?=	-O2
+OPTIM?=	-O2
 .endif
+DBG?=		# nothing -- just defined
+
 .if ${MKDTRACE:Uno} != "no"
 DTRACE_OPTS?=	-fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-ipa-sra -fno-ipa-icf
 .endif
-CFLAGS?=	${DBG}
+CFLAGS?=	${OPTIM} ${DBG}
 LDFLAGS?=
 COMPILE.c?=	${CC} ${CFLAGS} ${DTRACE_OPTS} ${CPPFLAGS} -c
-LINK.c?=	${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
+LINK.c?=	${CC} ${CFLAGS} ${LDSTATIC} ${LDFLAGS}
+COMPILE_LINK.c?=${CC} ${CFLAGS} ${DTRACE_OPTS} ${CPPFLAGS} ${LDSTATIC} ${LDFLAGS}

 # C Type Format data is required for DTrace
 CTFFLAGS	?=	-g -L VERSION
@@ -67,12 +72,14 @@
 _CXXSEED?=	${BUILDSEED:D-frandom-seed=${__BUILDSEED:hash}}

 COMPILE.cc?=	${CXX} ${_CXXSEED} ${CXXFLAGS} ${DTRACE_OPTS} ${CPPFLAGS} -c
-LINK.cc?=	${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
+LINK.cc?=	${CXX} ${CXXFLAGS} ${LDSTATIC} ${LDFLAGS}
+COMPILE_LINK.cc?=${CXX} ${_CXXSEED} ${CXXFLAGS} ${DTRACE_OPTS} ${CPPFLAGS} ${LDSTATIC} ${LDFLAGS}

 OBJC?=		${CC}
 OBJCFLAGS?=	${CFLAGS}
 COMPILE.m?=	${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
-LINK.m?=	${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}
+LINK.m?=	${OBJC} ${OBJCFLAGS} ${LDSTATIC} ${LDFLAGS}
+COMPILE_LINK.m?=${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDSTATIC} ${LDFLAGS}

 CPP?=		cpp
 CPPFLAGS?=
@@ -81,14 +88,19 @@
 FFLAGS?=	-O
 RFLAGS?=
 COMPILE.f?=	${FC} ${FFLAGS} -c
-LINK.f?=	${FC} ${FFLAGS} ${LDFLAGS}
+LINK.f?=	${FC} ${FFLAGS} ${LDSTATIC} ${LDFLAGS}
+COMPILE_LINK.f?=${FC} ${FFLAGS} ${CPPFLAGS} ${LDSTATIC} ${LDFLAGS}
 COMPILE.F?=	${FC} ${FFLAGS} ${CPPFLAGS} -c
-LINK.F?=	${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
+LINK.F?=	${FC} ${FFLAGS} ${LDSTATIC} ${LDFLAGS}
+COMPILE_LINK.F?=${FC} ${FFLAGS} ${CPPFLAGS} ${LDSTATIC} ${LDFLAGS}
 COMPILE.r?=	${FC} ${FFLAGS} ${RFLAGS} -c
-LINK.r?=	${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
+LINK.r?=	${FC} ${FFLAGS} ${LDSTATIC} ${LDFLAGS}
+COMPILE_LINK.r?=${FC} ${FFLAGS} ${CPPFLAGS} ${LDSTATIC} ${LDFLAGS}

 INSTALL?=	install

+MV?=		mv
+
 LD?=		ld

 LEX?=		lex
@@ -107,7 +119,8 @@
 PC?=		pc
 PFLAGS?=
 COMPILE.p?=	${PC} ${PFLAGS} ${CPPFLAGS} -c
-LINK.p?=	${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
+LINK.p?=	${PC} ${PFLAGS} ${LDSTATIC} ${LDFLAGS}
+COMPILE_LINK.p?=${PC} ${PFLAGS} ${CPPFLAGS} ${LDSTATIC} ${LDFLAGS}

 SHELL?=		sh

@@ -121,7 +134,7 @@

 # C
 .c:
-	${LINK.c} ${OBJECT_TARGET} ${.IMPSRC} ${LDLIBS}
+	${COMPILE_LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
 # XXX: disable for now
 #	${CTFCONVERT_RUN}
 .c.o:
@@ -138,7 +151,7 @@

 # C++
 .cc .cpp .cxx .C:
-	${LINK.cc} ${OBJECT_TARGET} ${.IMPSRC} ${LDLIBS}
+	${COMPILE_LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
 # XXX: disable for now
 #	${CTFCONVERT_RUN}
 .cc.o .cpp.o .cxx.o .C.o:
@@ -151,8 +164,9 @@

 # Fortran/Ratfor
 .f:
-	${LINK.f} ${OBJECT_TARGET} ${.IMPSRC} ${LDLIBS}
-	${CTFCONVERT_RUN}
+	${COMPILE_LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+# XXX: disable for now
+#	${CTFCONVERT_RUN}
 .f.o:
 	${COMPILE.f} ${.IMPSRC} ${OBJECT_TARGET}
 	${CTFCONVERT_RUN}
@@ -162,8 +176,9 @@
 	rm -f ${.PREFIX}.o

 .F:
-	${LINK.F} ${OBJECT_TARGET} ${.IMPSRC} ${LDLIBS}
-	${CTFCONVERT_RUN}
+	${COMPILE_LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+# XXX: disable for now
+#	${CTFCONVERT_RUN}
 .F.o:
 	${COMPILE.F} ${.IMPSRC} ${OBJECT_TARGET}
 	${CTFCONVERT_RUN}
@@ -173,8 +188,9 @@
 	rm -f ${.PREFIX}.o

 .r:
-	${LINK.r} ${OBJECT_TARGET} ${.IMPSRC} ${LDLIBS}
-	${CTFCONVERT_RUN}
+	${COMPILE_LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+# XXX: disable for now
+#	${CTFCONVERT_RUN}
 .r.o:
 	${COMPILE.r} ${.IMPSRC} ${OBJECT_TARGET}
 	${CTFCONVERT_RUN}
@@ -185,8 +201,9 @@

 # Pascal
 .p:
-	${LINK.p} ${OBJECT_TARGET} ${.IMPSRC} ${LDLIBS}
-	${CTFCONVERT_RUN}
+	${COMPILE_LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+# XXX: disable for now
+#	${CTFCONVERT_RUN}
 .p.o:
 	${COMPILE.p} ${.IMPSRC} ${OBJECT_TARGET}
 	${CTFCONVERT_RUN}
@@ -197,8 +214,9 @@

 # Assembly
 .s:
-	${LINK.s} ${OBJECT_TARGET} ${.IMPSRC} ${LDLIBS}
-	${CTFCONVERT_RUN}
+	${COMPILE_LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+# XXX: disable for now
+#	${CTFCONVERT_RUN}
 .s.o:
 	${COMPILE.s} ${.IMPSRC} ${OBJECT_TARGET}
 	${CTFCONVERT_RUN}
@@ -207,8 +225,9 @@
 	${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o
 	rm -f ${.PREFIX}.o
 .S:
-	${LINK.S} ${OBJECT_TARGET} ${.IMPSRC} ${LDLIBS}
-	${CTFCONVERT_RUN}
+	${COMPILE_LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+# XXX: disable for now
+#	${CTFCONVERT_RUN}
 .S.o:
 	${COMPILE.S} ${.IMPSRC} ${OBJECT_TARGET}
 	${CTFCONVERT_RUN}
@@ -220,8 +239,9 @@
 # Lex
 .l:
 	${LEX.l} ${.IMPSRC}
-	${LINK.c} ${OBJECT_TARGET} lex.yy.c ${LDLIBS} -ll
-	${CTFCONVERT_RUN}
+	${COMPILE_LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
+# XXX: disable for now
+#	${CTFCONVERT_RUN}
 	rm -f lex.yy.c
 .l.c:
 	${LEX.l} ${.IMPSRC}
@@ -235,8 +255,9 @@
 # Yacc
 .y:
 	${YACC.y} ${.IMPSRC}
-	${LINK.c} ${OBJECT_TARGET} y.tab.c ${LDLIBS}
-	${CTFCONVERT_RUN}
+	${COMPILE_LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
+# XXX: disable for now
+#	${CTFCONVERT_RUN}
 	rm -f y.tab.c
 .y.c:
 	${YACC.y} ${.IMPSRC}

--
					Greg A. Woods <gwoods%acm.org@localhost>

Kelowna, BC     +1 250 762-7675           RoboHack <woods%robohack.ca@localhost>
Planix, Inc. <woods%planix.com@localhost>     Avoncote Farms <woods%avoncote.ca@localhost>

Attachment: pgpbvgj6_lHHp.pgp
Description: OpenPGP Digital Signature



Home | Main Index | Thread Index | Old Index