2021-06-10 09:32:00

by Tor Vic

[permalink] [raw]
Subject: [PATCH] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0

Since LLVM commit 3787ee4, the '-stack-alignment' flag has been dropped [1],
leading to the following error message when building a LTO kernel with
Clang-13 and LLD-13:

ld.lld: error: -plugin-opt=-: ld.lld: Unknown command line argument
'-stack-alignment=8'. Try 'ld.lld --help'
ld.lld: Did you mean '--stackrealign=8'?

It also appears that the '-code-model' flag is not necessary anymore starting
with LLVM-9 [2].

Drop '-code-model' and make '-stack-alignment' conditional on LLD < 13.0.0.

This is for linux-stable 5.12.
Another patch will be submitted for 5.13 shortly (unless there are objections).

Discussion: https://github.com/ClangBuiltLinux/linux/issues/1377
[1]: https://reviews.llvm.org/D103048
[2]: https://reviews.llvm.org/D52322

Signed-off-by: Tor Vic <[email protected]>
---
arch/x86/Makefile | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 1f2e5bf..2855a1a 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -192,8 +192,9 @@ endif
KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)

ifdef CONFIG_LTO_CLANG
-KBUILD_LDFLAGS += -plugin-opt=-code-model=kernel \
- -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
+ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
+KBUILD_LDFLAGS += -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
+endif
endif

ifdef CONFIG_X86_NEED_RELOCS
--
2.32.0


2021-06-10 10:08:26

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0

On Thu, Jun 10, 2021 at 11:28:04AM +0200, [email protected] wrote:
> Since LLVM commit 3787ee4, the '-stack-alignment' flag has been dropped [1],
> leading to the following error message when building a LTO kernel with
> Clang-13 and LLD-13:
>
> ld.lld: error: -plugin-opt=-: ld.lld: Unknown command line argument
> '-stack-alignment=8'. Try 'ld.lld --help'
> ld.lld: Did you mean '--stackrealign=8'?
>
> It also appears that the '-code-model' flag is not necessary anymore starting
> with LLVM-9 [2].
>
> Drop '-code-model' and make '-stack-alignment' conditional on LLD < 13.0.0.
>
> This is for linux-stable 5.12.
> Another patch will be submitted for 5.13 shortly (unless there are objections).


<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

2021-06-10 16:46:07

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0

Hi Tor,

On 6/10/2021 2:28 AM, [email protected] wrote:
> Since LLVM commit 3787ee4, the '-stack-alignment' flag has been dropped [1],
> leading to the following error message when building a LTO kernel with
> Clang-13 and LLD-13:
>
> ld.lld: error: -plugin-opt=-: ld.lld: Unknown command line argument
> '-stack-alignment=8'. Try 'ld.lld --help'
> ld.lld: Did you mean '--stackrealign=8'?
>
> It also appears that the '-code-model' flag is not necessary anymore starting
> with LLVM-9 [2].
>
> Drop '-code-model' and make '-stack-alignment' conditional on LLD < 13.0.0.
>
> This is for linux-stable 5.12.
> Another patch will be submitted for 5.13 shortly (unless there are objections).

This patch needs to be accepted into mainline first before it can go to
stable so this line needs to be removed. The rest of the description
looks good to me, good job on being descriptive!

> Discussion: https://github.com/ClangBuiltLinux/linux/issues/1377
> [1]: https://reviews.llvm.org/D103048
> [2]: https://reviews.llvm.org/D52322

As Greg's auto-response points out, there needs to be an actual

Cc: [email protected]

here in the patch, rather than just cc'ing [email protected]
through email.

> Signed-off-by: Tor Vic <[email protected]>

The actual patch itself looks good and I have verified that it fixes the
build error. On the resend with the above fixed, please feel free to add:

Reviewed-by: Nathan Chancellor <[email protected]>
Tested-by: Nathan Chancellor <[email protected]>

