[llvmlinux] "make test" for x86_64 target just hung there, why?

Sedat Dilek sedat.dilek at gmail.com
Mon Sep 14 07:04:38 UTC 2015

On Sun, Sep 13, 2015 at 9:17 AM, PaX Team <pageexec at gmail.com> wrote:
> On 13 Sep 2015 at 4:24, Sedat Dilek wrote:
>> On Wed, Sep 9, 2015 at 10:24 PM, PaX Team <pageexec at gmail.com> wrote:
>> > are you sure it's not lib/hweight.o instead? under gcc it's compiled
>> > with special flags (CONFIG_ARCH_HWEIGHT_CFLAGS) which clang doesn't
>> > support and we used to patch that out but i have no idea about the
>> > current state of affairs.
>> >
>> Hi pipacs,
>> YES, you are right!
>> One of your patches for x86_64 got archived [1] but is still required
>> to build x86_64 arch correctly.
> interesting, Jan-Simon said that patch was still part of the llvmlinux
> tree (it is really mandatory for clang) so i'm not sure what's going on.

[ CC Jan-Simon ]

So PAX Team confirms that the patch in [3] is still *mandatory* for
x86_64 arch (together with the patch in [2]) to get a bootable

Jan-Simon - as an x86_64 LLVMLinux expert - can you please give a
*clear* statement on this?

If it is in your eyes *not mandatory* to get a bootable Linux-kernel...
...can you please comment on how you got managed to have a *bootable*
"Bootable" here means booting on bare metal (God saves Bryce for this term).


>> Shouldn't your patch go upstream?
> well, certainly not in this form as it disables an otherwise useful
> optimization (popcnt vs. call to helper). the real/best solution would
> be if clang (or more like llvm in this case) added some support for
> changing the calling conventions via the fcall-saved-REG (and other
> similar) switches but IIRC there was a discussion (or bugzilla entry?)
> about it and the devs weren't in favour of this gcc feature as it
> punched a hole through too many abstraction layers for their taste.

For the sake of completeness...

This was reported as *LLVM PR #9457*...

"Bug 9457 - clang's missing -ffixed-REG, -fcall-used-REG, -fcall-saved-REG"

...and the patch "hweight-x86.patch" in LLVMLinux [2] points to it.

I can confirm again and again that for Linux x86_64 arch both patches
[2] and [3] are required to get a bootable Linux-kernel here (here
means Ubuntu/precise AMD64).

> on the linux side the best (as in, probably upstreamable) fix would be to
> extend and make use of the thunking layer in arch/x86/entry/thunk_{32,64}.S
> as they properly save/restore the necessary registers (modulo eax/rax
> which are needed for the return value) that the above gcc switch would
> induce too.

A vital discussion has started in the thread...

"[llvmlinux] [PATCH] x86/hweight: LLVMLinux: Fix __arch_hweight{32,
64}() for compilation with clang"

...for more details see September 2015 offline ML llvmlinux archive [4].

Thanks to all involved people.

- Sedat -

P.S.: References

[1] https://llvm.org/bugs/show_bug.cgi?id=9457
[2] http://git.linuxfoundation.org/?p=llvmlinux.git;a=blob;f=arch/x86_64/patches/hweight-x86.patch
[3] http://git.linuxfoundation.org/?p=llvmlinux.git;a=blob_plain;f=arch/x86_64/patches/ARCHIVE/0029-Fix-ARCH_HWEIGHT-for-compilation-with-clang.patch;hb=HEAD
[4] http://lists.linuxfoundation.org/pipermail/llvmlinux/2015-September/thread.html

More information about the LLVMLinux mailing list