eclass/flag-o-matic: Sync with Gentoo

It's from Gentoo commit bc7f9e5b77e202ba568eaaf0f6a5638e5c0f6f23.
This commit is contained in:
Flatcar Buildbot 2023-09-04 07:12:04 +00:00 committed by Krzesimir Nowak
parent 130b932457
commit 8b2d075ee8

View File

@ -147,7 +147,10 @@ _filter-hardened() {
# not -fPIC or -fpic, but too many places filter -fPIC without # not -fPIC or -fpic, but too many places filter -fPIC without
# thinking about -fPIE. # thinking about -fPIE.
-fPIC|-fpic|-fPIE|-fpie|-Wl,pie|-pie) -fPIC|-fpic|-fPIE|-fpie|-Wl,pie|-pie)
gcc-specs-pie || continue if ! gcc-specs-pie && ! tc-enables-pie ; then
continue
fi
if ! is-flagq -nopie && ! is-flagq -no-pie ; then if ! is-flagq -nopie && ! is-flagq -no-pie ; then
# Support older Gentoo form first (-nopie) before falling # Support older Gentoo form first (-nopie) before falling
# back to the official gcc-6+ form (-no-pie). # back to the official gcc-6+ form (-no-pie).
@ -158,15 +161,36 @@ _filter-hardened() {
fi fi
fi fi
;; ;;
-fstack-protector)
gcc-specs-ssp || continue -fstack-protector|-fstack-protector-strong)
is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector);; if ! gcc-specs-ssp && ! tc-enables-ssp && ! tc-enables-ssp-strong ; then
continue
fi
is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
;;
-fstack-protector-all) -fstack-protector-all)
gcc-specs-ssp-to-all || continue if ! gcc-specs-ssp-to-all && ! tc-enables-ssp-all ; then
is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all);; continue
fi
is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
;;
-fno-strict-overflow) -fno-strict-overflow)
gcc-specs-nostrict || continue gcc-specs-nostrict || continue
is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow);;
is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
;;
-D_GLIBCXX_ASSERTIONS|-D_LIBCPP_ENABLE_ASSERTIONS|-D_LIBCPP_ENABLE_HARDENED_MODE)
tc-enables-cxx-assertions || continue
append-cppflags -U_GLIBCXX_ASSERTIONS -U_LIBCPP_ENABLE_ASSERTIONS -U_LIBCPP_ENABLE_HARDENED_MODE
;;
-D_FORTIFY_SOURCE=*)
tc-enables-fortify-source || continue
append-cppflags -U_FORTIFY_SOURCE
;;
esac esac
done done
} }