> ---
> arch/x86/Makefile | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> index 1f2e5bf..2855a1a 100644
> --- a/arch/x86/Makefile
> +++ b/arch/x86/Makefile
> @@ -192,8 +192,9 @@ endif
> KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
>
> ifdef CONFIG_LTO_CLANG
> -KBUILD_LDFLAGS += -plugin-opt=-code-model=kernel \
> - -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
> +ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
> +KBUILD_LDFLAGS += -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
> +endif
> endif
>
> ifdef CONFIG_X86_NEED_RELOCS
>

Cheers,
Nathan

2021-06-10 18:42:38

by Tor Vic

[permalink] [raw]
Subject: Re: [PATCH] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0

Hi Nathan,

On 10.06.21 16:42, Nathan Chancellor wrote:
> Hi Tor,
>
> On 6/10/2021 2:28 AM, [email protected] wrote:
>> Since LLVM commit 3787ee4, the '-stack-alignment' flag has been
>> dropped [1],
>> leading to the following error message when building a LTO kernel with
>> Clang-13 and LLD-13:
>>
>>      ld.lld: error: -plugin-opt=-: ld.lld: Unknown command line argument
>>      '-stack-alignment=8'.  Try 'ld.lld --help'
>>      ld.lld: Did you mean '--stackrealign=8'?
>>
>> It also appears that the '-code-model' flag is not necessary anymore
>> starting
>> with LLVM-9 [2].
>>
>> Drop '-code-model' and make '-stack-alignment' conditional on LLD <
>> 13.0.0.
>>
>> This is for linux-stable 5.12.
>> Another patch will be submitted for 5.13 shortly (unless there are
>> objections).
>
> This patch needs to be accepted into mainline first before it can go to
> stable so this line needs to be removed. The rest of the description
> looks good to me, good job on being descriptive!
>

Thank you for explaining this.
I wasn't exactly sure how the procedure for stable was.
Does this mean that the patch should be based on 5.13?
I usually use Linus' tree mirrored at GitHub.

>> Discussion: https://github.com/ClangBuiltLinux/linux/issues/1377
>> [1]: https://reviews.llvm.org/D103048
>> [2]: https://reviews.llvm.org/D52322
>
> As Greg's auto-response points out, there needs to be an actual
>
> Cc: [email protected]
>
> here in the patch, rather than just cc'ing [email protected]
> through email.
>

Yes I misinterpreted this in the sense of "put stable mail in CC".
So if I get this right, I should NOT put stable email in CC, but only
add the "Cc: [email protected]" tag above the "Signed-off-by"?

>> Signed-off-by: Tor Vic <[email protected]>
>
> The actual patch itself looks good and I have verified that it fixes the
> build error. On the resend with the above fixed, please feel free to add:
>
> Reviewed-by: Nathan Chancellor <[email protected]>
> Tested-by: Nathan Chancellor <[email protected]>
>
>> ---
>>   arch/x86/Makefile | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
>> index 1f2e5bf..2855a1a 100644
>> --- a/arch/x86/Makefile
>> +++ b/arch/x86/Makefile
>> @@ -192,8 +192,9 @@ endif
>>   KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
>>     ifdef CONFIG_LTO_CLANG
>> -KBUILD_LDFLAGS    += -plugin-opt=-code-model=kernel \
>> -           -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
>> +ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
>> +KBUILD_LDFLAGS    += -plugin-opt=-stack-alignment=$(if
>> $(CONFIG_X86_32),4,8)
>> +endif
>>   endif
>>     ifdef CONFIG_X86_NEED_RELOCS
>>
>
> Cheers,
> Nathan

Thanks for your help!
Tor

2021-06-10 19:19:53

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [PATCH] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0

On Thu, Jun 10, 2021 at 11:39 AM Tor Vic <[email protected]> wrote:
>
> Hi Nathan,
>
> On 10.06.21 16:42, Nathan Chancellor wrote:
> > As Greg's auto-response points out, there needs to be an actual
> >
> > Cc: [email protected]
> >
> > here in the patch, rather than just cc'ing [email protected]
> > through email.
> >
>
> Yes I misinterpreted this in the sense of "put stable mail in CC".
> So if I get this right, I should NOT put stable email in CC, but only
> add the "Cc: [email protected]" tag above the "Signed-off-by"?

