commit: 01362dba1be773ca4782e753a5e63d68da43787d Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Tue Sep 19 09:12:36 2023 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Tue Sep 19 09:12:36 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=01362dba
sys-devel/clang-common: adapt to 17 final (hardened mode); disable F_S for freestanding * In 84bffb47c84bc57fbbd409a72e5ae3d1cdb8cf9e, we changed from -D_LIBCPP_ENABLE_ASSERTIONS=1 to -D_LIBCPP_ENABLE_HARDENED_MODE=1. Unfortunately, LLVM upstream has reverted last minute back to _ENABLE_ASSERTIONS in https://reviews.llvm.org/D159171. This didn't land in any RCs. Go back for 17.x (but not 18.x). * Disable F_S for freestanding (thanks ceamac!) as it might emit calls to e.g. _memcpy_chk. Closes: https://bugs.gentoo.org/912223 Signed-off-by: Sam James <sam <AT> gentoo.org> sys-devel/clang-common/clang-common-17.0.0.9999.ebuild | 11 +++++++++-- sys-devel/clang-common/clang-common-18.0.0.9999.ebuild | 9 ++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/sys-devel/clang-common/clang-common-17.0.0.9999.ebuild b/sys-devel/clang-common/clang-common-17.0.0.9999.ebuild index 430e91d98aee..e3a7af989d05 100644 --- a/sys-devel/clang-common/clang-common-17.0.0.9999.ebuild +++ b/sys-devel/clang-common/clang-common-17.0.0.9999.ebuild @@ -169,12 +169,19 @@ src_install() { # define __GENTOO_HAS_FEATURE(x) 0 # endif # - # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 + # if defined(__STDC_HOSTED__) && __STDC_HOSTED__ == 1 + # define __GENTOO_NOT_FREESTANDING 1 + # else + # define __GENTOO_NOT_FREESTANDING 0 + # endif + # + # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 && __GENTOO_NOT_FREESTANDING > 0 # if !defined(__SANITIZE_ADDRESS__) && !__GENTOO_HAS_FEATURE(address_sanitizer) && !__GENTOO_HAS_FEATURE(memory_sanitizer) # define _FORTIFY_SOURCE ${fortify_level} # endif # endif # undef __GENTOO_HAS_FEATURE + # undef __GENTOO_NOT_FREESTANDING #endif EOF @@ -186,7 +193,7 @@ src_install() { # Analogue to GLIBCXX_ASSERTIONS # https://libcxx.llvm.org/UsingLibcxx.html#assertions-mode # https://libcxx.llvm.org/Hardening.html#using-hardened-mode - -D_LIBCPP_ENABLE_HARDENED_MODE=1 + -D_LIBCPP_ENABLE_ASSERTIONS=1 EOF cat >> "${ED}/etc/clang/gentoo-hardened-ld.cfg" <<-EOF || die diff --git a/sys-devel/clang-common/clang-common-18.0.0.9999.ebuild b/sys-devel/clang-common/clang-common-18.0.0.9999.ebuild index 430e91d98aee..baa1dffade6a 100644 --- a/sys-devel/clang-common/clang-common-18.0.0.9999.ebuild +++ b/sys-devel/clang-common/clang-common-18.0.0.9999.ebuild @@ -169,12 +169,19 @@ src_install() { # define __GENTOO_HAS_FEATURE(x) 0 # endif # - # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 + # if defined(__STDC_HOSTED__) && __STDC_HOSTED__ == 1 + # define __GENTOO_NOT_FREESTANDING 1 + # else + # define __GENTOO_NOT_FREESTANDING 0 + # endif + # + # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 && __GENTOO_NOT_FREESTANDING > 0 # if !defined(__SANITIZE_ADDRESS__) && !__GENTOO_HAS_FEATURE(address_sanitizer) && !__GENTOO_HAS_FEATURE(memory_sanitizer) # define _FORTIFY_SOURCE ${fortify_level} # endif # endif # undef __GENTOO_HAS_FEATURE + # undef __GENTOO_NOT_FREESTANDING #endif EOF
