commit:     162b52d8795d5eead77376c37c23d91001373258
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 13 21:46:59 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Mar 13 21:47:53 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=162b52d8

sys-devel/clang-common: don't default-enable _FORTIFY_SOURCE w/ ASAN and MSAN

This can cause either false positives in warnings from the compiler or false
negatives where the sanitizer misses something.

Bug: https://github.com/google/sanitizers/issues/247
Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...15.0.7-r3.ebuild => clang-common-15.0.7-r4.ebuild} | 19 ++++++++++++++-----
 .../clang-common/clang-common-16.0.0.9999.ebuild      | 19 ++++++++++++++-----
 ...c3-r1.ebuild => clang-common-16.0.0_rc3-r2.ebuild} | 19 ++++++++++++++-----
 ...0_rc4.ebuild => clang-common-16.0.0_rc4-r1.ebuild} | 19 ++++++++++++++-----
 .../clang-common/clang-common-17.0.0.9999.ebuild      | 19 ++++++++++++++-----
 ...uild => clang-common-17.0.0_pre20230304-r1.ebuild} | 19 ++++++++++++++-----
 6 files changed, 84 insertions(+), 30 deletions(-)

diff --git a/sys-devel/clang-common/clang-common-15.0.7-r3.ebuild 
b/sys-devel/clang-common/clang-common-15.0.7-r4.ebuild
similarity index 91%
rename from sys-devel/clang-common/clang-common-15.0.7-r3.ebuild
rename to sys-devel/clang-common/clang-common-15.0.7-r4.ebuild
index ae60c641f5f9..c7af956a5dd7 100644
--- a/sys-devel/clang-common/clang-common-15.0.7-r3.ebuild
+++ b/sys-devel/clang-common/clang-common-15.0.7-r4.ebuild
@@ -107,11 +107,20 @@ src_install() {
        # without optimization and that would at the very least be very noisy
        # during builds and at worst trigger many -Werror builds.
        cat >> "${ED}/usr/include/gentoo/fortify.h" <<- EOF || die
-               #ifndef _FORTIFY_SOURCE
-                       #if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
-                               #define _FORTIFY_SOURCE ${fortify_level}
-                       #endif
-               #endif
+       #ifndef _FORTIFY_SOURCE
+       # if defined(__has_feature)
+       #  define __GENTOO_HAS_FEATURE(x) __has_feature(x)
+       # else
+       #  define __GENTOO_HAS_FEATURE(x) 0
+       # endif
+       #
+       # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 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
+       #endif
        EOF
 
        if use hardened ; then

diff --git a/sys-devel/clang-common/clang-common-16.0.0.9999.ebuild 
b/sys-devel/clang-common/clang-common-16.0.0.9999.ebuild
index 3165f42a329f..808c1e1a0ae1 100644
--- a/sys-devel/clang-common/clang-common-16.0.0.9999.ebuild
+++ b/sys-devel/clang-common/clang-common-16.0.0.9999.ebuild
@@ -106,11 +106,20 @@ src_install() {
        # without optimization and that would at the very least be very noisy
        # during builds and at worst trigger many -Werror builds.
        cat >> "${ED}/usr/include/gentoo/fortify.h" <<- EOF || die
-               #ifndef _FORTIFY_SOURCE
-                       #if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
-                               #define _FORTIFY_SOURCE ${fortify_level}
-                       #endif
-               #endif
+       #ifndef _FORTIFY_SOURCE
+       # if defined(__has_feature)
+       #  define __GENTOO_HAS_FEATURE(x) __has_feature(x)
+       # else
+       #  define __GENTOO_HAS_FEATURE(x) 0
+       # endif
+       #
+       # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 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
+       #endif
        EOF
 
        if use hardened ; then

diff --git a/sys-devel/clang-common/clang-common-16.0.0_rc3-r1.ebuild 
b/sys-devel/clang-common/clang-common-16.0.0_rc3-r2.ebuild
similarity index 91%
rename from sys-devel/clang-common/clang-common-16.0.0_rc3-r1.ebuild
rename to sys-devel/clang-common/clang-common-16.0.0_rc3-r2.ebuild
index d8624a7c3152..1f768ea302a9 100644
--- a/sys-devel/clang-common/clang-common-16.0.0_rc3-r1.ebuild
+++ b/sys-devel/clang-common/clang-common-16.0.0_rc3-r2.ebuild
@@ -106,11 +106,20 @@ src_install() {
        # without optimization and that would at the very least be very noisy
        # during builds and at worst trigger many -Werror builds.
        cat >> "${ED}/usr/include/gentoo/fortify.h" <<- EOF || die
-               #ifndef _FORTIFY_SOURCE
-                       #if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
-                               #define _FORTIFY_SOURCE ${fortify_level}
-                       #endif
-               #endif
+       #ifndef _FORTIFY_SOURCE
+       # if defined(__has_feature)
+       #  define __GENTOO_HAS_FEATURE(x) __has_feature(x)
+       # else
+       #  define __GENTOO_HAS_FEATURE(x) 0
+       # endif
+       #
+       # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 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
+       #endif
        EOF
 
        if use hardened ; then

diff --git a/sys-devel/clang-common/clang-common-16.0.0_rc4.ebuild 
b/sys-devel/clang-common/clang-common-16.0.0_rc4-r1.ebuild
similarity index 91%
rename from sys-devel/clang-common/clang-common-16.0.0_rc4.ebuild
rename to sys-devel/clang-common/clang-common-16.0.0_rc4-r1.ebuild
index d8624a7c3152..1f768ea302a9 100644
--- a/sys-devel/clang-common/clang-common-16.0.0_rc4.ebuild
+++ b/sys-devel/clang-common/clang-common-16.0.0_rc4-r1.ebuild
@@ -106,11 +106,20 @@ src_install() {
        # without optimization and that would at the very least be very noisy
        # during builds and at worst trigger many -Werror builds.
        cat >> "${ED}/usr/include/gentoo/fortify.h" <<- EOF || die
-               #ifndef _FORTIFY_SOURCE
-                       #if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
-                               #define _FORTIFY_SOURCE ${fortify_level}
-                       #endif
-               #endif
+       #ifndef _FORTIFY_SOURCE
+       # if defined(__has_feature)
+       #  define __GENTOO_HAS_FEATURE(x) __has_feature(x)
+       # else
+       #  define __GENTOO_HAS_FEATURE(x) 0
+       # endif
+       #
+       # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 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
+       #endif
        EOF
 
        if use hardened ; then

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 3165f42a329f..808c1e1a0ae1 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
@@ -106,11 +106,20 @@ src_install() {
        # without optimization and that would at the very least be very noisy
        # during builds and at worst trigger many -Werror builds.
        cat >> "${ED}/usr/include/gentoo/fortify.h" <<- EOF || die
-               #ifndef _FORTIFY_SOURCE
-                       #if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
-                               #define _FORTIFY_SOURCE ${fortify_level}
-                       #endif
-               #endif
+       #ifndef _FORTIFY_SOURCE
+       # if defined(__has_feature)
+       #  define __GENTOO_HAS_FEATURE(x) __has_feature(x)
+       # else
+       #  define __GENTOO_HAS_FEATURE(x) 0
+       # endif
+       #
+       # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 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
+       #endif
        EOF
 
        if use hardened ; then

diff --git a/sys-devel/clang-common/clang-common-17.0.0_pre20230304.ebuild 
b/sys-devel/clang-common/clang-common-17.0.0_pre20230304-r1.ebuild
similarity index 91%
rename from sys-devel/clang-common/clang-common-17.0.0_pre20230304.ebuild
rename to sys-devel/clang-common/clang-common-17.0.0_pre20230304-r1.ebuild
index 3165f42a329f..808c1e1a0ae1 100644
--- a/sys-devel/clang-common/clang-common-17.0.0_pre20230304.ebuild
+++ b/sys-devel/clang-common/clang-common-17.0.0_pre20230304-r1.ebuild
@@ -106,11 +106,20 @@ src_install() {
        # without optimization and that would at the very least be very noisy
        # during builds and at worst trigger many -Werror builds.
        cat >> "${ED}/usr/include/gentoo/fortify.h" <<- EOF || die
-               #ifndef _FORTIFY_SOURCE
-                       #if defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
-                               #define _FORTIFY_SOURCE ${fortify_level}
-                       #endif
-               #endif
+       #ifndef _FORTIFY_SOURCE
+       # if defined(__has_feature)
+       #  define __GENTOO_HAS_FEATURE(x) __has_feature(x)
+       # else
+       #  define __GENTOO_HAS_FEATURE(x) 0
+       # endif
+       #
+       # if defined(__OPTIMIZE__) && __OPTIMIZE__ > 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
+       #endif
        EOF
 
        if use hardened ; then

Reply via email to