Yep, just above the Link: tags would be perfect. Don't worry, you'll
get the hang of it.
--
Thanks,
~Nick Desaulniers

2021-06-10 19:25:20

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [PATCH] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0

On Thu, Jun 10, 2021 at 2:28 AM <[email protected]> wrote:
>
> Since LLVM commit 3787ee4, the '-stack-alignment' flag has been dropped [1],
> leading to the following error message when building a LTO kernel with
> Clang-13 and LLD-13:
>
> ld.lld: error: -plugin-opt=-: ld.lld: Unknown command line argument
> '-stack-alignment=8'. Try 'ld.lld --help'
> ld.lld: Did you mean '--stackrealign=8'?
>
> It also appears that the '-code-model' flag is not necessary anymore starting
> with LLVM-9 [2].
>
> Drop '-code-model' and make '-stack-alignment' conditional on LLD < 13.0.0.

Please include this additional context in v2:
```
These flags were necessary because these flags were not encoded in the
IR properly, so the link would restart optimizations without them. Now
there are properly encoded in the IR, and these flags exposing
implementation details are no longer necessary.
```
That way it doesn't sound like we're not using an 8B stack alignment
on x86; we very much are so; AMDGPU GPFs without it!

Cut the below paragraph out on v2. Thanks for the patch and keep up
the good work!

>
> This is for linux-stable 5.12.
> Another patch will be submitted for 5.13 shortly (unless there are objections).
>
> Discussion: https://github.com/ClangBuiltLinux/linux/issues/1377
> [1]: https://reviews.llvm.org/D103048
> [2]: https://reviews.llvm.org/D52322
>
> Signed-off-by: Tor Vic <[email protected]>
> ---
> arch/x86/Makefile | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> index 1f2e5bf..2855a1a 100644
> --- a/arch/x86/Makefile
> +++ b/arch/x86/Makefile
> @@ -192,8 +192,9 @@ endif
> KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
>
> ifdef CONFIG_LTO_CLANG
> -KBUILD_LDFLAGS += -plugin-opt=-code-model=kernel \
> - -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
> +ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
> +KBUILD_LDFLAGS += -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
> +endif
> endif
>
> ifdef CONFIG_X86_NEED_RELOCS
> --
> 2.32.0



--
Thanks,
~Nick Desaulniers

2021-06-10 20:20:07

by Tor Vic

[permalink] [raw]
Subject: Re: [PATCH] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0



On 10.06.21 19:20, Nick Desaulniers wrote:
> On Thu, Jun 10, 2021 at 2:28 AM <[email protected]> wrote:
>>
>> Since LLVM commit 3787ee4, the '-stack-alignment' flag has been dropped [1],
>> leading to the following error message when building a LTO kernel with
>> Clang-13 and LLD-13:
>>
>> ld.lld: error: -plugin-opt=-: ld.lld: Unknown command line argument
>> '-stack-alignment=8'. Try 'ld.lld --help'
>> ld.lld: Did you mean '--stackrealign=8'?
>>
>> It also appears that the '-code-model' flag is not necessary anymore starting
>> with LLVM-9 [2].
>>
>> Drop '-code-model' and make '-stack-alignment' conditional on LLD < 13.0.0.
>
> Please include this additional context in v2:
> ```
> These flags were necessary because these flags were not encoded in the
> IR properly, so the link would restart optimizations without them. Now
> there are properly encoded in the IR, and these flags exposing
> implementation details are no longer necessary.
> ```
> That way it doesn't sound like we're not using an 8B stack alignment
> on x86; we very much are so; AMDGPU GPFs without it!
>

Will do so.
Does this have to be a v2 (with a "changes from v1" info) or just a
resend? It is based on mainline now and the line numbers have changed.

