lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20140919131021.EE3E.AA925319@jp.panasonic.com>
Date:	Fri, 19 Sep 2014 13:10:21 +0900
From:	Masahiro Yamada <yamada.m@...panasonic.com>
To:	linux-kbuild@...r.kernel.org, llvmlinux@...ts.linuxfoundation.org
Cc:	Vinicius Tinti <viniciustinti@...il.com>,
	Behan Webster <behanw@...verseincode.com>,
	linux-kernel@...r.kernel.org
Subject: How to build the kernel with Clang?

Hi Clang folks,


I'd like to know the status of Clang support
in the Linux mainline.


I can see some "clang" specific parts in makefiles,
so I guess Clang is already supported to a certain extent.


I just tried to build with "HOSTCC=clang CC=clang"
but it would not work.

Is there any tips I am missing here?



$ git describe 
v3.17-rc5-25-g8ba4caf
$ clang --version
Ubuntu clang version 3.5-1ubuntu1 (trunk) (based on LLVM 3.5)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ make HOSTCC=clang defconfig
  HOSTCC  scripts/basic/fixdep
clang: error: unknown argument: '-fno-delete-null-pointer-checks'
make[1]: *** [scripts/basic/fixdep] Error 1
make: *** [scripts_basic] Error 2

 [ edit the top Makefile and comment out -fno-delete-null-pointer-checks]
 
$ make HOSTCC=clang defconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
*** Default configuration is based on 'x86_64_defconfig'
#
# configuration written to .config
#
$ make HOSTCC=clang CC=clang
scripts/kconfig/conf --silentoldconfig Kconfig
  SYSTBL  arch/x86/syscalls/../include/generated/asm/syscalls_32.h
  SYSHDR  arch/x86/syscalls/../include/generated/asm/unistd_32_ia32.h
  SYSHDR  arch/x86/syscalls/../include/generated/asm/unistd_64_x32.h
  SYSTBL  arch/x86/syscalls/../include/generated/asm/syscalls_64.h
  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_32.h
  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_64.h
  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_x32.h
  HOSTCC  arch/x86/tools/relocs_32.o
  HOSTCC  arch/x86/tools/relocs_64.o
In file included from arch/x86/tools/relocs_64.c:17:
arch/x86/tools/relocs.c:969:6: warning: variable 'do_reloc' is used uninitialized whenever 'if' condition is false
      [-Wsometimes-uninitialized]
        if (!use_real_mode)
            ^~~~~~~~~~~~~~
arch/x86/tools/relocs.c:981:14: note: uninitialized use occurs here
        walk_relocs(do_reloc);
                    ^~~~~~~~
arch/x86/tools/relocs.c:969:2: note: remove the 'if' if its condition is always true
        if (!use_real_mode)
        ^~~~~~~~~~~~~~~~~~~
arch/x86/tools/relocs.c:966:24: note: initialize the variable 'do_reloc' to silence this warning
                        const char *symname);
                                            ^
                                             = NULL
1 warning generated.
  HOSTCC  arch/x86/tools/relocs_common.o
  HOSTLD  arch/x86/tools/relocs
  CHK     include/config/kernel.release
  UPD     include/config/kernel.release
  WRAP    arch/x86/include/generated/asm/clkdev.h
  WRAP    arch/x86/include/generated/asm/cputime.h
  WRAP    arch/x86/include/generated/asm/early_ioremap.h
  WRAP    arch/x86/include/generated/asm/mcs_spinlock.h
  WRAP    arch/x86/include/generated/asm/scatterlist.h
  CHK     include/generated/uapi/linux/version.h
  UPD     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  UPD     include/generated/utsrelease.h
  CC      kernel/bounds.s
clang: warning: argument '-fcatch-undefined-behavior' is deprecated, use '-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error' instead
kernel/bounds.c:18:2: error: unexpected token at start of statement
        DEFINE(NR_PAGEFLAGS, __NR_PAGEFLAGS);
        ^
include/linux/kbuild.h:5:25: note: expanded from macro 'DEFINE'
        asm volatile("\n->" #sym " %0 " #val : : "i" (val))
                        ^
<inline asm>:2:1: note: instantiated into assembly here
->NR_PAGEFLAGS $23 __NR_PAGEFLAGS
^
kernel/bounds.c:19:2: error: unexpected token at start of statement
        DEFINE(MAX_NR_ZONES, __MAX_NR_ZONES);
        ^
include/linux/kbuild.h:5:25: note: expanded from macro 'DEFINE'
        asm volatile("\n->" #sym " %0 " #val : : "i" (val))
                        ^
<inline asm>:2:1: note: instantiated into assembly here
->MAX_NR_ZONES $4 __MAX_NR_ZONES
^
kernel/bounds.c:21:2: error: unexpected token at start of statement
        DEFINE(NR_CPUS_BITS, ilog2(CONFIG_NR_CPUS));
        ^
include/linux/kbuild.h:5:25: note: expanded from macro 'DEFINE'
        asm volatile("\n->" #sym " %0 " #val : : "i" (val))
                        ^
<inline asm>:2:1: note: instantiated into assembly here
->NR_CPUS_BITS $6 ilog2(CONFIG_NR_CPUS)
^
kernel/bounds.c:23:2: error: unexpected token at start of statement
        DEFINE(SPINLOCK_SIZE, sizeof(spinlock_t));
        ^
include/linux/kbuild.h:5:25: note: expanded from macro 'DEFINE'
        asm volatile("\n->" #sym " %0 " #val : : "i" (val))
                        ^
<inline asm>:2:1: note: instantiated into assembly here
->SPINLOCK_SIZE $2 sizeof(spinlock_t)
^
4 errors generated.
make[1]: *** [kernel/bounds.s] Error 1
make: *** [prepare0] Error 2




Is "DEFINE()" macro working?


Do we need a patch like follows?
http://patchwork.ozlabs.org/patch/375026/


Best Regards
Masahiro Yamada

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