Pass -pie to cc, not -Wl,-pie. This way we have a chance to fix specs

for obscure corner cases like -pie -fPIE -static (used for
/usr/tests/lib/csu/h_initfini2 if building with MKPIE=yes).
While there also replace -fPIC with -fPIE for the PIE case, even if
it should be mostly equivalent.
This commit is contained in:
martin 2016-03-30 13:05:09 +00:00
parent a13d81e5df
commit cb4d6b868c
2 changed files with 6 additions and 6 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: bsd.prog.mk,v 1.297 2016/03/12 23:08:58 mrg Exp $
# $NetBSD: bsd.prog.mk,v 1.298 2016/03/30 13:05:09 martin Exp $
# @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94
.ifndef HOSTPROG
@ -540,7 +540,7 @@ ${_P}: .gdbinit ${LIBCRT0} ${LIBCRTI} ${OBJS.${_P}} ${LIBC} ${LIBCRTBEGIN} \
${_P}.ro: ${OBJS.${_P}} ${_DPADD.${_P}}
${_MKTARGET_LINK}
${CC} ${LDFLAGS:N-Wl,-pie} -nostdlib -r -Wl,-dc -o ${.TARGET} ${OBJS.${_P}}
${CC} ${LDFLAGS:N-pie} -nostdlib -r -Wl,-dc -o ${.TARGET} ${OBJS.${_P}}
.if defined(_PROGDEBUG.${_P})
${_PROGDEBUG.${_P}}: ${_P}

View File

@ -1,4 +1,4 @@
# $NetBSD: bsd.sys.mk,v 1.256 2016/03/22 08:17:27 mrg Exp $
# $NetBSD: bsd.sys.mk,v 1.257 2016/03/30 13:05:09 martin Exp $
#
# Build definitions used for NetBSD source tree builds.
@ -178,9 +178,9 @@ AFLAGS+= ${CPUFLAGS}
.if !defined(NOPIE) && (!defined(LDSTATIC) || ${LDSTATIC} != "-static")
# Position Independent Executable flags
PIE_CFLAGS?= -fPIC
PIE_LDFLAGS?= -Wl,-pie ${${ACTIVE_CC} == "gcc":? -shared-libgcc :}
PIE_AFLAGS?= -fPIC
PIE_CFLAGS?= -fPIE
PIE_LDFLAGS?= -pie ${${ACTIVE_CC} == "gcc":? -shared-libgcc :}
PIE_AFLAGS?= -fPIE
.endif
ELF2ECOFF?= elf2ecoff