Skip to content

Commit 9c20010

Browse files
committed
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
1 parent cba6bf5 commit 9c20010

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

share/mk/bsd.README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ LIBADD Additional libraries. This is for base system libraries
197197
LIBADD.${.TARGET:T}
198198
Libraries dependent on output file name.
199199

200+
SHARED_CFLAGS Additional compiler flags used when creating shared or
201+
position independent object files.
202+
200203
COMPILER_FEATURES
201204
A list of features that the compiler supports. Zero or
202205
more of:

share/mk/bsd.suffixes-extra.mk

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,39 +60,41 @@ PIEFLAG?=-fpie
6060

6161
.asm.pico:
6262
${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PICFLAG} -DPIC \
63-
${CFLAGS} ${ACFLAGS} \
63+
${SHARED_CFLAGS} ${CFLAGS} ${ACFLAGS} \
6464
-c ${.IMPSRC} -o ${.TARGET}
6565
${CTFCONVERT_CMD}
6666

6767
.asm.nossppico:
6868
${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PICFLAG} -DPIC \
69+
${SHARED_CFLAGS:C/^-fstack-protector.*$//:C/^-fstack-clash-protection.*$//} \
6970
${CFLAGS:C/^-fstack-protector.*$//:C/^-fstack-clash-protection.*$//} \
7071
${ACFLAGS} \
7172
-c ${.IMPSRC} -o ${.TARGET}
7273
${CTFCONVERT_CMD}
7374

7475
.asm.pieo:
7576
${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PIEFLAG} -DPIC \
76-
${CFLAGS} ${ACFLAGS} \
77+
${SHARED_CFLAGS} ${CFLAGS} ${ACFLAGS} \
7778
-c ${.IMPSRC} -o ${.TARGET}
7879
${CTFCONVERT_CMD}
7980

8081
.S.pico:
8182
${CC:N${CCACHE_BIN}} ${PICFLAG} -DPIC \
82-
${CFLAGS} ${ACFLAGS} \
83+
${SHARED_CFLAGS} ${CFLAGS} ${ACFLAGS} \
8384
-c ${.IMPSRC} -o ${.TARGET}
8485
${CTFCONVERT_CMD}
8586

8687
.S.nossppico:
8788
${CC:N${CCACHE_BIN}} ${PICFLAG} -DPIC \
89+
${SHARED_CFLAGS:C/^-fstack-protector.*$//:C/^-fstack-clash-protection.*$//} \
8890
${CFLAGS:C/^-fstack-protector.*$//:C/^-fstack-clash-protection.*$//} \
8991
${ACFLAGS} \
9092
-c ${.IMPSRC} -o ${.TARGET}
9193
${CTFCONVERT_CMD}
9294

9395
.S.pieo:
9496
${CC:N${CCACHE_BIN}} ${PIEFLAG} -DPIC \
95-
${CFLAGS} ${ACFLAGS} \
97+
${SHARED_CFLAGS} ${CFLAGS} ${ACFLAGS} \
9698
-c ${.IMPSRC} -o ${.TARGET}
9799
${CTFCONVERT_CMD}
98100

0 commit comments

Comments
 (0)