diff --git a/eclass/toolchain-glibc.eclass b/eclass/toolchain-glibc.eclass index ef9d91acae..44207d4cbe 100644 --- a/eclass/toolchain-glibc.eclass +++ b/eclass/toolchain-glibc.eclass @@ -264,14 +264,18 @@ setup_flags() { filter-flags -fstack-protector* gcc-specs-ssp && append-flags $(test-flags -fno-stack-protector) - if use hardened && gcc-specs-pie ; then - # Force PIC macro definition for all compilations since they're all - # either -fPIC or -fPIE with the default-PIE compiler. - append-cppflags -DPIC - else - # Don't build -fPIE without the default-PIE compiler and the - # hardened-pie patch - filter-flags -fPIE + if has_version '=gcc-6, these functions are controlled via + # the useflags on gcc + if use hardened && gcc-specs-pie ; then + # Force PIC macro definition for all compilations since they're all + # either -fPIC or -fPIE with the default-PIE compiler. + append-cppflags -DPIC + else + # Don't build -fPIE without the default-PIE compiler and the + # hardened-pie patch + filter-flags -fPIE + fi fi }