linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Desaulniers <ndesaulniers@google.com>
To: namit@vmware.com
Cc: Nathan Chancellor <natechancellor@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	Kees Cook <keescook@chromium.org>,
	Masahiro Yamada <yamada.masahiro@socionext.com>
Subject: Re: [PATCH RFC] x86: Don't include '-Wa,-' when building with Clang
Date: Tue, 23 Oct 2018 11:40:37 -0700	[thread overview]
Message-ID: <CAKwvOdmsKbW9v9or+u-W9V7T+LrF4ODY9cgUStkjkmsbMcqJ2g@mail.gmail.com> (raw)
In-Reply-To: <F3BBC06A-A9CB-4ABF-ADF4-6B0971FAE364@vmware.com>

On Mon, Oct 22, 2018 at 10:11 PM Nadav Amit <namit@vmware.com> wrote:
>
> at 5:37 PM, Nathan Chancellor <natechancellor@gmail.com> wrote:
>
> Commit 77b0bf55bc67 ("kbuild/Makefile: Prepare for using macros in
> inline assembly code to work around asm() related GCC inlining bugs")
> added this flag to KBUILD_CFLAGS, where it works perfectly fine with
> GCC. However, when building with Clang, all of the object files compile
> fine but the build hangs indefinitely at init/main.o, right before the
> linking stage. Don't include this flag when building with Clang.
>
> The kernel builds and boots to a shell in QEMU with both GCC and Clang
> with this patch applied.
>
> Link: https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FClangBuiltLinux%2Flinux%2Fissues%2F213&amp;data=02%7C01%7Cnamit%40vmware.com%7C871daebc2ca44947d28d08d638811fb5%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636758524579997650&amp;sdata=shuxW81QRrO3TSqbgf462wgZYdLeAKeQEdGRxmnUX30%3D&amp;reserved=0
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>
> The reason this patch is labeled RFC is while I can verify that this
> fixes the issue, I'm not entirely sure why the '-Wa,-' works for GCC
> and not Clang. I looked into what the flag means and I couldn't really
> find anything so I just assume it's taking input from stdin? The issue
> could stem from how GCC forks gas versus how Clang does it. If this
> isn't of concern and the maintainers are happy with this patch as is,
> feel free to take it.
>
> arch/x86/Makefile | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> index 5b562e464009..4736dcc1caec 100644
> --- a/arch/x86/Makefile
> +++ b/arch/x86/Makefile
> @@ -239,7 +239,10 @@ archheaders:
> archmacros:
> $(Q)$(MAKE) $(build)=arch/x86/kernel arch/x86/kernel/macros.s
>
> -ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s -Wa,-
> +ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s
> +ifneq ($(cc-name),clang)
> +ASM_MACRO_FLAGS += -Wa,-
> +endif
> export ASM_MACRO_FLAGS
> KBUILD_CFLAGS += $(ASM_MACRO_FLAGS)
>
>
> The '-Wa,-‘ was indeed used to take the input from stdin when the ‘-pipe’
> option is used in GCC. Perhaps clang ignores the ‘-pipe’ flag.
>

Clang documents support for `-pipe`.
https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-pipe

$ clang hello_world.c -no-integrated-as -Wa,-

is simple enough to reproduce the hang (notice no `-pipe`).
`strace`'ing the above with and without `-Wa,-` shows clang hung in a
`wait4` call after spawning as, while without `-Wa,-` shows it
receiving a SIGCHLD.

I've filed a bug against Clang to investigate:
https://bugs.llvm.org/show_bug.cgi?id=39410

In the meantime, I think Nathan's patch is the correct way to work
around this, if it is indeed a bug in Clang.

Reviewed-and-Tested-by: Nick Desaulniers <ndesaulniers@google.com>

https://stackoverflow.com/questions/1512933/when-should-i-use-gccs-pipe-option
has some interesting perspectives on the use of `-pipe`.
Thanks for the patch Nathan, and more info Nadav.
-- 
Thanks,
~Nick Desaulniers

  parent reply	other threads:[~2018-10-23 18:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-23  0:37 [PATCH RFC] x86: Don't include '-Wa,-' when building with Clang Nathan Chancellor
     [not found] ` <F3BBC06A-A9CB-4ABF-ADF4-6B0971FAE364@vmware.com>
2018-10-23 18:40   ` Nick Desaulniers [this message]
2018-10-23 20:01     ` H. Peter Anvin
2018-10-23 21:58       ` Nathan Chancellor
2018-10-23 22:04         ` hpa
2018-10-23 22:08         ` Nick Desaulniers
2018-10-23 22:44           ` Nathan Chancellor
2018-10-23 22:53             ` Nick Desaulniers
2018-10-23 23:01               ` hpa

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=CAKwvOdmsKbW9v9or+u-W9V7T+LrF4ODY9cgUStkjkmsbMcqJ2g@mail.gmail.com \
    --to=ndesaulniers@google.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namit@vmware.com \
    --cc=natechancellor@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yamada.masahiro@socionext.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;
as well as URLs for NNTP newsgroup(s).