mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@infradead.org>
To: Nick Desaulniers <ndesaulniers@google.com>,
	alexandre.belloni@bootlin.com,
	Masahiro Yamada <masahiroy@kernel.org>
Cc: Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] init/Kconfig: fix CC_HAS_ASM_GOTO_TIED_OUTPUT test with dash
Date: Wed, 17 Aug 2022 16:52:23 -0700	[thread overview]
Message-ID: <7eacd1d9-42ba-fd61-7f37-0635cebcb33d@infradead.org> (raw)
In-Reply-To: <CAKwvOd=3N8_Rx1P8J7pVnjM6sEzJA233BnwmD1VyMRqgujq2_Q@mail.gmail.com>



On 8/17/22 16:46, Nick Desaulniers wrote:
> On Thu, Aug 4, 2022 at 12:03 PM <alexandre.belloni@bootlin.com> wrote:
>>
>> From: Alexandre Belloni <alexandre.belloni@bootlin.com>
>>
>> When using dash as /bin/sh, the CC_HAS_ASM_GOTO_TIED_OUTPUT test fails
>> with a syntax error which is not the one we are looking for:
> 
> Thanks for the patch, though I think I'd rather see `/bin/bash`
> hardcoded. Bash is a non-optional requirement as of
> commit da4288b95baa ("scripts/check-local-export: avoid 'wait $!' for
> process substitution")
> scripts/ is kind of a mess...
> 

Well, once upon a time, we took patches to remove bash-isms (convert to
standard shell)...
No longer, AFAICT.

>>
>> <stdin>: In function ‘foo’:
>> <stdin>:1:29: warning: missing terminating " character
>> <stdin>:1:29: error: missing terminating " character
>> <stdin>:2:5: error: expected ‘:’ before ‘+’ token
>> <stdin>:2:7: warning: missing terminating " character
>> <stdin>:2:7: error: missing terminating " character
>> <stdin>:2:5: error: expected declaration or statement at end of input
>>
>> Move all the CC_HAS_ASM_GOTO tests to scripts/gcc-goto.sh to solve the
>> escaping issues.
>>
>> Fixes: 1aa0e8b144b6 ("Kconfig: Add option for asm goto w/ tied outputs to workaround clang-13 bug")
>> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
>> ---
>>  init/Kconfig        |  6 +++---
>>  scripts/gcc-goto.sh | 31 +++++++++++++++++++++++++++++++
>>  2 files changed, 34 insertions(+), 3 deletions(-)
>>
>> diff --git a/init/Kconfig b/init/Kconfig
>> index c984afc489de..9903a11cfe7d 100644
>> --- a/init/Kconfig
>> +++ b/init/Kconfig
>> @@ -71,16 +71,16 @@ config CC_CAN_LINK_STATIC
>>         default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(USERCFLAGS) $(USERLDFLAGS) $(m32-flag) -static)
>>
>>  config CC_HAS_ASM_GOTO
>> -       def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))
>> +       def_bool $(success,$(srctree)/scripts/gcc-goto.sh goto $(CC))
>>
>>  config CC_HAS_ASM_GOTO_OUTPUT
>>         depends on CC_HAS_ASM_GOTO
>> -       def_bool $(success,echo 'int foo(int x) { asm goto ("": "=r"(x) ::: bar); return x; bar: return 0; }' | $(CC) -x c - -c -o /dev/null)
>> +       def_bool $(success,$(srctree)/scripts/gcc-goto.sh goto_output $(CC))
>>
>>  config CC_HAS_ASM_GOTO_TIED_OUTPUT
>>         depends on CC_HAS_ASM_GOTO_OUTPUT
>>         # Detect buggy gcc and clang, fixed in gcc-11 clang-14.
>> -       def_bool $(success,echo 'int foo(int *x) { asm goto (".long (%l[bar]) - .\n": "+m"(*x) ::: bar); return *x; bar: return 0; }' | $CC -x c - -c -o /dev/null)
>> +       def_bool $(success,$(srctree)/scripts/gcc-goto.sh goto_tied_output $(CC))
>>
>>  config TOOLS_SUPPORT_RELR
>>         def_bool $(success,env "CC=$(CC)" "LD=$(LD)" "NM=$(NM)" "OBJCOPY=$(OBJCOPY)" $(srctree)/scripts/tools-support-relr.sh)
>> diff --git a/scripts/gcc-goto.sh b/scripts/gcc-goto.sh
>> index 8b980fb2270a..aa9498b74df8 100755
>> --- a/scripts/gcc-goto.sh
>> +++ b/scripts/gcc-goto.sh
>> @@ -3,6 +3,11 @@
>>  # Test for gcc 'asm goto' support
>>  # Copyright (C) 2010, Jason Baron <jbaron@redhat.com>
>>
>> +TEST=$1
>> +shift
>> +
>> +case $TEST in
>> +    "goto")
>>  cat << "END" | $@ -x c - -fno-PIE -c -o /dev/null
>>  int main(void)
>>  {
>> @@ -20,3 +25,29 @@ entry:
>>         return 0;
>>  }
>>  END
>> +    ;;
>> +
>> +    "goto_output")
>> +cat << "END" | $@ -x c - -c -o /dev/null
>> +int foo(int x) {
>> +       asm goto ("": "=r"(x) ::: bar);
>> +       return x;
>> +       bar: return 0;
>> +}
>> +END
>> +    ;;
>> +
>> +    "goto_tied_output")
>> +cat << "END" | $@ -x c - -c -o /dev/null
>> +int foo(int *x) {
>> +       asm goto (".long (%l[bar]) - .\n": "+m"(*x) ::: bar);
>> +       return *x;
>> +       bar: return 0;
>> +}
>> +END
>> +    ;;
>> +
>> +    *)
>> +       exit -1
>> +    ;;
>> +esac
>> --
>> 2.37.1
>>
> 
> 

-- 
~Randy

  reply	other threads:[~2022-08-17 23:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04 19:03 alexandre.belloni
2022-08-17 23:46 ` Nick Desaulniers
2022-08-17 23:52   ` Randy Dunlap [this message]
2022-08-18  9:14     ` Richard Purdie
2022-08-18 19:31       ` Masahiro Yamada
2022-08-18 21:45         ` Richard Purdie
2022-08-19  8:40           ` Masahiro Yamada
2022-08-22 21:59             ` Richard Purdie
2022-08-19  2:27   ` Masahiro Yamada
2022-08-19 16:31     ` Nick Desaulniers
2022-08-18 17:00 ` Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7eacd1d9-42ba-fd61-7f37-0635cebcb33d@infradead.org \
    --to=rdunlap@infradead.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®