clangbuiltlinux / linux Goto Github PK
View Code? Open in Web Editor NEWThis project forked from torvalds/linux
Linux kernel source tree
License: Other
This project forked from torvalds/linux
Linux kernel source tree
License: Other
upstream bug: https://llvm.org/pr33587
TL;DR
Clang will validate extended inline assembly, even if the code gets compiled out. This conflicts with some macros that involve switching on the sizeof a type.
The validity check is done early in the front-end partly because the backend (as it stands today) cannot handle inline-asm instructions that have constraints that are not valid for the input or output operands
Kernel: 4.16.2 x86_64
LLVM/Clang: 6.0.0
Building Linux with clang with stack protection and paravirt guest support makes the kernel unbootable under qemu/kvm.
Relevant config:
CONFIG_HAVE_CC_STACKPROTECTOR=y
CONFIG_CC_STACKPROTECTOR=y
CONFIG_CC_STACKPROTECTOR_STRONG=y
CONFIG_HYPERVISOR_GUEST=y
CONFIG_PARAVIRT=y
Kernel panic:
[ 0.000000] Kernel command line: console=ttyS0 earlyprintk=ttyS0 root=/dev/sda1 init=/bin/sh
[ 0.000000] Memory: 490684K/523888K available (12300K kernel code, 1212K rwdata, 3136K rodata, 1768K init, 664K bss, 33204K reserved, 0K cma-reserved)
[ 0.000000] BUG: unable to handle kernel paging request at ffff97089f651a78
[ 0.000000] IP: get_page_from_freelist+0xcda/0x2160
[ 0.000000] PGD 1a607067 P4D 1a607067 PUD 0
[ 0.000000] Oops: 0000 [#1] SMP PTI
[ 0.000000] Modules linked in:
[ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.16.2-generic #19
[ 0.000000] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
[ 0.000000] RIP: 0010:get_page_from_freelist+0xcda/0x2160
[ 0.000000] RSP: 0000:ffffffff9fa039a8 EFLAGS: 00010086
[ 0.000000] RAX: ffff97089f651a78 RBX: ffffffff9fa03d10 RCX: a29848eeb7fa3300
[ 0.000000] RDX: ffffffffb7fa3300 RSI: 0000000000000000 RDI: ffff970d1fff95c0
[ 0.000000] RBP: ffffffff9fa03c48 R08: 0000000000000000 R09: 0000000000000080
[ 0.000000] R10: 0000000000000008 R11: 0000000000000020 R12: ffff970d1fc1ea68
[ 0.000000] R13: fffffffb7fa33000 R14: 0000000000000086 R15: ffff970d1fff95c0
[ 0.000000] FS: 0000000000000000(0000) GS:ffff970d1fc00000(0000) knlGS:0000000000000000
[ 0.000000] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 0.000000] CR2: ffff97089f651a78 CR3: 000000001a008000 CR4: 00000000000006b0
[ 0.000000] Call Trace:
[ 0.000000] ? vsnprintf+0x25b/0x740
[ 0.000000] ? sprintf+0x63/0x80
[ 0.000000] ? __raw_callee_save___native_queued_spin_unlock+0x11/0x1e
[ 0.000000] ? io_serial_in+0x10/0x10
[ 0.000000] ? number+0x141/0x4a0
[ 0.000000] ? __raw_callee_save___native_queued_spin_unlock+0x11/0x1e
[ 0.000000] ? __raw_callee_save___native_queued_spin_unlock+0x11/0x1e
[ 0.000000] ? __raw_callee_save___native_queued_spin_unlock+0x11/0x1e
[ 0.000000] __alloc_pages_nodemask+0x16a/0x14e0
[ 0.000000] ? vsnprintf+0x25b/0x740
[ 0.000000] ? sprintf+0x63/0x80
[ 0.000000] ? __raw_callee_save___native_queued_spin_unlock+0x11/0x1e
[ 0.000000] new_slab+0xb5/0x6b0
[ 0.000000] ? _raw_read_unlock_irqrestore+0x1c/0x20
[ 0.000000] __kmem_cache_create+0x186/0x630
[ 0.000000] ? printk+0x62/0x80
[ 0.000000] create_boot_cache+0xa4/0xd0
[ 0.000000] kmem_cache_init+0x4b/0x250
[ 0.000000] start_kernel+0x2e3/0x550
[ 0.000000] secondary_startup_64+0xa5/0xb0
[ 0.000000] Code: a2 9f 49 89 c6 ff 14 25 68 18 a2 9f 4d 8b 67 50 65 4c 03 24 25 68 f1 00 00 48 63 d1 49 89 d5 49 c1 e5 04 4b 8d 04 2c 48 83 c0 10 <4f> 8b 4c 2c 10 4c 39 c8 0f 85 3b 0f 00 00 48 89 55 80 48 89 45
[ 0.000000] RIP: get_page_from_freelist+0xcda/0x2160 RSP: ffffffff9fa039a8
[ 0.000000] CR2: ffff97089f651a78
[ 0.000000] ---[ end trace 5e6b89e544c81208 ]---
Kernel boots successfully when disabling either the stack-protector or the paravirt/kvm support.
Any ideas?
CC fs/cachefiles/namei.o
fs/cachefiles/namei.c:247:50: warning: implicit conversion from enumeration type 'enum cachefiles_obj_ref_trace' to different enumeration type 'enum fscache_obj_ref_trace'
[-Wenum-conversion]
cache->cache.ops->put_object(&xobject->fscache, cachefiles_obj_put_wait_retry);
~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/cachefiles/namei.c:251:50: warning: implicit conversion from enumeration type 'enum cachefiles_obj_ref_trace' to different enumeration type 'enum fscache_obj_ref_trace'
[-Wenum-conversion]
cache->cache.ops->put_object(&xobject->fscache, cachefiles_obj_put_wait_timeo);
~~~~~
ARMv8 added support for register prefixes "w" (eg w0, w1) for lower 32b and "x" (eg x0, x1) for full 64b of the same register. GCC also supports the ARMv7 "r" prefixes, but clang complains for ARMv8 that this is ambiguous.
LLVM Bug: https://llvm.org/pr36862
Chromium Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=824526
Example Android workaround: https://android-review.googlesource.com/c/kernel/common/+/645181
Details in this discussion: https://lore.kernel.org/r/[email protected]/
Workaround patch: https://lore.kernel.org/r/[email protected]
as reported on: https://lore.kernel.org/r/[email protected]/
A patch is under testing for LLVM
It was reported that the following error was encountered:
$ make HOSTCC=clang CC=clang -j32 ARCH=x86_64 prepare
...
scripts/kconfig/conf --silentoldconfig Kconfig
Makefile:965: *** "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel". Stop.
But the latest libelf-dev has been installed with version 0.170-0.4.
Reported-by: Hao, Shun [email protected]
example:
➜ kernel-all git:(master) ✗ cat test.S
var_xdata = %rcx
xorq var_xdata, var_xdata
➜ kernel-all git:(master) ✗ gcc -c test.S
➜ kernel-all git:(master) ✗ objdump -D test.o
test.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <.text>:
0: 48 31 c9 xor %rcx,%rcx
➜ kernel-all git:(master) ✗ clang -c test.S
test.S:1:13: error: unknown token in expression
var_xdata = %rcx
^
test.S:1:13: error: missing expression
var_xdata = %rcx
^
test.S:3:17: error: invalid operand for instruction
xorq var_xdata, var_xdata
^
CC drivers/dma/xilinx/zynqmp_dma.o
drivers/dma/xilinx/zynqmp_dma.c:166:4: warning: attribute 'aligned' is ignored, place
it after "struct" to apply attribute to type declaration [-Wignored-attributes]
}; __aligned(64)
^
./include/linux/compiler_types.h:200:38: note: expanded from macro '__aligned'
#define __aligned(x) __attribute__((aligned(x)))
^
CONFIG_XILINX_DMA=y
should be on the other side of the ;
(oops!)
Report from QC:
xyz.c:(.text+0x1804): undefined reference to `llvm_gcda_emit_function'
xyz.c:(.text+0x1814): undefined reference to `llvm_gcda_emit_arcs'
xyz.c:(.text+0x1834): undefined reference to `llvm_gcda_emit_function'
xyz.c:(.text+0x1844): undefined reference to `llvm_gcda_emit_arcs'
xyz.c:(.text+0x1848): undefined reference to `llvm_gcda_summary_info'
xyz.c:(.text+0x1858): undefined reference to `llvm_gcda_end_file'
xyz.o: In function `__llvm_gcov_init':
xyz.c:(.text+0x1a28): undefined reference to `llvm_gcov_init'
it would be good how to avoid bugs like: https://lore.kernel.org/r/[email protected]/
where aggressive inlining removed NULL ptr checks.
The hardened usercopy whitelisting (CONFIG_HARDENED_USERCOPY=y) depends on constant-sized arguments to copy_to_user()/copy_from_user() to be implicitly whitelisted. Without this, there is both a performance hit (for doing dynamic checking when none is needed) and failures (when an implicit whitelist is used with static sizes). For example, on x86, this happens under clang-5.0 but not gcc:
[ 1.628046] ------------[ cut here ]------------
[ 1.628524] Bad or missing usercopy whitelist? Kernel memory exposure attempt detected from SLUB object 'task_struct' (offset 1728, size 8)!
[ 1.629772] WARNING: CPU: 3 PID: 1208 at mm/usercopy.c:81 usercopy_warn+0x96/0xa0
[ 1.630514] Modules linked in:
[ 1.630519] CPU: 3 PID: 1208 Comm: sh Not tainted 4.16.0-rc5+ #64
[ 1.630520] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
[ 1.630522] RIP: 0010:usercopy_warn+0x96/0xa0
[ 1.630523] RSP: 0018:ffff9c1781a73ce8 EFLAGS: 00010286
[ 1.630526] RAX: 947d865a0fb2e100 RBX: ffffffff96310daf RCX: ffffffff9665cdd0
[ 1.630527] RDX: ffffffff94edcfb7 RSI: ffffffff9665cd78 RDI: ffffffff94edcff8
[ 1.630528] RBP: ffff9c1781a73cf0 R08: 0000000000000000 R09: 0000000000000000
[ 1.630529] R10: 0000000000000002 R11: 0000000000000000 R12: ffff966a6bf6b3c8
[ 1.630530] R13: 0000000000000000 R14: 0000000000000008 R15: 0000000000000001
[ 1.630532] FS: 00007fc896687700(0000) GS:ffff966a7fd80000(0000) knlGS:0000000000000000
[ 1.630533] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1.630534] CR2: 00007ffc730a5d1c CR3: 000000042a81c001 CR4: 00000000001606e0
[ 1.630537] Call Trace:
[ 1.630541] __check_object_size+0xc3/0x1c0
[ 1.646723] do_signal+0x48e/0x5f0
[ 1.647127] prepare_exit_to_usermode+0xeb/0x170
[ 1.647742] syscall_return_slowpath+0x5e/0x2b0
[ 1.648240] ? syscall_trace_enter+0x15d/0x350
[ 1.648730] entry_SYSCALL_64_after_hwframe+0x42/0xb7
[ 1.649305] RIP: 0033:0x7fc89618012a
[ 1.649694] RSP: 002b:00007ffe56f8ec58 EFLAGS: 00000246 ORIG_RAX: 000000000000003d
[ 1.650522] RAX: 00000000000004bf RBX: 0000000000000001 RCX: 00007fc89618012a
[ 1.651294] RDX: 0000000000000000 RSI: 00007ffe56f8ec7c RDI: 00000000ffffffff
[ 1.652067] RBP: 0000563ebd2f63e0 R08: 0000000000000000 R09: 00007fc896687700
[ 1.652827] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
[ 1.653586] R13: 00007ffe56f8ec7c R14: 00007ffe56f90fb3 R15: 0000000000000000
[ 1.654361] Code: 96 4c 0f 44 c0 4c 0f 44 c8 48 c7 c3 af 0d 31 96 48 0f 44 d8 48 c7 c7 31 0d 31 96 31 c0 41 52 41 53 53 e8 4e 2b e5 ff 48 83 c4 18 <0f> 0b 5b 5d c3 0f 1f 44 00 00 0f 1f 44 00 00 55 48 89 e5 53 4d
[ 1.656441] ---[ end trace aa26781ca73156e1 ]---
This is from arch/x86/kernel/signal.c do_signal+0x48e/0x5f0:
copy_user_generic at arch/x86/include/asm/uaccess_64.h:37
(inlined by) raw_copy_to_user at arch/x86/include/asm/uaccess_64.h:112
(inlined by) __copy_to_user at include/linux/uaccess.h:105
(inlined by) __setup_rt_frame at arch/x86/kernel/signal.c:493
(inlined by) setup_rt_frame at arch/x86/kernel/signal.c:699
(inlined by) handle_signal at arch/x86/kernel/signal.c:743
(inlined by) do_signal at arch/x86/kernel/signal.c:811
specifically __setup_rt_frame():
err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
Last argument is sizeof(*set), which should be true for __builtin_constant_p() in __copy_to_user():
static __always_inline unsigned long
__copy_to_user(void __user *to, const void *from, unsigned long n)
{
might_fault();
kasan_check_read(from, n);
check_object_size(from, n, true);
return raw_copy_to_user(to, from, n);
}
static __always_inline void check_object_size(const void *ptr, unsigned long n,
bool to_user)
{
if (!__builtin_constant_p(n))
__check_object_size(ptr, n, to_user);
}
check_object_size()'s n is __copy_to_user()'s n is __setup_rt_frame()'s sizeof(*set).
I'm trying to build 32-bit x86 kernel from android-4.14 branch of AOSP
https://android.googlesource.com/kernel/common with
AOSP's prebuilt clang-4053586 (in the Oreo release):
make CC=clang HOSTCC=clang CLANG_TRIPLE=x86_64-linux-gnu- CROSS_COMPILE=x86_64-linux-androidkernel- bzImage modules
I saw the errors. Not sure what it means.
....
CC kernel/events/core.o
CC [M] fs/cifs/netmisc.o
CC mm/frame_vector.o
CC mm/usercopy.o
/home/cwhuang/git/android-x86-8.1/kernel/kernel/events/core.c:520:16: error: invalid output size for constraint '=q'
running_len = __this_cpu_read(running_sample_length);
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:433:2: note: expanded from macro '_this_cpu_read'
raw_cpu_read(pcp);
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:407:28: note: expanded from macro 'raw_cpu_read'
#define raw_cpu_read(pcp) pcpu_size_call_return(raw_cpu_read, pcp)
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:308:23: note: expanded from macro 'pcpu_size_call_return'
case 1: pscr_ret = stem##1(variable); break;
^
:262:1: note: expanded from here
raw_cpu_read_1
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:394:30: note: expanded from macro 'raw_cpu_read_1'
#define raw_cpu_read_1(pcp) percpu_from_op("mov", pcp)
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:189:15: note: expanded from macro 'percpu_from_op'
: "=q" (pfo_ret)
^
/home/cwhuang/git/android-x86-8.1/kernel/kernel/events/core.c:520:16: error: invalid output size for constraint '=q'
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:433:2: note: expanded from macro '_this_cpu_read'
raw_cpu_read(pcp);
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:407:28: note: expanded from macro 'raw_cpu_read'
#define raw_cpu_read(pcp) pcpu_size_call_return(raw_cpu_read, pcp)
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:309:23: note: expanded from macro 'pcpu_size_call_return'
case 2: pscr_ret = stem##2(variable); break;
^
:264:1: note: expanded from here
raw_cpu_read_2
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:395:30: note: expanded from macro 'raw_cpu_read_2'
#define raw_cpu_read_2(pcp) percpu_from_op("mov", pcp)
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:189:15: note: expanded from macro 'percpu_from_op'
: "=q" (pfo_ret)
^
/home/cwhuang/git/android-x86-8.1/kernel/kernel/events/core.c:520:16: error: invalid output size for constraint '=q'
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:433:2: note: expanded from macro '_this_cpu_read'
raw_cpu_read(pcp);
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:407:28: note: expanded from macro 'raw_cpu_read'
#define raw_cpu_read(pcp) pcpu_size_call_return(raw_cpu_read, pcp)
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:310:23: note: expanded from macro 'pcpu_size_call_return'
case 4: pscr_ret = stem##4(variable); break;
^
:264:1: note: expanded from here
raw_cpu_read_4
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:396:30: note: expanded from macro 'raw_cpu_read_4'
#define raw_cpu_read_4(pcp) percpu_from_op("mov", pcp)
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:189:15: note: expanded from macro 'percpu_from_op'
: "=q" (pfo_ret)
^
/home/cwhuang/git/android-x86-8.1/kernel/kernel/events/core.c:523:2: error: invalid input size for constraint 'qi'
__this_cpu_write(running_sample_length, running_len);
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:439:2: note: expanded from macro '__this_cpu_write'
raw_cpu_write(pcp, val);
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:408:34: note: expanded from macro 'raw_cpu_write'
#define raw_cpu_write(pcp, val) _pcpu_size_call(raw_cpu_write, pcp, val)
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:364:11: note: expanded from macro 'pcpu_size_call'
case 1: stem##1(variable, VA_ARGS);break;
^
:264:1: note: expanded from here
raw_cpu_write_1
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:398:35: note: expanded from macro 'raw_cpu_write_1'
#define raw_cpu_write_1(pcp, val) percpu_to_op("mov", (pcp), val)
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:102:15: note: expanded from macro 'percpu_to_op'
: "qi" ((pto_T)(val)));
^
/home/cwhuang/git/android-x86-8.1/kernel/kernel/events/core.c:523:2: error: invalid input size for constraint 'qi'
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:439:2: note: expanded from macro '__this_cpu_write'
raw_cpu_write(pcp, val);
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:408:34: note: expanded from macro 'raw_cpu_write'
#define raw_cpu_write(pcp, val) _pcpu_size_call(raw_cpu_write, pcp, val)
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:365:11: note: expanded from macro 'pcpu_size_call'
case 2: stem##2(variable, VA_ARGS);break;
^
:264:1: note: expanded from here
raw_cpu_write_2
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:399:35: note: expanded from macro 'raw_cpu_write_2'
#define raw_cpu_write_2(pcp, val) percpu_to_op("mov", (pcp), val)
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:102:15: note: expanded from macro 'percpu_to_op'
: "qi" ((pto_T)(val)));
^
/home/cwhuang/git/android-x86-8.1/kernel/kernel/events/core.c:523:2: error: invalid input size for constraint 'qi'
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:439:2: note: expanded from macro '__this_cpu_write'
raw_cpu_write(pcp, val);
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:408:34: note: expanded from macro 'raw_cpu_write'
#define raw_cpu_write(pcp, val) _pcpu_size_call(raw_cpu_write, pcp, val)
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:366:11: note: expanded from macro 'pcpu_size_call'
case 4: stem##4(variable, VA_ARGS);break;
^
:264:1: note: expanded from here
raw_cpu_write_4
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:400:35: note: expanded from macro 'raw_cpu_write_4'
#define raw_cpu_write_4(pcp, val) percpu_to_op("mov", (pcp), val)
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:102:15: note: expanded from macro 'percpu_to_op'
: "qi" ((pto_T)(val)));
^
/home/cwhuang/git/android-x86-8.1/kernel/kernel/events/core.c:3570:2: error: invalid input size for constraint 'qi'
__this_cpu_inc(perf_throttled_seq);
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:484:30: note: expanded from macro '__this_cpu_inc'
#define __this_cpu_inc(pcp) __this_cpu_add(pcp, 1)
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:445:2: note: expanded from macro '_this_cpu_add'
raw_cpu_add(pcp, val);
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:409:32: note: expanded from macro 'raw_cpu_add'
#define raw_cpu_add(pcp, val) pcpu_size_call(raw_cpu_add, pcp, val)
^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
:185:1: note: expanded from here
raw_cpu_add_1
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:401:34: note: expanded from macro 'raw_cpu_add_1'
#define raw_cpu_add_1(pcp, val) percpu_add_op((pcp), val)
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:147:16: note: expanded from macro 'percpu_add_op'
: "qi" ((pao_T)(val)));
^
/home/cwhuang/git/android-x86-8.1/kernel/kernel/events/core.c:3570:2: error: invalid input size for constraint 'qi'
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:484:30: note: expanded from macro '__this_cpu_inc'
#define __this_cpu_inc(pcp) __this_cpu_add(pcp, 1)
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:445:2: note: expanded from macro '_this_cpu_add'
raw_cpu_add(pcp, val);
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:409:32: note: expanded from macro 'raw_cpu_add'
#define raw_cpu_add(pcp, val) pcpu_size_call(raw_cpu_add, pcp, val)
^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
:191:1: note: expanded from here
raw_cpu_add_2
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:402:34: note: expanded from macro 'raw_cpu_add_2'
#define raw_cpu_add_2(pcp, val) percpu_add_op((pcp), val)
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:147:16: note: expanded from macro 'percpu_add_op'
: "qi" ((pao_T)(val)));
^
/home/cwhuang/git/android-x86-8.1/kernel/kernel/events/core.c:3570:2: error: invalid input size for constraint 'qi'
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:484:30: note: expanded from macro '__this_cpu_inc'
#define __this_cpu_inc(pcp) __this_cpu_add(pcp, 1)
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:445:2: note: expanded from macro '_this_cpu_add'
raw_cpu_add(pcp, val);
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:409:32: note: expanded from macro 'raw_cpu_add'
#define raw_cpu_add(pcp, val) pcpu_size_call(raw_cpu_add, pcp, val)
^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
:191:1: note: expanded from here
raw_cpu_add_4
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:403:34: note: expanded from macro 'raw_cpu_add_4'
#define raw_cpu_add_4(pcp, val) percpu_add_op((pcp), val)
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:147:16: note: expanded from macro 'percpu_add_op'
: "qi" ((pao_T)(val)));
^
CC [M] fs/btrfs/transaction.o
CC kernel/events/ring_buffer.o
/home/cwhuang/git/android-x86-8.1/kernel/kernel/events/core.c:7433:8: error: invalid output size for constraint '=q'
seq = __this_cpu_read(perf_throttled_seq);
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:433:2: note: expanded from macro '_this_cpu_read'
raw_cpu_read(pcp);
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:407:28: note: expanded from macro 'raw_cpu_read'
#define raw_cpu_read(pcp) pcpu_size_call_return(raw_cpu_read, pcp)
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:308:23: note: expanded from macro 'pcpu_size_call_return'
case 1: pscr_ret = stem##1(variable); break;
^
:11:1: note: expanded from here
raw_cpu_read_1
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:394:30: note: expanded from macro 'raw_cpu_read_1'
#define raw_cpu_read_1(pcp) percpu_from_op("mov", pcp)
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:189:15: note: expanded from macro 'percpu_from_op'
: "=q" (pfo_ret)
^
/home/cwhuang/git/android-x86-8.1/kernel/kernel/events/core.c:7433:8: error: invalid output size for constraint '=q'
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:433:2: note: expanded from macro '_this_cpu_read'
raw_cpu_read(pcp);
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:407:28: note: expanded from macro 'raw_cpu_read'
#define raw_cpu_read(pcp) pcpu_size_call_return(raw_cpu_read, pcp)
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:309:23: note: expanded from macro 'pcpu_size_call_return'
case 2: pscr_ret = stem##2(variable); break;
^
:13:1: note: expanded from here
raw_cpu_read_2
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:395:30: note: expanded from macro 'raw_cpu_read_2'
#define raw_cpu_read_2(pcp) percpu_from_op("mov", pcp)
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:189:15: note: expanded from macro 'percpu_from_op'
: "=q" (pfo_ret)
^
/home/cwhuang/git/android-x86-8.1/kernel/kernel/events/core.c:7433:8: error: invalid output size for constraint '=q'
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:433:2: note: expanded from macro '_this_cpu_read'
raw_cpu_read(pcp);
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:407:28: note: expanded from macro 'raw_cpu_read'
#define raw_cpu_read(pcp) pcpu_size_call_return(raw_cpu_read, pcp)
^
/home/cwhuang/git/android-x86-8.1/kernel/include/linux/percpu-defs.h:310:23: note: expanded from macro 'pcpu_size_call_return'
case 4: pscr_ret = stem##4(variable); break;
^
:13:1: note: expanded from here
raw_cpu_read_4
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:396:30: note: expanded from macro 'raw_cpu_read_4'
#define raw_cpu_read_4(pcp) percpu_from_op("mov", pcp)
^
/home/cwhuang/git/android-x86-8.1/kernel/arch/x86/include/asm/percpu.h:189:15: note: expanded from macro 'percpu_from_op'
: "=q" (pfo_ret)
^
12 errors generated.
since this is not a hard fork, it would be good to automate pulling updates from upstream. A quick search looks like https://backstroke.co/ is a service that may help.
Building ARM32 with function tracing enabled currently fails at linking stage:
LD vmlinux.o
MODPOST vmlinux.o
kernel/softirq.o: In function `_local_bh_enable':
/home/ags/projects/toradex/imx/linux-vanilla-llvm/kernel/softirq.c:152:
undefined reference to `mcount'
kernel/softirq.o: In function `__local_bh_enable_ip':
/home/ags/projects/toradex/imx/linux-vanilla-llvm/kernel/softirq.c:159:
undefined reference to `mcount'
kernel/softirq.o: In function `do_softirq':
/home/ags/projects/toradex/imx/linux-vanilla-llvm/kernel/softirq.c:316:
undefined reference to `mcount'
kernel/softirq.o: In function `irq_enter':
/home/ags/projects/toradex/imx/linux-vanilla-llvm/kernel/softirq.c:337:
undefined reference to `mcount'
kernel/softirq.o: In function `irq_exit':
/home/ags/projects/toradex/imx/linux-vanilla-llvm/kernel/softirq.c:395:
undefined reference to `mcount'
@kees has sent a patch upstream: https://patchwork.kernel.org/patch/10311617/
CC drivers/dma/ep93xx_dma.o
In file included from drivers/dma/ep93xx_dma.c:30:
./include/linux/platform_data/dma-ep93xx.h:88:10: warning: implicit conversion from
enumeration type 'enum dma_data_direction' to different enumeration type 'enum
dma_transfer_direction' [-Wenum-conversion]
return DMA_NONE;
~~~~~~ ^~~~~~~~
CONFIG_EP93XX_DMA=y
CC drivers/clk/berlin/berlin2-avpll.o
/tmp/berlin2-avpll-3020f5.s: Assembler messages:
/tmp/berlin2-avpll-3020f5.s:1441: Warning: entity size for SHF_MERGE not specified
sk_reuseport_convert_ctx_access
has a compiletime assert:
7284 BUILD_BUG_ON(hweight_long(SK_FL_PROTO_MASK) != BITS_PER_BYTE);
This is producing a linker error, which means that the assertion is failing, for some reason.
If you comment out the assertion, you can successfully link the kernel, but something is probably wrong.
gcc is adding a way to specify that certain registers should be zero'd. Let's see if llvm will entertain such a feature.
gcc patch: https://github.com/clearlinux-pkgs/gcc/blob/master/zero-regs-gcc8.patch
llvm feature request: https://llvm.org/pr37880
I just remove this option and it works fine without it.
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index fa3f439..293fa4c 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -47,7 +47,7 @@ targets += $(vdso_img_sodbg) $(vdso_img-y:%=vdso%.so)
CPPFLAGS_vdso.lds += -P -C
VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 --no-undefined \
- -z max-page-size=4096 -z common-page-size=4096
+ -z max-page-size=4096
$(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE
$(call if_changed,vdso)
@@ -92,7 +92,7 @@ CFLAGS_REMOVE_vvar.o = -pg
CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds)
VDSO_LDFLAGS_vdsox32.lds = -m elf32_x86_64 -soname linux-vdso.so.1 \
- -z max-page-size=4096 -z common-page-size=4096
+ -z max-page-size=4096
# x32-rebranded versions
vobjx32s-y := $(vobjs-y:.o=-x32.o)
clang-7 has a new warning that gets printed in a lot of translation units.
Patch series for THIS_IP: https://lore.kernel.org/r/[email protected]/
Need to follow up on consolidating current_text_addr.
As of commit cafa0010cd51 ("Raise the minimum required gcc version to 4.6"), the kernel will now refuse to build the kernel with clang, with the following error:
./include/linux/compiler-gcc.h:14:3: error: Sorry, your compiler is too old - please
upgrade it.
# error Sorry, your compiler is too old - please upgrade it.
^
That is because clang defines itself to look like gcc 4.2.1.
I've sent a patch to llvm to upgrade this to 8.2: https://reviews.llvm.org/D51011
We got lucky that this wasn't breaking before. I think we'll need something more clever in include/linux/compiler_types.h
for this.
Ideas:
#include <linux/compiler-gcc.h>
in compiler_types.h
if __clang__
is defined.#undef __GNUC__
and redefine them before including compiler-gcc.h
if clang. CC security/keys/trusted.o
security/keys/trusted.c:146:17: warning: passing an object that undergoes default
argument promotion to 'va_start' has undefined behavior [-Wvarargs]
va_start(argp, h3);
^
security/keys/trusted.c:126:37: note: parameter of type 'unsigned char' is declared
here
unsigned char *h2, unsigned char h3, ...)
^
guessing this requires CONFIG_TRUSTED_KEYS=y
CC drivers/crypto/ccp/sp-platform.o
drivers/crypto/ccp/sp-platform.c:36:36: warning: tentative array definition assumed to
have one element
static const struct acpi_device_id sp_acpi_match[];
^
I have never seen this construct before.
Probably needs to be defined to length 1
, but it's used case needs to be checked (I have not yet done so). cc @kees
Maybe needs CONFIG_CRYPTO_DEV_SP_CCP=y
.
Compiling Linux v4.19-rc1 for ARM32 fails due to missing __naked preprocessor define.
$ make CC=clang HOSTCC=clang
CALL scripts/checksyscalls.sh
<stdin>:1332:2: warning: syscall io_pgetevents not implemented [-W#warnings]
#warning syscall io_pgetevents not implemented
^
1 warning generated.
CHK include/generated/compile.h
CC arch/arm/mach-exynos/mcpm-exynos.o
arch/arm/mach-exynos/mcpm-exynos.c:193:13: error: variable has incomplete type 'void'
static void __naked exynos_pm_power_up_setup(unsigned int affinity_level)
^
drivers/block/drbd/* has tons of warnings like:
In file included from drivers/block/drbd/drbd_actlog.c:30:
In file included from drivers/block/drbd/drbd_int.h:48:
In file included from ./include/linux/drbd_genl_api.h:54:
In file included from ./include/linux/genl_magic_struct.h:236:
./include/linux/drbd_genl.h:317:1: warning: no case matching constant switch condition
'0'
GENL_struct(DRBD_NLA_NOTIFICATION_HEADER, 23, drbd_notification_header,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/genl_magic_struct.h:220:10: note: expanded from macro 'GENL_struct'
switch (0) { \
^
Without looking at the source code for more context switch(0)
already looks hyper-wrong (if (false)
), but maybe there's another way to accomplish whatever they're using that construct for. Probably needs CONFIG_BLK_DEV_DRBD=y
.
Linux kernel uses OUTPUT_FORMAT
in it's linker scripts. Most of the time -m
option is passed to the linker with correct architecture, but sometimes (at least for x86_64) the -m
option contradicts OUTPUT_FORMAT
directive (which should have higher priority). My fix is crude: just add correct -m
after incorrect one (it overrides it), so the linker invocation looks like this: ld -m elf_x86_64 -z max-page-size=0x200000 -m elf_i386 --emit-relocs -T realmode.lds header.o trampoline_64.o stack.o reboot.o -o realmode.elf
(it will also work with GNU ld, because it supports OUTPUT_FORMAT
and just ignores -m
options if this directive is in the linker script). Ideal solution would be adding OUTPUT_FORMAT
support to LLD.
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
index 9b5adae..e2839b5 100644
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -100,7 +100,7 @@ $(obj)/zoffset.h: $(obj)/compressed/vmlinux FORCE
AFLAGS_header.o += -I$(objtree)/$(obj)
$(obj)/header.o: $(obj)/zoffset.h
-LDFLAGS_setup.elf := -T
+LDFLAGS_setup.elf := -m elf_i386 -T
$(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
$(call if_changed,ld)
diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
index 4463fa7..96cb20d 100644
--- a/arch/x86/realmode/rm/Makefile
+++ b/arch/x86/realmode/rm/Makefile
@@ -47,7 +47,7 @@ $(obj)/pasyms.h: $(REALMODE_OBJS) FORCE
targets += realmode.lds
$(obj)/realmode.lds: $(obj)/pasyms.h
-LDFLAGS_realmode.elf := --emit-relocs -T
+LDFLAGS_realmode.elf := -m elf_i386 --emit-relocs -T
CPPFLAGS_realmode.lds += -P -C -I$(objtree)/$(obj)
targets += realmode.elf
➜ kernel-all git:(master) ✗ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make CC=clang init/main.o
CALL scripts/checksyscalls.sh
CC init/main.o
aarch64-linux-gnu-ld: init/.tmp_main.o: compiled for a little endian system and target is big endian
aarch64-linux-gnu-ld: failed to merge target specific data of file init/.tmp_main.o
scripts/Makefile.build:305: recipe for target 'init/main.o' failed
make[1]: *** [init/main.o] Error 1
Makefile:1678: recipe for target 'init/main.o' failed
make: *** [init/main.o] Error 2
Trying to link vmlinux with LLD:
ld.lld: error: ./arch/x86/kernel/vmlinux.lds:342: at least one side of the expression must be absolute
ld.lld: error: ./arch/x86/kernel/vmlinux.lds:343: at least one side of the expression must be absolute
These are the lines 342 and 343 from vmlinux.lds:
init_per_cpu__gdt_page = gdt_page + __per_cpu_load;
init_per_cpu__irq_stack_union = irq_stack_union + __per_cpu_load;
There is a patch resolving this issue:
https://marc.info/?l=llvm-commits&m=150594588415147&w=2
https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20170918/488965.html
Thanks to George Rimar for pointing out.
While we're working on getting 0day support, I think we can wire up travis-ci.org to build some configs with Clang.
CONFIG_ARM64_LSE_ATOMICS is now on by default for arm64's defconfig. This currently requires the compiler flags -ffixed-REG, -fcall-used-REG, -fcall-saved-REG
.
llvm bug: https://llvm.org/pr9457
llvm patch with relevant discusson: https://reviews.llvm.org/D48580#1173710
CrOS bug: https://bugs.chromium.org/p/chromium/issues/detail?id=865188
We should either implement these flags in LLVM, or come up with a suitable kernel path (or maybe some combination of both).
This commit broke arm64 build with the latest clang, see the build failure log below. It seems it's a bug in clang though.
+ make ARCH=arm64 CC=../../compilers/llvm/build/bin/clang CROSS_COMPILE=../../compilers/gcc-linaro-7.2.1/bin/aarch64-linux-gnu- -j48
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK scripts/mod/devicetable-offsets.h
CHK include/generated/utsrelease.h
CHK include/generated/bounds.h
CHK include/generated/timeconst.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
CC arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.o
CHK kernel/config_data.h
clang-7: /llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:7585: void llvm::SelectionDAGBuilder::visitInlineAsm(llvm::ImmutableCallSite): Assertion `(OpInfo.ConstraintType == TargetLowering::C_RegisterClass || OpInfo.ConstraintType == TargetLowering::C_Register) && "Unknown constraint type!"' failed.
#0 0x00005593cac4f62a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/llvm/build/bin/clang-7+0x246862a)
#1 0x00005593cac4d366 llvm::sys::RunSignalHandlers() (/llvm/build/bin/clang-7+0x2466366)
#2 0x00005593cac4d6d5 SignalHandler(int) (/llvm/build/bin/clang-7+0x24666d5)
#3 0x00007fc8e7d890c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)
#4 0x00007fc8e691afcf gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x32fcf)
#5 0x00007fc8e691c3fa abort (/lib/x86_64-linux-gnu/libc.so.6+0x343fa)
#6 0x00007fc8e6913e37 (/lib/x86_64-linux-gnu/libc.so.6+0x2be37)
#7 0x00007fc8e6913ee2 (/lib/x86_64-linux-gnu/libc.so.6+0x2bee2)
#8 0x00005593cb479796 llvm::SelectionDAGBuilder::visitInlineAsm(llvm::ImmutableCallSite) (/llvm/build/bin/clang-7+0x2c92796)
#9 0x00005593cb485217 llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&) (/llvm/build/bin/clang-7+0x2c9e217)
#10 0x00005593cb48c73e llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (/llvm/build/bin/clang-7+0x2ca573e)
#11 0x00005593cb4d61bf llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) (/llvm/build/bin/clang-7+0x2cef1bf)
#12 0x00005593cb4dac3a llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/llvm/build/bin/clang-7+0x2cf3c3a)
#13 0x00005593cb4dcb73 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.887) (/llvm/build/bin/clang-7+0x2cf5b73)
#14 0x00005593ca3b0545 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/llvm/build/bin/clang-7+0x1bc9545)
#15 0x00005593ca727179 llvm::FPPassManager::runOnFunction(llvm::Function&) (/llvm/build/bin/clang-7+0x1f40179)
#16 0x00005593ca7271d9 llvm::FPPassManager::runOnModule(llvm::Module&) (/llvm/build/bin/clang-7+0x1f401d9)
#17 0x00005593ca7268c1 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/llvm/build/bin/clang-7+0x1f3f8c1)
#18 0x00005593cae2d8cb (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/llvm/build/bin/clang-7+0x26468cb)
#19 0x00005593cae2f277 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/llvm/build/bin/clang-7+0x2648277)
#20 0x00005593cb59f548 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/llvm/build/bin/clang-7+0x2db8548)
#21 0x00005593cbd73ee9 clang::ParseAST(clang::Sema&, bool, bool) (/llvm/build/bin/clang-7+0x358cee9)
#22 0x00005593cb59e2c0 clang::CodeGenAction::ExecuteAction() (/llvm/build/bin/clang-7+0x2db72c0)
#23 0x00005593cb242eee clang::FrontendAction::Execute() (/llvm/build/bin/clang-7+0x2a5beee)
#24 0x00005593cb20aa0e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/llvm/build/bin/clang-7+0x2a23a0e)
#25 0x00005593cb2df70b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/llvm/build/bin/clang-7+0x2af870b)
#26 0x00005593c94119f8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/llvm/build/bin/clang-7+0xc2a9f8)
#27 0x00005593c93913a4 main (/llvm/build/bin/clang-7+0xbaa3a4)
#28 0x00007fc8e69082b1 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b1)
#29 0x00005593c940d8da _start (/llvm/build/bin/clang-7+0xc268da)
Stack dump:
0. Program arguments: /llvm/build/bin/clang-7 -cc1 -triple aarch64--linux-gnu -S -disable-free -main-file-name vgic-v2-cpuif-proxy.c -mrelocation-model static -mthread-model posix -mllvm -warn-stack-size=2048 -mdisable-fp-elim -relaxed-aliasing -mdisable-tail-calls -fmath-errno -masm-verbose -no-integrated-as -mconstructor-aliases -fuse-init-array -target-cpu generic -target-feature -fp-armv8 -target-feature -crypto -target-feature -neon -target-abi aapcs -mllvm -aarch64-enable-global-merge=false -fallow-half-arguments-and-returns -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -coverage-notes-file s/upstream/arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.gcno -nostdsysteminc -nobuiltininc -resource-dir /llvm/build/lib/clang/7.0.0 -dependency-file arch/arm64/kvm/hyp/.vgic-v2-cpuif-proxy.o.d -MT arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.o -sys-header-deps -isystem /llvm/build/lib/clang/7.0.0/include -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -I ./arch/arm64/include -I ./arch/arm64/include/generated -I ./include -I ./arch/arm64/include/uapi -I ./arch/arm64/include/generated/uapi -I ./include/uapi -I ./include/generated/uapi -D __KERNEL__ -D CONFIG_CC_STACKPROTECTOR -D CONFIG_AS_LSE=1 -D DISABLE_BRANCH_PROFILING -D KBUILD_BASENAME="vgic_v2_cpuif_proxy" -D KBUILD_MODNAME="vgic_v2_cpuif_proxy" -O2 -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -Werror-implicit-function-declaration -Wno-format-security -Wno-format-invalid-specifier -Wno-gnu -Wno-address-of-packed-member -Wno-tautological-compare -Wno-unused-const-variable -Wdeclaration-after-statement -Wno-pointer-sign -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Wno-initializer-overrides -Wno-unused-value -Wno-format -Wno-sign-compare -Wno-format-zero-length -Wno-uninitialized -std=gnu89 -fno-dwarf-directory-asm -fdebug-compilation-dir s/upstream -ferror-limit 19 -fmessage-length 94 -fwrapv -fno-builtin -fno-signed-char -fwchar-type=short -fno-signed-wchar -fobjc-runtime=gcc -fno-common -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o /tmp/vgic-v2-cpuif-proxy-303c39.s -x c arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c'.
4. Running pass 'AArch64 Instruction Selection' on function '@__vgic_v2_perform_cpuif_access'
clang-7: error: unable to execute command: Aborted
clang-7: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 7.0.0
Target: aarch64--linux-gnu
Thread model: posix
InstalledDir: s/upstream/../../compilers/llvm/build/bin
clang-7: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
AR drivers/gpu/drm/rcar-du/built-in.a
rm drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dtb drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dtb.S drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7793.dtb drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7791.dtb.S drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7795.dtb.S drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7793.dtb.S drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7796.dtb drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7795.dtb drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7796.dtb.S drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7791.dtb
clang-7: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-7: note: diagnostic msg: /tmp/vgic-v2-cpuif-proxy-4c4c74.c
clang-7: note: diagnostic msg: /tmp/vgic-v2-cpuif-proxy-4c4c74.sh
clang-7: note: diagnostic msg:
********************
scripts/Makefile.build:312: recipe for target 'arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.o' failed
make[2]: *** [arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.o] Error 254
scripts/Makefile.build:546: recipe for target 'arch/arm64/kvm/hyp' failed
make[1]: *** [arch/arm64/kvm/hyp] Error 2
Makefile:1057: recipe for target 'arch/arm64/kvm' failed
make: *** [arch/arm64/kvm] Error 2
CC drivers/gpu/drm/amd/amdgpu/gmc_v8_0.o
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c:1447:41: warning: suggest braces around
initialization of subobject [-Wmissing-braces]
struct amdgpu_task_info task_info = { 0 };
^
{}
1 warning generated.
CC drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.o
CC drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.o
CC drivers/gpu/drm/amd/amdgpu/gmc_v9_0.o
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c:262:41: warning: suggest braces around
initialization of subobject [-Wmissing-braces]
struct amdgpu_task_info task_info = { 0 };
^
{}
1 warning generated.
IIRC, { 0 }
does not initialize subobjects in C? Should be an easy fix. CONFIG_DRM_AMDGPU=y
we're having trouble assembling arch/x86/entry/entry_64.S in the kernel with llvm-as:
<instantiation>:13:10: error: unknown token in expression
.elseif %rsp == %r10
^
Probably from CONFIG_KASAN=y
but at least two instances:
CC fs/ext4/inode.o
fs/ext4/inode.c:53:14: warning: stack frame size of 2688 bytes in function 'ext4_inode_csum' [-Wframe-larger-than=]
static __u32 ext4_inode_csum(struct inode *inode, struct ext4_inode *raw,
^
CC fs/f2fs/inode.o
fs/f2fs/inode.c:137:14: warning: stack frame size of 2304 bytes in function 'f2fs_inode_chksum' [-Wframe-larger-than=]
static __u32 f2fs_inode_chksum(struct f2fs_sb_info *sbi, struct page *page)
^
Sedat and @kees noted that Clang is producing lots of -Wvla
warnings now for the __compiletime_assert
and BUG_ON
macros. It seems that there's some differences in Integer Constant Expression definitions between compilers, and dependence on DCE in the kernel code.
Many instances of -Wignored-attributes
:
CC fs/exofs/ore.o
In file included from fs/exofs/ore.c:30:
In file included from fs/exofs/ore_raid.h:16:
In file included from ./include/scsi/osd_ore.h:25:
In file included from ./include/scsi/osd_initiator.h:18:
./include/scsi/osd_types.h:31:21: warning: 'weak' attribute only applies to variables, functions, and classes [-Wignored-attributes]
static const struct __weak osd_obj_id osd_root_object = {0, 0};
^
./include/linux/compiler_types.h:211:33: note: expanded from macro '__weak'
#define __weak __attribute__((weak))
^
1 warning generated.
Probably requires: CONFIG_EXOFS_FS=y
and possibly CONFIG_EXOFS_DEBUG=y
.
It's possible to use LLVM's implementation of objcopy when compiling Linux: make OBJCOPY=llvm-objcopy
. However this implementation lacks -S
flag (which should be synonymous to -strip-all-gnu
which is unique to this implementation). As a workaround I replace -S
to -strip-all-gnu
in OBJCOPYFLAGS
in kernel's makefiles (will break compatibility with objcopy from GNU binutils).
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
index 9b5adae9cc40..8f8f3f8987ab 100644
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -81,7 +81,7 @@ $(obj)/bzImage: $(obj)/setup.bin $(obj)/vmlinux.bin $(obj)/tools/build FORCE
$(call if_changed,image)
@$(kecho) 'Kernel: $@ is ready' ' (#'`cat .version`')'
-OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S
+OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -strip-all-gnu
$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
$(call if_changed,objcopy)
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index 28764dacf018..41836d506e0a 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -114,7 +114,7 @@ quiet_cmd_check-and-link-vmlinux = LD $@
$(obj)/vmlinux: $(vmlinux-objs-y) FORCE
$(call if_changed,check-and-link-vmlinux)
-OBJCOPYFLAGS_vmlinux.bin := -R .comment -S
+OBJCOPYFLAGS_vmlinux.bin := -R .comment -strip-all-gnu
$(obj)/vmlinux.bin: vmlinux FORCE
$(call if_changed,objcopy)
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index fa3f439f0a92..d1be64895fd2 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -109,7 +109,7 @@ $(obj)/%-x32.o: $(obj)/%.o FORCE
targets += vdsox32.lds $(vobjx32s-y)
-$(obj)/%.so: OBJCOPYFLAGS := -S
+$(obj)/%.so: OBJCOPYFLAGS := -strip-all-gnu
$(obj)/%.so: $(obj)/%.so.dbg
$(call if_changed,objcopy)
searching llvm's bug tracker for clang, it seems that upstream kernel dev's reported issues with i915: https://llvm.org/pr36378
drivers/crypto/ccree/cc_hash.c is full of:
CC drivers/crypto/ccree/cc_hash.o
drivers/crypto/ccree/cc_hash.c:99:28: warning: implicit conversion from enumeration
type 'enum cc_hash_conf_pad' to different enumeration type
'enum drv_crypto_direction' [-Wenum-conversion]
set_cipher_config0(desc, HASH_DIGEST_RESULT_LITTLE_ENDIAN);
~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CONFIG_CRYPTO_DEV_CCREE=y
.
CC drivers/dma/timb_dma.o
drivers/dma/timb_dma.c:548:27: warning: implicit conversion from enumeration type
'enum dma_transfer_direction' to different enumeration type
'enum dma_data_direction' [-Wenum-conversion]
td_desc->desc_list_len, DMA_MEM_TO_DEV);
^~~~~~~~~~~~~~
CONFIG_TIMB_DMA=y
CC drivers/atm/eni.o
drivers/atm/eni.c:244:48: warning: for loop has empty body [-Wempty-body]
for (order = 0; (1 << order) < *size; order++);
^
drivers/atm/eni.c:244:48: note: put the semicolon on a separate line to silence this
warning
This can probably be replaced with a while
loop, or the warning disabled unless W=1
or something in KBUILD. Probably CONFIG_ATM_DRIVERS=y
.
The following compilation:
$ clang-7 cc1as -triple x86_64-unknown-linux-gnu -filetype obj \
-main-file-name aesni-intel_avx-x86_64.S -target-cpu x86-64 \
-dwarf-version=4 -mrelocation-model static -debug-info-kind=limited \
-dwarf-version=2 -o test.bc test.s
eventually runs out of memory. It seems like the .rep
bits are being replicated over and over and over...
CC fs/ocfs2/dlm/dlmthread.o
fs/ocfs2/dlm/dlmthread.c:534:18: warning: equality comparison with extraneous
parentheses [-Wparentheses-equality]
if ((res->owner == dlm->node_num)) {
~~~~~~~~~~~^~~~~~~~~~~~~~~~
fs/ocfs2/dlm/dlmthread.c:534:18: note: remove extraneous parentheses around the
comparison to silence this warning
if ((res->owner == dlm->node_num)) {
~ ^ ~
fs/ocfs2/dlm/dlmthread.c:534:18: note: use '=' to turn this equality comparison into
an assignment
if ((res->owner == dlm->node_num)) {
^~
=
Probably requires CONFIG_OCFS2_FS=y
(there's like 6 OCFS2 configs).
It's possible to use LLVM's implementation of ar when compiling Linux: make AR=llvm-ar
, but llvm-ar doesn't support P option which is used extensively in kernel's makefiles. Removing all P options helped me to advance in compilation, but ld didn't accept the resulting archives complaining about them not being valid thin archives. I'm not sure if those malformed archives have something to do with the P option or is it a completely different issue.
Without support for compile-time warnings, Clang is forced to fall back to a build-failure using __compiletime_error_fallback in include/linux/compiler.h:
# define __compiletime_error_fallback(condition) \
do { ((void)sizeof(char[1 - 2 * condition])); } while (0)
However, this is a VLA, so future use of -Wvla will make builds extraordinarily noisy. This could likely be worked around in some Clang-specific way, but having true compile time warnings would be best, as that means Clang builds gain sensible warnings for things like BUILD_BUG_ON_MSG().
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.