From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 8F9F83858000 for ; Tue, 9 Nov 2021 02:59:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8F9F83858000 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 22DA2342EB8; Tue, 9 Nov 2021 02:59:12 +0000 (UTC) From: Mike Frysinger To: newlib@sourceware.org Subject: [PATCH alternative] newlib: ignore _FORTIFY_SOURCE when building newlib Date: Mon, 8 Nov 2021 21:59:06 -0500 Message-Id: <20211109025906.26204-1-vapier@gentoo.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211109025656.26127-1-vapier@gentoo.org> References: <20211109025656.26127-1-vapier@gentoo.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Nov 2021 02:59:13 -0000 Some distros enable _FORTIFY_SOURCE by default which upsets building newlib which itself implements the logic for this define. For example, building gets.c fails because the includes set up a gets() macro which expands in the definition. Since newlib isn't prepared to build itself with _FORTIFY_SOURCE, and it's not clear if it's even useful, ignore it when building the code. This also matches what glibc is doing. --- NB: This is an alternative approach instead of passing -U_FORTIFY_SOURCE. I think the -U approach is better, but throwing this up for discussion. newlib/libc/include/sys/features.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/newlib/libc/include/sys/features.h b/newlib/libc/include/sys/features.h index 2188071785f6..6b4999e83482 100644 --- a/newlib/libc/include/sys/features.h +++ b/newlib/libc/include/sys/features.h @@ -320,7 +320,8 @@ extern "C" { #endif #if _FORTIFY_SOURCE > 0 && !defined(__cplusplus) && !defined(__lint__) && \ - (__OPTIMIZE__ > 0 || defined(__clang__)) && __GNUC_PREREQ__(4, 1) + (__OPTIMIZE__ > 0 || defined(__clang__)) && __GNUC_PREREQ__(4, 1) && \ + !defined(_COMPILING_NEWLIB) # if _FORTIFY_SOURCE > 1 # define __SSP_FORTIFY_LEVEL 2 # else -- 2.33.0