From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1555780-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 5BA8A158089
	for <garchives@archives.gentoo.org>; Tue, 19 Sep 2023 09:14:33 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id A50E42BC03E;
	Tue, 19 Sep 2023 09:14:32 +0000 (UTC)
Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 911142BC03E
	for <gentoo-commits@lists.gentoo.org>; Tue, 19 Sep 2023 09:14:32 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id CA258335C78
	for <gentoo-commits@lists.gentoo.org>; Tue, 19 Sep 2023 09:14:31 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 28D6711AA
	for <gentoo-commits@lists.gentoo.org>; Tue, 19 Sep 2023 09:14:30 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1695114756.01362dba1be773ca4782e753a5e63d68da43787d.sam@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/clang-common/
X-VCS-Repository: repo/gentoo
X-VCS-Files: sys-devel/clang-common/clang-common-17.0.0.9999.ebuild sys-devel/clang-common/clang-common-18.0.0.9999.ebuild
X-VCS-Directories: sys-devel/clang-common/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 01362dba1be773ca4782e753a5e63d68da43787d
X-VCS-Branch: master
Date: Tue, 19 Sep 2023 09:14:30 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: f2f189fa-2ff8-47a9-8b07-1141f4a14757
X-Archives-Hash: adb9f88e7a98469601e77846fdbb7a22

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