The branch main has been updated by brooks:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=9c20010361854a6034595fdb13cd3583ea13f289

commit 9c20010361854a6034595fdb13cd3583ea13f289
Author:     Brooks Davis <bro...@freebsd.org>
AuthorDate: 2025-05-23 23:35:21 +0000
Commit:     Brooks Davis <bro...@freebsd.org>
CommitDate: 2025-05-23 23:38:06 +0000

    share/mk: pass SHARED_CFLAGS to PIC and PIE from assembly
    
    This matches what we do with C sources.  Document SHARED_CFLAGS.
    
    PR:             286975
    Reviewed by:    jhb, emaste
    Sponsored by:   DARPA, AFRL
    Differential Revision:  https://reviews.freebsd.org/D50466
---
 share/mk/bsd.README            |  3 +++
 share/mk/bsd.suffixes-extra.mk | 10 ++++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/share/mk/bsd.README b/share/mk/bsd.README
index c2326a17f03c..4820bf12c72d 100644
--- a/share/mk/bsd.README
+++ b/share/mk/bsd.README
@@ -197,6 +197,9 @@ LIBADD              Additional libraries.  This is for base 
system libraries
 LIBADD.${.TARGET:T}
                Libraries dependent on output file name.
 
+SHARED_CFLAGS  Additional compiler flags used when creating shared or
+               position independent object files.
+
 COMPILER_FEATURES
                A list of features that the compiler supports. Zero or
                more of:
diff --git a/share/mk/bsd.suffixes-extra.mk b/share/mk/bsd.suffixes-extra.mk
index 680abfc88eb4..e27c9ad318e6 100644
--- a/share/mk/bsd.suffixes-extra.mk
+++ b/share/mk/bsd.suffixes-extra.mk
@@ -60,12 +60,13 @@ PIEFLAG?=-fpie
 
 .asm.pico:
        ${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PICFLAG} -DPIC \
-           ${CFLAGS} ${ACFLAGS} \
+           ${SHARED_CFLAGS} ${CFLAGS} ${ACFLAGS} \
            -c ${.IMPSRC} -o ${.TARGET}
        ${CTFCONVERT_CMD}
 
 .asm.nossppico:
        ${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PICFLAG} -DPIC \
+           
${SHARED_CFLAGS:C/^-fstack-protector.*$//:C/^-fstack-clash-protection.*$//} \
            
${CFLAGS:C/^-fstack-protector.*$//:C/^-fstack-clash-protection.*$//} \
            ${ACFLAGS} \
            -c ${.IMPSRC} -o ${.TARGET}
@@ -73,18 +74,19 @@ PIEFLAG?=-fpie
 
 .asm.pieo:
        ${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PIEFLAG} -DPIC \
-           ${CFLAGS} ${ACFLAGS} \
+           ${SHARED_CFLAGS} ${CFLAGS} ${ACFLAGS} \
            -c ${.IMPSRC} -o ${.TARGET}
        ${CTFCONVERT_CMD}
 
 .S.pico:
        ${CC:N${CCACHE_BIN}} ${PICFLAG} -DPIC \
-           ${CFLAGS} ${ACFLAGS} \
+           ${SHARED_CFLAGS} ${CFLAGS} ${ACFLAGS} \
            -c ${.IMPSRC} -o ${.TARGET}
        ${CTFCONVERT_CMD}
 
 .S.nossppico:
        ${CC:N${CCACHE_BIN}} ${PICFLAG} -DPIC \
+           
${SHARED_CFLAGS:C/^-fstack-protector.*$//:C/^-fstack-clash-protection.*$//} \
            
${CFLAGS:C/^-fstack-protector.*$//:C/^-fstack-clash-protection.*$//} \
            ${ACFLAGS} \
            -c ${.IMPSRC} -o ${.TARGET}
@@ -92,7 +94,7 @@ PIEFLAG?=-fpie
 
 .S.pieo:
        ${CC:N${CCACHE_BIN}} ${PIEFLAG} -DPIC \
-           ${CFLAGS} ${ACFLAGS} \
+           ${SHARED_CFLAGS} ${CFLAGS} ${ACFLAGS} \
            -c ${.IMPSRC} -o ${.TARGET}
        ${CTFCONVERT_CMD}
 

Reply via email to