From patchwork Tue Aug 17 18:41:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1517801 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 ozlabs.org (Postfix) with ESMTPS id 4Gq0Hk3MZ4z9sWw for ; Wed, 18 Aug 2021 04:41:52 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 53E7439730FC for ; Tue, 17 Aug 2021 18:41:49 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp001-out.apm-internet.net (smtp001-out.apm-internet.net [85.119.248.222]) by sourceware.org (Postfix) with ESMTPS id AFACE3839412 for ; Tue, 17 Aug 2021 18:41:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AFACE3839412 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=sandoe.co.uk Received: (qmail 158 invoked from network); 17 Aug 2021 18:41:14 -0000 X-APM-Out-ID: 16292256730015 X-APM-Authkey: 257869/1(257869/1) 2 Received: from unknown (HELO ?192.168.1.214?) (81.138.1.83) by smtp001.apm-internet.net with SMTP; 17 Aug 2021 18:41:14 -0000 From: Iain Sandoe Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: [pushed] Darwin, X86, config: Adjust 'as' command lines [PR100340]. Message-Id: <09640E7D-7174-4AB3-9998-CD2C66928661@sandoe.co.uk> Date: Tue, 17 Aug 2021 19:41:13 +0100 To: GCC Patches X-Mailer: Apple Mail (2.3445.104.21) X-Spam-Status: No, score=-15.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_COUK, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, Versions of the assembler using clang from XCode 12.5/12.5.1 have a bug which produces different code layout between debug and non-debug input, leading to a compare fail for default configure parameters. This is a workaround fix to disable the optimisation that is responsible for the bug. tested on x86_64-darwin20, x86_64-darwin17, i686-darwin9 and on x86_64-linux. Pushed to master, thanks Iain Signed-off-by: Iain Sandoe PR target/100340 - Bootstrap fails with Clang 12.0.5 (XCode 12.5) PR target/100340 gcc/ChangeLog: * config.in: Regenerate. * config/i386/darwin.h (EXTRA_ASM_OPTS): New (ASM_SPEC): Pass options to disable branch shortening where needed. * configure: Regenerate. * configure.ac: Detect versions of 'as' that support the optimisation which has the bug. --- gcc/config.in | 7 +++++++ gcc/config/i386/darwin.h | 10 +++++++++- gcc/configure | 35 +++++++++++++++++++++++++++++++++++ gcc/configure.ac | 9 +++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/gcc/config.in b/gcc/config.in index 7f5b01fad76..d8a810bbc91 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -616,6 +616,13 @@ #endif +/* Define if your Mac OS X assembler supports -mllvm -x86-pad-for-align=false. + */ +#ifndef USED_FOR_TARGET +#undef HAVE_AS_MLLVM_X86_PAD_FOR_ALIGN +#endif + + /* Define if your Mac OS X assembler supports the -mmacos-version-min option. */ #ifndef USED_FOR_TARGET diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h index bac32197e83..73b06e2307d 100644 --- a/gcc/config/i386/darwin.h +++ b/gcc/config/i386/darwin.h @@ -125,10 +125,18 @@ along with GCC; see the file COPYING3. If not see %{mfentry*:%eDarwin does not support -mfentry or associated options}" \ DARWIN_CC1_SPEC +/* This is a workaround for a tool bug: see PR100340. */ + +#ifdef HAVE_AS_MLLVM_X86_PAD_FOR_ALIGN +#define EXTRA_ASM_OPTS " -mllvm -x86-pad-for-align=false" +#else +#define EXTRA_ASM_OPTS "" +#endif + #undef ASM_SPEC #define ASM_SPEC "-arch %(darwin_arch) \ " ASM_OPTIONS " -force_cpusubtype_ALL \ - %{static}" ASM_MMACOSX_VERSION_MIN_SPEC + %{static}" ASM_MMACOSX_VERSION_MIN_SPEC EXTRA_ASM_OPTS #undef ENDFILE_SPEC #define ENDFILE_SPEC \ diff --git a/gcc/configure b/gcc/configure index 08c286764e0..a2d1003a0f5 100755 --- a/gcc/configure +++ b/gcc/configure @@ -27082,6 +27082,41 @@ $as_echo "$as_me: WARNING: LTO for $target requires binutils >= 2.20.1, but vers fi ;; esac + case $target_os in + darwin2[0-9]* | darwin19*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for llvm assembler x86-pad-for-align option" >&5 +$as_echo_n "checking assembler for llvm assembler x86-pad-for-align option... " >&6; } +if ${gcc_cv_as_mllvm_x86_pad_for_align+:} false; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_as_mllvm_x86_pad_for_align=no + if test x$gcc_cv_as != x; then + $as_echo '.text' > conftest.s + if { ac_try='$gcc_cv_as $gcc_cv_as_flags -mllvm -x86-pad-for-align=false -o conftest.o conftest.s >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + gcc_cv_as_mllvm_x86_pad_for_align=yes + else + echo "configure: failed program was" >&5 + cat conftest.s >&5 + fi + rm -f conftest.o conftest.s + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_mllvm_x86_pad_for_align" >&5 +$as_echo "$gcc_cv_as_mllvm_x86_pad_for_align" >&6; } +if test $gcc_cv_as_mllvm_x86_pad_for_align = yes; then + +$as_echo "#define HAVE_AS_MLLVM_X86_PAD_FOR_ALIGN 1" >>confdefs.h + +fi + + ;; + esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -xbrace_comment" >&5 $as_echo_n "checking assembler for -xbrace_comment... " >&6; } diff --git a/gcc/configure.ac b/gcc/configure.ac index 653a1cc561d..ad8fa5a4604 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -4799,6 +4799,15 @@ foo: nop fi ;; esac + case $target_os in + darwin2[[0-9]]* | darwin19*) + gcc_GAS_CHECK_FEATURE([llvm assembler x86-pad-for-align option], + gcc_cv_as_mllvm_x86_pad_for_align,, + [-mllvm -x86-pad-for-align=false], [.text],, + [AC_DEFINE(HAVE_AS_MLLVM_X86_PAD_FOR_ALIGN, 1, + [Define if your Mac OS X assembler supports -mllvm -x86-pad-for-align=false.])]) + ;; + esac gcc_GAS_CHECK_FEATURE([-xbrace_comment], gcc_cv_as_ix86_xbrace_comment,, [-xbrace_comment=no], [.text],,