From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1658754-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 6F206159C9B
	for <garchives@archives.gentoo.org>; Sun,  4 Aug 2024 08:28:20 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id A200DE2AA0;
	Sun,  4 Aug 2024 08:28:19 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183])
	(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 7D712E2AA0
	for <gentoo-commits@lists.gentoo.org>; Sun,  4 Aug 2024 08:28:19 +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 706A9342F93
	for <gentoo-commits@lists.gentoo.org>; Sun,  4 Aug 2024 08:28:18 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 9B6831E5D
	for <gentoo-commits@lists.gentoo.org>; Sun,  4 Aug 2024 08:28:16 +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: <1722760001.361c3758642891759b0ed60a8f96bc0776d19f15.sam@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
X-VCS-Repository: repo/gentoo
X-VCS-Files: eclass/toolchain.eclass
X-VCS-Directories: eclass/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 361c3758642891759b0ed60a8f96bc0776d19f15
X-VCS-Branch: master
Date: Sun,  4 Aug 2024 08:28:16 +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: 02dcfeaa-5e3f-42de-abab-0aab2439137c
X-Archives-Hash: e635c31566bd4894bd32d3bb3f0f889e

commit:     361c3758642891759b0ed60a8f96bc0776d19f15
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Aug  4 01:27:26 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug  4 08:26:41 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=361c3758

toolchain.eclass: use more conservative flags in src_test

For tests, we need to put some effort in to counteract our defaults
like -Wformat-security and -Wtrampolines (which we may want to revisit
at some point, but it is what it is for now).

Use a subshell so we can mangle the values within without affecting
the rest of the build.

I still get some failures with this (including some related to e.g.
-Wformat-security still) but far fewer, the flags don't get passed
everywhere so needs more poking or maybe just patching those tests
within the patch we use to change defaults.

See also the discussion on gcc-patches recently [0].

[0] https://inbox.sourceware.org/gcc-patches/ee9a8a6b11438f158933a21d7965b486987be5a8.1721454759.git.sam <AT> gentoo.org/

Signed-off-by: Sam James <sam <AT> gentoo.org>

 eclass/toolchain.eclass | 41 ++++++++++++++++++++++++++++++++++++++---
 1 file changed, 38 insertions(+), 3 deletions(-)

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 7aa0f5a170f8..d2f42804301e 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1923,9 +1923,44 @@ toolchain_src_test() {
 	# Controls running expensive tests in e.g. the torture testsuite.
 	local -x GCC_TEST_RUN_EXPENSIVE=1
 
-	# nonfatal here as we die if the comparison below fails. Also, note that
-	# the exit code of targets other than 'check' may be unreliable.
-	nonfatal emake -C "${WORKDIR}"/build -k "${GCC_TESTS_CHECK_TARGET}" RUNTESTFLAGS="${GCC_TESTS_RUNTESTFLAGS}"
+	# Use a subshell to allow meddling with flags just for the testsuite
+	(
+		# Workaround our -Wformat-security default which breaks
+		# various tests as it adds unexpected warning output.
+		append-flags -Wno-format-security -Wno-format
+		# Workaround our -Wtrampolines default which breaks
+		# tests too.
+		append-flags -Wno-trampolines
+
+		# Issues with Ada tests:
+		# gnat.dg/align_max.adb
+		# gnat.dg/trampoline4.adb
+		#
+		# A handful of Ada tests use -fstack-check and conflict
+		# with -fstack-clash-protection.
+		#
+		# TODO: This isn't ideal given it obv. affects codegen
+		# and we want to be sure it works.
+		append-flags -fno-stack-clash-protection
+		# A handful of Ada (and objc++?) tests need an executable stack
+		append-ldflags -Wl,--no-warn-execstack
+
+		# Go doesn't support this and causes noisy warnings
+		filter-flags -Wbuiltin-declaration-mismatch
+
+		# nonfatal here as we die if the comparison below fails. Also, note that
+		# the exit code of targets other than 'check' may be unreliable.
+		nonfatal emake -C "${WORKDIR}"/build -k "${GCC_TESTS_CHECK_TARGET}" \
+			RUNTESTFLAGS="${GCC_TESTS_RUNTESTFLAGS}" \
+			CFLAGS_FOR_TARGET="${CFLAGS_FOR_TARGET:-${CFLAGS}}" \
+			CXXFLAGS_FOR_TARGET="${CXXFLAGS_FOR_TARGET:-${CXXFLAGS}}" \
+			LDFLAGS_FOR_TARGET="${LDFLAGS_FOR_TARGET:-${LDFLAGS}}" \
+			CFLAGS="${CFLAGS}" \
+			CXXFLAGS="${CXXFLAGS}" \
+			FCFLAGS="${FCFLAGS}" \
+			FFLAGS="${FFLAGS}" \
+			LDFLAGS="${LDFLAGS}"
+	)
 
 	# Produce an updated failure manifest.
 	einfo "Generating a new failure manifest ${T}/${CHOST}.xfail"