[llvm-bugs] [Bug 41035] New: Linux kernel build: Regression due memcmp to bcmp optimization

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 11 12:50:47 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41035

            Bug ID: 41035
           Summary: Linux kernel build: Regression due memcmp to bcmp
                    optimization
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: adhemerval.zanella at linaro.org
                CC: llvm-bugs at lists.llvm.org

Revision r355672 [1] introduced a Linux kernel regression build since it Linux
does not build the kernel with -ffreestanding and also it does not provide
bcmp.

The compiler command line issued is:

clang -Wp,-MD,init/.do_mounts.o.d  -nostdinc -isystem
/home/adhemerval.zanella/investigate-llvm-8e16d73346f8091461319a7dfc4ddd18eedcff13/llvm-install/lib/clang/9.0.0/include
-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 -include ./include/linux/kconfig.h
-include ./include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian
-DKASAN_SHADOW_SCALE_SHIFT=3 -Qunused-arguments -Wall -Wundef
-Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common
-fshort-wchar -fno-PIE -Werror-implicit-function-declaration
-Werror=implicit-int -Wno-format-security -std=gnu89 -no-integrated-as
-mgeneral-regs-only -DCONFIG_AS_LSE=1 -fno-asynchronous-unwind-tables
-DKASAN_SHADOW_SCALE_SHIFT=3 -fno-delete-null-pointer-checks -O2
-Wframe-larger-than=2048 -fstack-protector-strong -Wno-format-invalid-specifier
-Wno-gnu -Wno-address-of-packed-member -Wno-tautological-compare
-mno-global-merge -Wno-unused-const-variable -fno-omit-frame-pointer
-fno-optimize-sibling-calls -g -Wdeclaration-after-statement -Wvla
-Wno-pointer-sign -fno-strict-overflow -fno-merge-all-constants
-fno-stack-check -Werror=date-time -Werror=incompatible-pointer-types
-Wno-initializer-overrides -Wno-unused-value -Wno-format -Wno-sign-compare
-Wno-format-zero-length -Wno-uninitialized -fno-function-sections
-fno-data-sections    -DKBUILD_BASENAME='"do_mounts"'
-DKBUILD_MODNAME='"mounts"' -c -o init/do_mounts.o init/do_mounts.c

And the resulting error is:

ld.lld -EL -maarch64elf --no-undefined -X --fix-cortex-a53-843419 --build-id -o
.tmp_vmlinux1 -T ./arch/arm64/kernel/vmlinux.lds --whole-archive built-in.a
--no-whole-archive --start-group arch/arm64/lib/lib.a lib/lib.a --end-group
ld.lld: error: undefined symbol: bcmp
>>> referenced by do_mounts.c:593 (/home/adhemerval.zanella/investigate-llvm-8e16d73346f8091461319a7dfc4ddd18eedcff13/linux/init/do_mounts.c:593)
>>>               init/do_mounts.o:(prepare_namespace) in archive built-in.a

ld.lld: error: undefined symbol: bcmp
>>> referenced by do_mounts.c:594 (/home/adhemerval.zanella/investigate-llvm-8e16d73346f8091461319a7dfc4ddd18eedcff13/linux/init/do_mounts.c:594)
>>>               init/do_mounts.o:(prepare_namespace) in archive built-in.a

[...]

This can be fixed on Linux kernel side, but it will require to add
-fno-builtin-bcmp and rollout this on all support releases. However I really
think we should disable such transformation for -nostdinc. Also, as jyknight
has stated on https://reviews.llvm.org/D56593, this optimization currently is
also not a performance gain on Linux (on glibc it is a weak alias to memcmp,
while on musl is a tail call to memcmp).


[1] http://llvm.org/viewvc/llvm-project?view=revision&revision=355672

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190311/ad7bedff/attachment.html>


More information about the llvm-bugs mailing list