git: 979864eef41b - stable/13 - Use .pieo extension for WITH_PIE bsd.prog.mk output
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 05 May 2025 09:38:47 UTC
The branch stable/13 has been updated by dim:
URL: https://cgit.FreeBSD.org/src/commit/?id=979864eef41b5f8e4d201c2b37e0733c33cf41b2
commit 979864eef41b5f8e4d201c2b37e0733c33cf41b2
Author: Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-04-21 19:52:29 +0000
Commit: Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2025-05-05 08:59:30 +0000
Use .pieo extension for WITH_PIE bsd.prog.mk output
When object files for programs are built using bsd.prog.mk, and WITH_PIE
is enabled, the extension used is still plain ".o". To be consistent
with bsd.lib.mk, and to allow changes in WITH_PIE settings to propagate
correctly, the extension should be ".pieo" instead.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D49966
(cherry picked from commit 245bb0110639fe963086fb2903143dbd4e6ac48c)
---
share/mk/bsd.prog.mk | 15 ++++++++-------
share/mk/bsd.progs.mk | 2 +-
tests/sys/fs/fusefs/Makefile | 8 +++++++-
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk
index 8c7de9be4093..ee6282de4f8a 100644
--- a/share/mk/bsd.prog.mk
+++ b/share/mk/bsd.prog.mk
@@ -4,7 +4,7 @@
.include <bsd.compiler.mk>
.include <bsd.linker.mk>
-.SUFFIXES: .out .o .bc .c .cc .cpp .cxx .C .m .y .l .ll .ln .s .S .asm
+.include <bsd.suffixes-extra.mk>
# XXX The use of COPTS in modern makefiles is discouraged.
.if defined(COPTS)
@@ -47,13 +47,14 @@ LDFLAGS+= -Wl,-znorelro
LDFLAGS+= -Wl,-zrelro
.endif
.endif
-.if ${MK_PIE} != "no"
# Static PIE is not yet supported/tested.
-.if !defined(NO_SHARED) || ${NO_SHARED:tl} == "no"
+.if ${MK_PIE} != "no" && (!defined(NO_SHARED) || ${NO_SHARED:tl} == "no")
CFLAGS+= -fPIE
CXXFLAGS+= -fPIE
LDFLAGS+= -pie
-.endif
+OBJ_EXT=pieo
+.else
+OBJ_EXT=o
.endif
.if ${MK_RETPOLINE} != "no"
.if ${COMPILER_FEATURES:Mretpoline} && ${LINKER_FEATURES:Mretpoline}
@@ -149,7 +150,7 @@ PROGNAME?= ${PROG}
.if defined(SRCS)
-OBJS+= ${SRCS:N*.h:${OBJS_SRCS_FILTER:ts:}:S/$/.o/g}
+OBJS+= ${SRCS:N*.h:${OBJS_SRCS_FILTER:ts:}:S/$/.${OBJ_EXT}/g}
# LLVM bitcode / textual IR representations of the program
BCOBJS+=${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.bco/g}
@@ -185,10 +186,10 @@ SRCS= ${PROG}.c
# - the name of the object gets put into the executable symbol table instead of
# the name of a variable temporary object.
# - it's useful to keep objects around for crunching.
-OBJS+= ${PROG}.o
+OBJS+= ${PROG}.${OBJ_EXT}
BCOBJS+= ${PROG}.bc
LLOBJS+= ${PROG}.ll
-CLEANFILES+= ${PROG}.o ${PROG}.bc ${PROG}.ll
+CLEANFILES+= ${PROG}.${OBJ_EXT} ${PROG}.bc ${PROG}.ll
.if target(beforelinking)
beforelinking: ${OBJS}
diff --git a/share/mk/bsd.progs.mk b/share/mk/bsd.progs.mk
index f86e95bed749..15e359ac72c0 100644
--- a/share/mk/bsd.progs.mk
+++ b/share/mk/bsd.progs.mk
@@ -109,7 +109,7 @@ _PROGS_ALL_SRCS+= ${s}
.if !empty(_PROGS_COMMON_SRCS)
_PROGS_COMMON_OBJS= ${_PROGS_COMMON_SRCS:M*.[dhly]}
.if !empty(_PROGS_COMMON_SRCS:N*.[dhly])
-_PROGS_COMMON_OBJS+= ${_PROGS_COMMON_SRCS:N*.[dhly]:${OBJS_SRCS_FILTER:ts:}:S/$/.o/g}
+_PROGS_COMMON_OBJS+= ${_PROGS_COMMON_SRCS:N*.[dhly]:${OBJS_SRCS_FILTER:ts:}:S/$/.${OBJ_EXT}/g}
.endif
.endif
diff --git a/tests/sys/fs/fusefs/Makefile b/tests/sys/fs/fusefs/Makefile
index 8e6fdd10c377..c5101be6026f 100644
--- a/tests/sys/fs/fusefs/Makefile
+++ b/tests/sys/fs/fusefs/Makefile
@@ -57,6 +57,7 @@ GTESTS+= xattr
.for p in ${GTESTS}
SRCS.$p+= ${p}.cc
SRCS.$p+= getmntopts.c
+SRCS.$p+= mntopts.h
SRCS.$p+= mockfs.cc
SRCS.$p+= utils.cc
.endfor
@@ -88,9 +89,14 @@ CXXWARNFLAGS+= -Wno-vla-cxx-extension
CXXFLAGS+= -I${SRCTOP}/tests
CXXFLAGS+= -I${FUSEFS}
CXXFLAGS+= -I${MOUNT}
-.PATH: ${MOUNT}
CXXSTD= c++14
+.for f in getmntopts.c mntopts.h
+CLEANFILES+= ${f}
+${f}: ${MOUNT}/${f} .NOMETA
+ ln -sf ${.ALLSRC} ${.TARGET}
+.endfor
+
LIBADD+= pthread
LIBADD+= gmock gtest
LIBADD+= util