Hi, I'm trying to compiler the Linux kernel. I tried both wllvm and clang.
For clang, I just add two arguments to the kernel Makefile.
# add debug info
KBUILD_CFLAGS += -g
# generate bitcode
KBUILD_CFLAGS += -save-temps=obj
and use llvm-link to link all the bitcode files into one. However, this produces a lot of errors when linking, something like:
error: Linking global named 'xxx': symbol multiply defined
Then I change to wllvm, I use extract-bc -b built-in.a to get bitcode and it works well.
However, when I compare the two results, the LLVM IRs are quit different.
This is wllvm output
; Function Attrs: cold fn_ret_thunk_extern noredzone nounwind null_pointer_is_valid optsize sanitize_thread sspstrong
define internal void @mac_hid_exit() #0 section ".exit.text" align 64 !kcfi_type !10 {
%1 = call ptr @llvm.returnaddress(i32 0)
call void @__tsan_func_entry(ptr %1)
call void @__sanitizer_cov_trace_pc() #9
call void @__tsan_read8(ptr @mac_hid_sysctl_header)
%2 = load ptr, ptr @mac_hid_sysctl_header, align 8
call void @unregister_sysctl_table(ptr noundef %2) #10
call void @__tsan_read4(ptr @mouse_emulate_buttons)
%3 = load i32, ptr @mouse_emulate_buttons, align 4
call void @__sanitizer_cov_trace_const_cmp4(i32 0, i32 %3)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %0
call void @__sanitizer_cov_trace_pc() #9
br label %8
6: ; preds = %0
call void @__sanitizer_cov_trace_pc() #9
call void @input_unregister_handler(ptr noundef nonnull @mac_hid_emumouse_handler) #10
call void @__tsan_read8(ptr @mac_hid_emumouse_dev)
%7 = load ptr, ptr @mac_hid_emumouse_dev, align 8
call void @input_unregister_device(ptr noundef %7) #10
call void @__tsan_write8(ptr @mac_hid_emumouse_dev)
store ptr null, ptr @mac_hid_emumouse_dev, align 8
br label %8
8: ; preds = %5, %6
call void @__tsan_func_exit()
ret void
}
This is clang output
; Function Attrs: cold fn_ret_thunk_extern noredzone nounwind null_pointer_is_valid optsize sspstrong
define internal void @mac_hid_exit.10() #0 section ".exit.text" align 16 !dbg !29354 {
%1 = load ptr, ptr @mac_hid_sysctl_header.12, align 8, !dbg !29355
call void @unregister_sysctl_table(ptr noundef %1) #15, !dbg !29356
%2 = load i32, ptr @mouse_emulate_buttons.13, align 4, !dbg !29357
%3 = icmp ne i32 %2, 0, !dbg !29357
br i1 %3, label %4, label %5, !dbg !29359
4: ; preds = %0
call void @mac_hid_stop_emulation.14() #15, !dbg !29360
br label %5, !dbg !29360
5: ; preds = %4, %0
ret void, !dbg !29361
}
Any suggestion is appreciated!
Hi, I'm trying to compiler the Linux kernel. I tried both
wllvmandclang.For
clang, I just add two arguments to the kernel Makefile.and use
llvm-linkto link all the bitcode files into one. However, this produces a lot of errors when linking, something like:Then I change to
wllvm, I useextract-bc -b built-in.ato get bitcode and it works well.However, when I compare the two results, the LLVM IRs are quit different.
This is
wllvmoutputThis is
clangoutputAny suggestion is appreciated!