> Cut the below paragraph out on v2. Thanks for the patch and keep up
> the good work!
>
>>
>> This is for linux-stable 5.12.
>> Another patch will be submitted for 5.13 shortly (unless there are objections).
>>
>> Discussion: https://github.com/ClangBuiltLinux/linux/issues/1377
>> [1]: https://reviews.llvm.org/D103048
>> [2]: https://reviews.llvm.org/D52322
>>
>> Signed-off-by: Tor Vic <[email protected]>
>> ---
>> arch/x86/Makefile | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
>> index 1f2e5bf..2855a1a 100644
>> --- a/arch/x86/Makefile
>> +++ b/arch/x86/Makefile
>> @@ -192,8 +192,9 @@ endif
>> KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
>>
>> ifdef CONFIG_LTO_CLANG
>> -KBUILD_LDFLAGS += -plugin-opt=-code-model=kernel \
>> - -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
>> +ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
>> +KBUILD_LDFLAGS += -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
>> +endif
>> endif
>>
>> ifdef CONFIG_X86_NEED_RELOCS
>> --
>> 2.32.0
>
>
>

2021-06-10 20:45:09

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0

On 6/10/2021 1:16 PM, Tor Vic wrote:
>
>
> On 10.06.21 19:20, Nick Desaulniers wrote:
>> On Thu, Jun 10, 2021 at 2:28 AM <[email protected]> wrote:
>>>
>>> Since LLVM commit 3787ee4, the '-stack-alignment' flag has been dropped [1],
>>> leading to the following error message when building a LTO kernel with
>>> Clang-13 and LLD-13:
>>>
>>> ld.lld: error: -plugin-opt=-: ld.lld: Unknown command line argument
>>> '-stack-alignment=8'. Try 'ld.lld --help'
>>> ld.lld: Did you mean '--stackrealign=8'?
>>>
>>> It also appears that the '-code-model' flag is not necessary anymore starting
>>> with LLVM-9 [2].
>>>
>>> Drop '-code-model' and make '-stack-alignment' conditional on LLD < 13.0.0.
>>
>> Please include this additional context in v2:
>> ```
>> These flags were necessary because these flags were not encoded in the
>> IR properly, so the link would restart optimizations without them. Now
>> there are properly encoded in the IR, and these flags exposing
>> implementation details are no longer necessary.
>> ```
>> That way it doesn't sound like we're not using an 8B stack alignment
>> on x86; we very much are so; AMDGPU GPFs without it!
>>
>
> Will do so.
> Does this have to be a v2 (with a "changes from v1" info) or just a
> resend? It is based on mainline now and the line numbers have changed.

Yes, this should be a v2 because the commit message changed. It would be
considered a resend if nothing changed and the patch just needed to be
picked up rather than re-reviewed.

Cheers,
Nathan

2021-06-11 08:11:51

by David Laight

[permalink] [raw]
Subject: RE: [PATCH] x86/Makefile: make -stack-alignment conditional on LLD < 13.0.0

From: Nick Desaulniers
> Sent: 10 June 2021 20:21
>
> On Thu, Jun 10, 2021 at 2:28 AM <[email protected]> wrote:
> >
> > Since LLVM commit 3787ee4, the '-stack-alignment' flag has been dropped [1],
> > leading to the following error message when building a LTO kernel with
> > Clang-13 and LLD-13:
> >
> > ld.lld: error: -plugin-opt=-: ld.lld: Unknown command line argument
> > '-stack-alignment=8'. Try 'ld.lld --help'
> > ld.lld: Did you mean '--stackrealign=8'?
> >
> > It also appears that the '-code-model' flag is not necessary anymore starting
> > with LLVM-9 [2].
> >
> > Drop '-code-model' and make '-stack-alignment' conditional on LLD < 13.0.0.
>
> Please include this additional context in v2:
> ```
> These flags were necessary because these flags were not encoded in the
> IR properly, so the link would restart optimizations without them. Now
> there are properly encoded in the IR, and these flags exposing
> implementation details are no longer necessary.
> ```
> That way it doesn't sound like we're not using an 8B stack alignment
> on x86; we very much are so; AMDGPU GPFs without it!

Actually, give that LTO is still 'experimental' is it worth just
removing the flags and requiring clang-13 for LTO builds?

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)