Re: Clang patch stacks for LTS kernels (v4.4 and v4.9) and status update

From: Sedat Dilek
Date: Sun May 06 2018 - 03:58:32 EST


On Sun, May 6, 2018 at 9:41 AM, Dmitry Vyukov <dvyukov@xxxxxxxxxx> wrote:
> On Sun, May 6, 2018 at 8:35 AM, Sedat Dilek <sedat.dilek@xxxxxxxxx> wrote:
>> On Mon, Apr 23, 2018 at 7:42 PM, Matthias Kaehlcke <mka@xxxxxxxxxxxx> wrote:
>> [...]
>>>> [ ASM-GOTO ]
>>>>
>>>> Foremore, I have seen you have a "refs/sandbox/mka/llvm/v4.14" Git branch.
>>>> Linux v4.14 is also an LTS release.
>>>
>>> Yes, there is also a follow up post:
>>> https://lkml.org/lkml/2017/11/22/943
>>>
>>>> After Linux v4.9 "asm-goto" support was added which is GCC specific.
>>>
>>> asm-goto was optional until a few weeks ago, when x86 maintainers
>>> decided to make it mandatory, and thus break clang builds for x86:
>>>
>>> https://lkml.org/lkml/2018/4/2/486
>>>
>>>> Is there a workaround to compile Linux-kernel with any CLANG
>>>> version?
>>>
>>> You could revert the patch that makes asm-goto mandatory.
>>>
>>>> You happen to know the status in LLVM upstream?
>>>
>>> I know people are actively working on this, but don't know an ETA.
>>>
>>
>> [ CC Dimitry ]
>>
>> Sorry for the late response.
>> This weekend I had some time to play with clang-7 and Linux-4.17-rcN.
>>
>> I tried with Linux v4.17-rc3-261-gc1c07416cdd4 and reverted the
>> mandatory patch [1].
>>
>> commit e501ce957a786ecd076ea0cfb10b114e6e4d0f40
>> "x86: Force asm-goto"
>>
>> This needed a follow up [2]...
>>
>> commit d0266046ad54e0c964941364cd82a0d0478ce286
>> "x86: Remove FAST_FEATURE_TESTS"
>>
>> ...but breaks my build.
>>
>> That seems to be a known issue [3] and Dimitry bisected this to [4].
>> Is there a fix for this?
>>
>> I have attached my kernel-config and the broken build-log.
>>
>> Hope this helps.
>>
>> Regards,
>> - Sedat -
>>
>> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e501ce957a786ecd076ea0cfb10b114e6e4d0f40
>> [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/x86/include/asm/cpufeature.h?id=d0266046ad54e0c964941364cd82a0d0478ce286
>> [3] https://www.spinics.net/lists/linux-mm/msg147669.html
>> [4] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8bf705d130396e69c04cd8e6e010244ad2ce71f4
>
>
> Hi Sedat,
>
> Sorry for the breakage.
>
> This was reported and discussed here:
> https://groups.google.com/forum/#!topic/kasan-dev/oMgCP37n1vw
> The plan is to make clang behave the same way as gcc wrt asm
> constraint checking. But I don't know what's the progress.

Hi Dimitry,

that's the thread I looked into and also looked into the involved
commits and appropriate files in the linux-source without knowing of
[1].

Just just for the records...
I used the kernel-config of Debian's
linux-image-4.17.0-rc3-amd64-unsigned (4.17~rc3-1~exp1) as a base with
this modification:

$ cd /path/to/linux-source
$ LINUX_CONFIG="./.config"
$ scripts/config --file $LINUX_CONFIG --disable X86_X32

...and...

# CONFIG_KASAN is not set

...if this matters.

Kind regards,
- Sedat -

[1] https://bugs.llvm.org/show_bug.cgi?id=33587
[2] https://packages.debian.org/experimental/linux-image-4.17.0-rc3-amd64-unsigned