* [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag @ 2021-03-02 21:06 Nathan Chancellor 2021-03-02 21:06 ` [PATCH 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as Nathan Chancellor ` (4 more replies) 0 siblings, 5 replies; 20+ messages in thread From: Nathan Chancellor @ 2021-03-02 21:06 UTC (permalink / raw) To: Masahiro Yamada, Michal Marek, Nick Desaulniers Cc: linux-kbuild, linux-kernel, clang-built-linux, Nathan Chancellor This is not necessary anymore now that we specify '--prefix=', which tells clang exactly where to find the GNU cross tools. This has been verified with self compiled LLVM 10.0.1 and LLVM 13.0.0 as well as a distribution version of LLVM 11.1.0 without binutils in the LLVM toolchain locations. Signed-off-by: Nathan Chancellor <nathan@kernel.org> --- Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Makefile b/Makefile index f9b54da2fca0..c20f0ad8be73 100644 --- a/Makefile +++ b/Makefile @@ -568,10 +568,6 @@ ifneq ($(CROSS_COMPILE),) CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) -GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) -endif -ifneq ($(GCC_TOOLCHAIN),) -CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) endif ifneq ($(LLVM_IAS),1) CLANG_FLAGS += -no-integrated-as base-commit: 7a7fd0de4a9804299793e564a555a49c1fc924cb -- 2.31.0.rc0.75.gec125d1bc1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as 2021-03-02 21:06 [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag Nathan Chancellor @ 2021-03-02 21:06 ` Nathan Chancellor 2021-03-02 22:02 ` Fangrui Song ` (3 more replies) 2021-03-02 21:43 ` [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag Fangrui Song ` (3 subsequent siblings) 4 siblings, 4 replies; 20+ messages in thread From: Nathan Chancellor @ 2021-03-02 21:06 UTC (permalink / raw) To: Masahiro Yamada, Michal Marek, Nick Desaulniers Cc: linux-kbuild, linux-kernel, clang-built-linux, Nathan Chancellor When building with LLVM_IAS=1, there is no point to specifying '--prefix=' because that flag is only used to find the cross assembler, which is clang itself when building with LLVM_IAS=1. All of the other tools are invoked directly from PATH or a full path specified via the command line, which does not depend on the value of '--prefix='. Sharing commands to reproduce issues becomes a little bit easier without a '--prefix=' value because that '--prefix=' value is specific to a user's machine due to it being an absolute path. Signed-off-by: Nathan Chancellor <nathan@kernel.org> --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c20f0ad8be73..0413b8c594cd 100644 --- a/Makefile +++ b/Makefile @@ -566,12 +566,12 @@ CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1 | sed 's/\#//g ifneq ($(findstring clang,$(CC_VERSION_TEXT)),) ifneq ($(CROSS_COMPILE),) CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) +ifneq ($(LLVM_IAS),1) GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) -endif -ifneq ($(LLVM_IAS),1) CLANG_FLAGS += -no-integrated-as endif +endif CLANG_FLAGS += -Werror=unknown-warning-option KBUILD_CFLAGS += $(CLANG_FLAGS) KBUILD_AFLAGS += $(CLANG_FLAGS) -- 2.31.0.rc0.75.gec125d1bc1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as 2021-03-02 21:06 ` [PATCH 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as Nathan Chancellor @ 2021-03-02 22:02 ` Fangrui Song 2021-03-02 22:09 ` Nick Desaulniers 2021-03-09 19:55 ` Masahiro Yamada ` (2 subsequent siblings) 3 siblings, 1 reply; 20+ messages in thread From: Fangrui Song @ 2021-03-02 22:02 UTC (permalink / raw) To: Nathan Chancellor Cc: Masahiro Yamada, Michal Marek, Nick Desaulniers, linux-kbuild, linux-kernel, clang-built-linux On 2021-03-02, Nathan Chancellor wrote: >When building with LLVM_IAS=1, there is no point to specifying >'--prefix=' because that flag is only used to find the cross assembler, >which is clang itself when building with LLVM_IAS=1. All of the other >tools are invoked directly from PATH or a full path specified via the >command line, which does not depend on the value of '--prefix='. > >Sharing commands to reproduce issues becomes a little bit easier without >a '--prefix=' value because that '--prefix=' value is specific to a >user's machine due to it being an absolute path. > >Signed-off-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Fangrui Song <maskray@google.com> clang can spawn GNU as (if -f?no-integrated-as is specified) and GNU objcopy (-f?no-integrated-as and -gsplit-dwarf and -g[123]). With LLVM_IAS=1, these cases are ruled out. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as 2021-03-02 22:02 ` Fangrui Song @ 2021-03-02 22:09 ` Nick Desaulniers 2021-03-02 22:40 ` Nick Desaulniers 0 siblings, 1 reply; 20+ messages in thread From: Nick Desaulniers @ 2021-03-02 22:09 UTC (permalink / raw) To: Fangrui Song Cc: Nathan Chancellor, Masahiro Yamada, Michal Marek, Linux Kbuild mailing list, LKML, clang-built-linux On Tue, Mar 2, 2021 at 2:02 PM Fangrui Song <maskray@google.com> wrote: > > On 2021-03-02, Nathan Chancellor wrote: > >When building with LLVM_IAS=1, there is no point to specifying > >'--prefix=' because that flag is only used to find the cross assembler, > >which is clang itself when building with LLVM_IAS=1. All of the other > >tools are invoked directly from PATH or a full path specified via the > >command line, which does not depend on the value of '--prefix='. > > > >Sharing commands to reproduce issues becomes a little bit easier without > >a '--prefix=' value because that '--prefix=' value is specific to a > >user's machine due to it being an absolute path. > > > >Signed-off-by: Nathan Chancellor <nathan@kernel.org> > > Reviewed-by: Fangrui Song <maskray@google.com> > > clang can spawn GNU as (if -f?no-integrated-as is specified) and GNU > objcopy (-f?no-integrated-as and -gsplit-dwarf and -g[123]). But -g get's set via CONFIG_DEBUG_INFO and -gsplit-dwarf by DEBUG_INFO_SPLIT. So if we say: $ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make CC=clang LLVM_IAS=1 So cross compile, use clang, use the integrated assembler (ie. with this change, don't set --prefix), with either of the two above configs, which objcopy get's exec'd? > > With LLVM_IAS=1, these cases are ruled out. -- Thanks, ~Nick Desaulniers ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as 2021-03-02 22:09 ` Nick Desaulniers @ 2021-03-02 22:40 ` Nick Desaulniers 0 siblings, 0 replies; 20+ messages in thread From: Nick Desaulniers @ 2021-03-02 22:40 UTC (permalink / raw) To: Nathan Chancellor Cc: Masahiro Yamada, Michal Marek, Linux Kbuild mailing list, LKML, clang-built-linux, Fangrui Song On Tue, Mar 2, 2021 at 2:09 PM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Tue, Mar 2, 2021 at 2:02 PM Fangrui Song <maskray@google.com> wrote: > > > > On 2021-03-02, Nathan Chancellor wrote: > > >When building with LLVM_IAS=1, there is no point to specifying > > >'--prefix=' because that flag is only used to find the cross assembler, > > >which is clang itself when building with LLVM_IAS=1. All of the other > > >tools are invoked directly from PATH or a full path specified via the > > >command line, which does not depend on the value of '--prefix='. > > > > > >Sharing commands to reproduce issues becomes a little bit easier without > > >a '--prefix=' value because that '--prefix=' value is specific to a > > >user's machine due to it being an absolute path. > > > > > >Signed-off-by: Nathan Chancellor <nathan@kernel.org> > > > > Reviewed-by: Fangrui Song <maskray@google.com> > > > > clang can spawn GNU as (if -f?no-integrated-as is specified) and GNU > > objcopy (-f?no-integrated-as and -gsplit-dwarf and -g[123]). > > But -g get's set via CONFIG_DEBUG_INFO and -gsplit-dwarf by > DEBUG_INFO_SPLIT. So if we say: > $ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make CC=clang LLVM_IAS=1 > > So cross compile, use clang, use the integrated assembler (ie. with > this change, don't set --prefix), with either of the two above > configs, which objcopy get's exec'd? Ok, I spoke to Fangrui more offline, and probably misread his response. From our chat: ``` Fangrui: objcopy is only used for GNU as assembled object files With integrated assembler, the object file streamer creates .o and .dwo simultaneously With GNU as, two objcopy commands are needed to extract .debug*.dwo to .dwo files &&& another command to remove .debug*.dwo sections ``` Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Tested-by: Nick Desaulniers <ndesaulniers@google.com> I ran this series through a mix of LLVM=1 vs CC=clang, LLVM_IAS=1 vs unset, CROSS_COMPILE vs not, without issue. > > > > > With LLVM_IAS=1, these cases are ruled out. > > > > -- > Thanks, > ~Nick Desaulniers -- Thanks, ~Nick Desaulniers ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as 2021-03-02 21:06 ` [PATCH 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as Nathan Chancellor 2021-03-02 22:02 ` Fangrui Song @ 2021-03-09 19:55 ` Masahiro Yamada 2021-03-09 19:58 ` Masahiro Yamada 2021-09-29 17:26 ` kernel test robot 2021-09-29 19:32 ` kernel test robot 3 siblings, 1 reply; 20+ messages in thread From: Masahiro Yamada @ 2021-03-09 19:55 UTC (permalink / raw) To: Nathan Chancellor Cc: Michal Marek, Nick Desaulniers, Linux Kbuild mailing list, Linux Kernel Mailing List, clang-built-linux On Wed, Mar 3, 2021 at 6:07 AM Nathan Chancellor <nathan@kernel.org> wrote: > > When building with LLVM_IAS=1, there is no point to specifying > '--prefix=' because that flag is only used to find the cross assembler, > which is clang itself when building with LLVM_IAS=1. All of the other > tools are invoked directly from PATH or a full path specified via the > command line, which does not depend on the value of '--prefix='. > > Sharing commands to reproduce issues becomes a little bit easier without > a '--prefix=' value because that '--prefix=' value is specific to a > user's machine due to it being an absolute path. > > Signed-off-by: Nathan Chancellor <nathan@kernel.org> I was tricked by a couple of Reviewed-by/Tested-by tags. With this patch applied, the code looks as follows: ifneq ($(CROSS_COMPILE),) CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) ifneq ($(LLVM_IAS),1) GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) CLANG_FLAGS += -no-integrated-as endif endif For the native build (empty CROSS_COMPILE), you cannot add -no-integrated-as. I dropped this from my tree. Is the correct code as follows? ifneq ($(LLVM_IAS),1) CLANG_FLAGS += -no-integrated-as ifneq ($(CROSS_COMPILE),) CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) endif endif > --- > Makefile | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/Makefile b/Makefile > index c20f0ad8be73..0413b8c594cd 100644 > --- a/Makefile > +++ b/Makefile > @@ -566,12 +566,12 @@ CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1 | sed 's/\#//g > ifneq ($(findstring clang,$(CC_VERSION_TEXT)),) > ifneq ($(CROSS_COMPILE),) > CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) > +ifneq ($(LLVM_IAS),1) > GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) > CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) > -endif > -ifneq ($(LLVM_IAS),1) > CLANG_FLAGS += -no-integrated-as > endif > +endif > CLANG_FLAGS += -Werror=unknown-warning-option > KBUILD_CFLAGS += $(CLANG_FLAGS) > KBUILD_AFLAGS += $(CLANG_FLAGS) > -- > 2.31.0.rc0.75.gec125d1bc1 > -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as 2021-03-09 19:55 ` Masahiro Yamada @ 2021-03-09 19:58 ` Masahiro Yamada 0 siblings, 0 replies; 20+ messages in thread From: Masahiro Yamada @ 2021-03-09 19:58 UTC (permalink / raw) To: Nathan Chancellor Cc: Michal Marek, Nick Desaulniers, Linux Kbuild mailing list, Linux Kernel Mailing List, clang-built-linux On Wed, Mar 10, 2021 at 4:55 AM Masahiro Yamada <masahiroy@kernel.org> wrote: > > On Wed, Mar 3, 2021 at 6:07 AM Nathan Chancellor <nathan@kernel.org> wrote: > > > > When building with LLVM_IAS=1, there is no point to specifying > > '--prefix=' because that flag is only used to find the cross assembler, > > which is clang itself when building with LLVM_IAS=1. All of the other > > tools are invoked directly from PATH or a full path specified via the > > command line, which does not depend on the value of '--prefix='. > > > > Sharing commands to reproduce issues becomes a little bit easier without > > a '--prefix=' value because that '--prefix=' value is specific to a > > user's machine due to it being an absolute path. > > > > Signed-off-by: Nathan Chancellor <nathan@kernel.org> > > > I was tricked by a couple of Reviewed-by/Tested-by tags. > > With this patch applied, the code looks as follows: > > > ifneq ($(CROSS_COMPILE),) > CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) > ifneq ($(LLVM_IAS),1) > GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) > CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) > CLANG_FLAGS += -no-integrated-as > endif > endif > > > For the native build (empty CROSS_COMPILE), > you cannot add -no-integrated-as. > > > I dropped this from my tree. > > > > Is the correct code as follows? > > > ifneq ($(LLVM_IAS),1) > CLANG_FLAGS += -no-integrated-as > ifneq ($(CROSS_COMPILE),) > CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) > GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) > CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) > endif > endif > > > > If you send v2, can you include comments from Fangrui Song? Fangrui Song: clang can spawn GNU as (if -f?no-integrated-as is specified) and GNU objcopy (-f?no-integrated-as and -gsplit-dwarf and -g[123]). objcopy is only used for GNU as assembled object files. With integrated assembler, the object file streamer creates .o and .dwo simultaneously. With GNU as, two objcopy commands are needed to extract .debug*.dwo to .dwo files && another command to remove .debug*.dwo sections. I did not know the objtool part, and I think it is worth recording. -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as 2021-03-02 21:06 ` [PATCH 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as Nathan Chancellor 2021-03-02 22:02 ` Fangrui Song 2021-03-09 19:55 ` Masahiro Yamada @ 2021-09-29 17:26 ` kernel test robot 2021-09-29 19:32 ` kernel test robot 3 siblings, 0 replies; 20+ messages in thread From: kernel test robot @ 2021-09-29 17:26 UTC (permalink / raw) To: Nathan Chancellor, Masahiro Yamada, Michal Marek, Nick Desaulniers Cc: llvm, kbuild-all, linux-kbuild, linux-kernel, clang-built-linux, Nathan Chancellor [-- Attachment #1: Type: text/plain, Size: 5424 bytes --] Hi Nathan, I love your patch! Perhaps something to improve: [auto build test WARNING on 7a7fd0de4a9804299793e564a555a49c1fc924cb] url: https://github.com/0day-ci/linux/commits/Nathan-Chancellor/Makefile-Remove-gcc-toolchain-flag/20210929-112213 base: 7a7fd0de4a9804299793e564a555a49c1fc924cb config: x86_64-randconfig-a014-20210929 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project dc6e8dfdfe7efecfda318d43a06fae18b40eb498) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/74a168f9e88d9edf5aaa8209d2c39e676de2857a git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Nathan-Chancellor/Makefile-Remove-gcc-toolchain-flag/20210929-112213 git checkout 74a168f9e88d9edf5aaa8209d2c39e676de2857a # save the attached .config to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash arch/x86/entry/ arch/x86/kernel/ arch/x86/lib/ kernel/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> arch/x86/entry/entry_64.S:47:1: warning: DWARF2 only supports one section per compilation unit .section .entry.text, "ax" ^ >> <instantiation>:11:2: warning: DWARF2 only supports one section per compilation unit .pushsection .altinstr_replacement,"ax" ^ <instantiation>:1:1: note: while in macro instantiation ALTERNATIVE "jmp .Lend_2", "", ( 7*32+11) ^ arch/x86/entry/entry_64.S:93:2: note: while in macro instantiation SWITCH_TO_KERNEL_CR3 scratch_reg=%rsp ^ arch/x86/entry/entry_64.S:741:2: warning: DWARF2 only supports one section per compilation unit .section .fixup, "ax" ^ -- >> arch/x86/entry/entry_64_compat.S:20:2: warning: DWARF2 only supports one section per compilation unit .section .entry.text, "ax" ^ >> <instantiation>:11:2: warning: DWARF2 only supports one section per compilation unit .pushsection .altinstr_replacement,"ax" ^ <instantiation>:1:1: note: while in macro instantiation ALTERNATIVE "jmp .Lend_2", "", ( 7*32+11) ^ arch/x86/entry/entry_64_compat.S:55:2: note: while in macro instantiation SWITCH_TO_KERNEL_CR3 scratch_reg=%rax ^ -- >> arch/x86/kernel/head_64.S:42:2: warning: DWARF2 only supports one section per compilation unit .section ".head.text","ax" ^ arch/x86/kernel/head_64.S:352:2: warning: DWARF2 only supports one section per compilation unit .section ".init.text","ax" ^ -- >> arch/x86/lib/copy_mc_64.S:138:2: warning: DWARF2 only supports one section per compilation unit .section .fixup, "ax" ^ -- >> <instantiation>:11:2: warning: DWARF2 only supports one section per compilation unit .pushsection .altinstr_replacement,"ax" ^ arch/x86/lib/copy_page_64.S:17:2: note: while in macro instantiation ALTERNATIVE "jmp copy_page_regs", "", ( 3*32+16) ^ -- >> <instantiation>:11:2: warning: DWARF2 only supports one section per compilation unit .pushsection .altinstr_replacement,"ax" ^ arch/x86/lib/copy_user_64.S:58:2: note: while in macro instantiation ALTERNATIVE "", ".byte 0x0f,0x01,0xcb", ( 9*32+20) ^ <instantiation>:15:2: warning: DWARF2 only supports one section per compilation unit .section .fixup,"ax" ^ arch/x86/lib/copy_user_64.S:61:2: note: while in macro instantiation ALIGN_DESTINATION ^ -- >> <instantiation>:11:2: warning: DWARF2 only supports one section per compilation unit .pushsection .altinstr_replacement,"ax" ^ arch/x86/lib/getuser.S:56:2: note: while in macro instantiation ALTERNATIVE "", ".byte 0x0f,0x01,0xcb", ( 9*32+20) ^ -- >> arch/x86/lib/memcpy_64.S:10:1: warning: DWARF2 only supports one section per compilation unit .pushsection .noinstr.text, "ax" ^ <instantiation>:13:2: warning: DWARF2 only supports one section per compilation unit .pushsection .altinstr_replacement,"ax" ^ arch/x86/lib/memcpy_64.S:32:2: note: while in macro instantiation ALTERNATIVE_2 "jmp memcpy_orig", "", ( 3*32+16), "jmp memcpy_erms", ( 9*32+ 9) ^ -- >> <instantiation>:11:2: warning: DWARF2 only supports one section per compilation unit .pushsection .altinstr_replacement,"ax" ^ arch/x86/lib/memmove_64.S:42:2: note: while in macro instantiation ALTERNATIVE "cmp $0x20, %rdx; jb 1f", "", (18*32+ 4) ^ -- >> <instantiation>:11:2: warning: DWARF2 only supports one section per compilation unit .pushsection .altinstr_replacement,"ax" ^ arch/x86/lib/putuser.S:51:2: note: while in macro instantiation ALTERNATIVE "", ".byte 0x0f,0x01,0xcb", ( 9*32+20) ^ vim +47 arch/x86/entry/entry_64.S 6fd166aae78c0a arch/x86/entry/entry_64.S Peter Zijlstra 2017-12-04 45 ^1da177e4c3f41 arch/x86_64/kernel/entry.S Linus Torvalds 2005-04-16 46 .code64 ea7145477a461e arch/x86/kernel/entry_64.S Jiri Olsa 2011-03-07 @47 .section .entry.text, "ax" ea7145477a461e arch/x86/kernel/entry_64.S Jiri Olsa 2011-03-07 48 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 29380 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as 2021-03-02 21:06 ` [PATCH 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as Nathan Chancellor ` (2 preceding siblings ...) 2021-09-29 17:26 ` kernel test robot @ 2021-09-29 19:32 ` kernel test robot 3 siblings, 0 replies; 20+ messages in thread From: kernel test robot @ 2021-09-29 19:32 UTC (permalink / raw) To: Nathan Chancellor, Masahiro Yamada, Michal Marek, Nick Desaulniers Cc: llvm, kbuild-all, linux-kbuild, linux-kernel, clang-built-linux, Nathan Chancellor [-- Attachment #1: Type: text/plain, Size: 1846 bytes --] Hi Nathan, I love your patch! Perhaps something to improve: [auto build test WARNING on 7a7fd0de4a9804299793e564a555a49c1fc924cb] url: https://github.com/0day-ci/linux/commits/Nathan-Chancellor/Makefile-Remove-gcc-toolchain-flag/20210929-112213 base: 7a7fd0de4a9804299793e564a555a49c1fc924cb config: x86_64-randconfig-a011-20210929 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project dc6e8dfdfe7efecfda318d43a06fae18b40eb498) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/74a168f9e88d9edf5aaa8209d2c39e676de2857a git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Nathan-Chancellor/Makefile-Remove-gcc-toolchain-flag/20210929-112213 git checkout 74a168f9e88d9edf5aaa8209d2c39e676de2857a # save the attached .config to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash arch/x86/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> arch/x86/platform/pvh/head.S:22:2: warning: DWARF2 only supports one section per compilation unit .section ".head.text","ax" ^ vim +22 arch/x86/platform/pvh/head.S 7243b93345f7f8d arch/x86/xen/xen-pvh.S Boris Ostrovsky 2017-02-05 21 7243b93345f7f8d arch/x86/xen/xen-pvh.S Boris Ostrovsky 2017-02-05 @22 __HEAD 7243b93345f7f8d arch/x86/xen/xen-pvh.S Boris Ostrovsky 2017-02-05 23 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 32508 bytes --] ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag 2021-03-02 21:06 [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag Nathan Chancellor 2021-03-02 21:06 ` [PATCH 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as Nathan Chancellor @ 2021-03-02 21:43 ` Fangrui Song 2021-03-03 8:33 ` Masahiro Yamada 2021-03-02 22:33 ` Nick Desaulniers ` (2 subsequent siblings) 4 siblings, 1 reply; 20+ messages in thread From: Fangrui Song @ 2021-03-02 21:43 UTC (permalink / raw) To: Nathan Chancellor Cc: Masahiro Yamada, Michal Marek, Nick Desaulniers, linux-kbuild, linux-kernel, clang-built-linux Reviewed-by: Fangrui Song <maskray@google.com> Thanks for the clean-up! --gcc-toolchain= is an obsscure way searching for GCC installation prefixes (--prefix). The logic is complex and different for different distributions/architectures. If we specify --prefix= (-B) explicitly, --gcc-toolchain is not needed. On 2021-03-02, Nathan Chancellor wrote: >This is not necessary anymore now that we specify '--prefix=', which >tells clang exactly where to find the GNU cross tools. This has been >verified with self compiled LLVM 10.0.1 and LLVM 13.0.0 as well as a >distribution version of LLVM 11.1.0 without binutils in the LLVM >toolchain locations. > >Signed-off-by: Nathan Chancellor <nathan@kernel.org> >--- > Makefile | 4 ---- > 1 file changed, 4 deletions(-) > >diff --git a/Makefile b/Makefile >index f9b54da2fca0..c20f0ad8be73 100644 >--- a/Makefile >+++ b/Makefile >@@ -568,10 +568,6 @@ ifneq ($(CROSS_COMPILE),) > CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) > GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) > CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) >-GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) >-endif >-ifneq ($(GCC_TOOLCHAIN),) >-CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) > endif > ifneq ($(LLVM_IAS),1) > CLANG_FLAGS += -no-integrated-as > >base-commit: 7a7fd0de4a9804299793e564a555a49c1fc924cb >-- >2.31.0.rc0.75.gec125d1bc1 > >-- >You received this message because you are subscribed to the Google Groups "Clang Built Linux" group. >To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com. >To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20210302210646.3044738-1-nathan%40kernel.org. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag 2021-03-02 21:43 ` [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag Fangrui Song @ 2021-03-03 8:33 ` Masahiro Yamada 0 siblings, 0 replies; 20+ messages in thread From: Masahiro Yamada @ 2021-03-03 8:33 UTC (permalink / raw) To: Fangrui Song Cc: Nathan Chancellor, Michal Marek, Nick Desaulniers, Linux Kbuild mailing list, Linux Kernel Mailing List, clang-built-linux Hi. On Wed, Mar 3, 2021 at 6:44 AM Fangrui Song <maskray@google.com> wrote: > > Reviewed-by: Fangrui Song <maskray@google.com> > > Thanks for the clean-up! > --gcc-toolchain= is an obsscure way searching for GCC installation prefixes (--prefix). > The logic is complex and different for different distributions/architectures. > > If we specify --prefix= (-B) explicitly, --gcc-toolchain is not needed. I tested this, and worked for me too. Before applying this patch, could you please help me understand the logic? I checked the manual (https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-b-dir) -B<dir>, --prefix <arg>, --prefix=<arg> Add <dir> to search path for binaries and object files used implicitly --gcc-toolchain=<arg>, -gcc-toolchain <arg> Use the gcc toolchain at the given directory Hmm, this description is too concise to understand how it works... I use Ubuntu 20.10. I use distro's default clang located in /usr/bin/clang. I place my aarch64 linaro toolchain in /home/masahiro/tools/aarch64-linaro-7.5/bin/aarch64-linux-gnu-gcc, which is not in my PATH environment. From my some experiments, clang --target=aarch64-linux-gnu -no-integrated-as \ --prefix=/home/masahiro/tools/aarch64-linaro-7.5/bin/aarch64-linux-gnu- ... works almost equivalent to PATH=/home/masahiro/tools/aarch64-linaro-7.5/bin:$PATH \ clang --target=aarch64-linux-gnu -no-integrated-as ... Then, clang will pick up aarch64-linux-gnu-as found in the search path. Is this correct? On the other hand, I could not understand what the purpose of --gcc-toolchain= is. Even if I add --gcc-toolchain=/home/masahiro/tools/aarch64-linaro-7.5, it does not make any difference, and it is completely useless. I read the comment from stephenhines: https://github.com/ClangBuiltLinux/linux/issues/78 How could --gcc-toolchain be used in a useful way? > On 2021-03-02, Nathan Chancellor wrote: > >This is not necessary anymore now that we specify '--prefix=', which > >tells clang exactly where to find the GNU cross tools. This has been > >verified with self compiled LLVM 10.0.1 and LLVM 13.0.0 as well as a > >distribution version of LLVM 11.1.0 without binutils in the LLVM > >toolchain locations. > > > >Signed-off-by: Nathan Chancellor <nathan@kernel.org> > >--- > > Makefile | 4 ---- > > 1 file changed, 4 deletions(-) > > > >diff --git a/Makefile b/Makefile > >index f9b54da2fca0..c20f0ad8be73 100644 > >--- a/Makefile > >+++ b/Makefile > >@@ -568,10 +568,6 @@ ifneq ($(CROSS_COMPILE),) > > CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) > > GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) > > CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) > >-GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) > >-endif > >-ifneq ($(GCC_TOOLCHAIN),) > >-CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) > > endif > > ifneq ($(LLVM_IAS),1) > > CLANG_FLAGS += -no-integrated-as > > > >base-commit: 7a7fd0de4a9804299793e564a555a49c1fc924cb > >-- > >2.31.0.rc0.75.gec125d1bc1 > > > >-- > >You received this message because you are subscribed to the Google Groups "Clang Built Linux" group. > >To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com. > >To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20210302210646.3044738-1-nathan%40kernel.org. -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag 2021-03-02 21:06 [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag Nathan Chancellor 2021-03-02 21:06 ` [PATCH 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as Nathan Chancellor 2021-03-02 21:43 ` [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag Fangrui Song @ 2021-03-02 22:33 ` Nick Desaulniers 2021-03-03 3:25 ` Sedat Dilek 2021-03-09 20:59 ` [PATCH v2 " Nathan Chancellor 4 siblings, 0 replies; 20+ messages in thread From: Nick Desaulniers @ 2021-03-02 22:33 UTC (permalink / raw) To: Nathan Chancellor Cc: Masahiro Yamada, Michal Marek, Linux Kbuild mailing list, LKML, clang-built-linux On Tue, Mar 2, 2021 at 1:07 PM Nathan Chancellor <nathan@kernel.org> wrote: > > This is not necessary anymore now that we specify '--prefix=', which > tells clang exactly where to find the GNU cross tools. This has been > verified with self compiled LLVM 10.0.1 and LLVM 13.0.0 as well as a > distribution version of LLVM 11.1.0 without binutils in the LLVM > toolchain locations. > > Signed-off-by: Nathan Chancellor <nathan@kernel.org> Thanks for the patch! Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Tested-by: Nick Desaulniers <ndesaulniers@google.com> I see this pattern still being used in arch/arm64/kernel/vdso32/Makefile, but that can be separate cleanups. > --- > Makefile | 4 ---- > 1 file changed, 4 deletions(-) > > diff --git a/Makefile b/Makefile > index f9b54da2fca0..c20f0ad8be73 100644 > --- a/Makefile > +++ b/Makefile > @@ -568,10 +568,6 @@ ifneq ($(CROSS_COMPILE),) > CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) > GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) > CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) > -GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) > -endif > -ifneq ($(GCC_TOOLCHAIN),) > -CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) > endif > ifneq ($(LLVM_IAS),1) > CLANG_FLAGS += -no-integrated-as > > base-commit: 7a7fd0de4a9804299793e564a555a49c1fc924cb > -- > 2.31.0.rc0.75.gec125d1bc1 > -- Thanks, ~Nick Desaulniers ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag 2021-03-02 21:06 [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag Nathan Chancellor ` (2 preceding siblings ...) 2021-03-02 22:33 ` Nick Desaulniers @ 2021-03-03 3:25 ` Sedat Dilek 2021-03-03 14:22 ` Sedat Dilek 2021-03-09 20:59 ` [PATCH v2 " Nathan Chancellor 4 siblings, 1 reply; 20+ messages in thread From: Sedat Dilek @ 2021-03-03 3:25 UTC (permalink / raw) To: Nathan Chancellor Cc: Masahiro Yamada, Michal Marek, Nick Desaulniers, linux-kbuild, linux-kernel, Clang-Built-Linux ML, Behan Webster On Tue, Mar 2, 2021 at 10:07 PM Nathan Chancellor <nathan@kernel.org> wrote: > > This is not necessary anymore now that we specify '--prefix=', which > tells clang exactly where to find the GNU cross tools. This has been > verified with self compiled LLVM 10.0.1 and LLVM 13.0.0 as well as a > distribution version of LLVM 11.1.0 without binutils in the LLVM > toolchain locations. > > Signed-off-by: Nathan Chancellor <nathan@kernel.org> [ CC Behan ] Hahaha, that is a change of a very early commit in times of the LLVM/Clang Linux-kernel development. So-to-say a historical change :-). I will try this patchset later with latest Linux -v5.12-rc1+ and my custom patchset. Thanks. - Sedat - > --- > Makefile | 4 ---- > 1 file changed, 4 deletions(-) > > diff --git a/Makefile b/Makefile > index f9b54da2fca0..c20f0ad8be73 100644 > --- a/Makefile > +++ b/Makefile > @@ -568,10 +568,6 @@ ifneq ($(CROSS_COMPILE),) > CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) > GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) > CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) > -GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) > -endif > -ifneq ($(GCC_TOOLCHAIN),) > -CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) > endif > ifneq ($(LLVM_IAS),1) > CLANG_FLAGS += -no-integrated-as > > base-commit: 7a7fd0de4a9804299793e564a555a49c1fc924cb > -- > 2.31.0.rc0.75.gec125d1bc1 > > -- > You received this message because you are subscribed to the Google Groups "Clang Built Linux" group. > To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20210302210646.3044738-1-nathan%40kernel.org. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag 2021-03-03 3:25 ` Sedat Dilek @ 2021-03-03 14:22 ` Sedat Dilek 0 siblings, 0 replies; 20+ messages in thread From: Sedat Dilek @ 2021-03-03 14:22 UTC (permalink / raw) To: Nathan Chancellor Cc: Masahiro Yamada, Michal Marek, Nick Desaulniers, linux-kbuild, linux-kernel, Clang-Built-Linux ML, Behan Webster On Wed, Mar 3, 2021 at 4:25 AM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > On Tue, Mar 2, 2021 at 10:07 PM Nathan Chancellor <nathan@kernel.org> wrote: > > > > This is not necessary anymore now that we specify '--prefix=', which > > tells clang exactly where to find the GNU cross tools. This has been > > verified with self compiled LLVM 10.0.1 and LLVM 13.0.0 as well as a > > distribution version of LLVM 11.1.0 without binutils in the LLVM > > toolchain locations. > > > > Signed-off-by: Nathan Chancellor <nathan@kernel.org> > > [ CC Behan ] > > Hahaha, that is a change of a very early commit in times of the > LLVM/Clang Linux-kernel development. > So-to-say a historical change :-). > > I will try this patchset later with latest Linux -v5.12-rc1+ and my > custom patchset. > I tested these two patches in my build environment. So far no issues. NOTE: I have not tested the combo: Clang and GNU AS. Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM/Clang v13-git - Sedat - > > --- > > Makefile | 4 ---- > > 1 file changed, 4 deletions(-) > > > > diff --git a/Makefile b/Makefile > > index f9b54da2fca0..c20f0ad8be73 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -568,10 +568,6 @@ ifneq ($(CROSS_COMPILE),) > > CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) > > GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) > > CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) > > -GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) > > -endif > > -ifneq ($(GCC_TOOLCHAIN),) > > -CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) > > endif > > ifneq ($(LLVM_IAS),1) > > CLANG_FLAGS += -no-integrated-as > > > > base-commit: 7a7fd0de4a9804299793e564a555a49c1fc924cb > > -- > > 2.31.0.rc0.75.gec125d1bc1 > > > > -- > > You received this message because you are subscribed to the Google Groups "Clang Built Linux" group. > > To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com. > > To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20210302210646.3044738-1-nathan%40kernel.org. ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v2 1/2] Makefile: Remove '--gcc-toolchain' flag 2021-03-02 21:06 [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag Nathan Chancellor ` (3 preceding siblings ...) 2021-03-03 3:25 ` Sedat Dilek @ 2021-03-09 20:59 ` Nathan Chancellor 2021-03-09 20:59 ` [PATCH v2 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as Nathan Chancellor ` (2 more replies) 4 siblings, 3 replies; 20+ messages in thread From: Nathan Chancellor @ 2021-03-09 20:59 UTC (permalink / raw) To: Masahiro Yamada, Michal Marek, Nick Desaulniers Cc: linux-kbuild, linux-kernel, clang-built-linux, Sedat Dilek, Fangrui Song, Nathan Chancellor This flag was originally added to allow clang to find the GNU cross tools in commit 785f11aa595b ("kbuild: Add better clang cross build support"). This flag was not enough to find the tools at times so '--prefix' was added to the list in commit ef8c4ed9db80 ("kbuild: allow to use GCC toolchain not in Clang search path") and improved upon in commit ca9b31f6bb9c ("Makefile: Fix GCC_TOOLCHAIN_DIR prefix for Clang cross compilation"). Now that '--prefix' specifies a full path and prefix, '--gcc-toolchain' serves no purpose because the kernel builds with '-nostdinc' and '-nostdlib'. This has been verified with self compiled LLVM 10.0.1 and LLVM 13.0.0 as well as a distribution version of LLVM 11.1.0 without binutils in the LLVM toolchain locations. Link: https://reviews.llvm.org/D97902 Signed-off-by: Nathan Chancellor <nathan@kernel.org> --- v1 -> v2: * Improve commit message (add history behind flag and link to Fangrui's documentation improvement). I did not carry tags forward so that people could re-review and test. Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Makefile b/Makefile index 31dcdb3d61fa..182e93d91198 100644 --- a/Makefile +++ b/Makefile @@ -568,10 +568,6 @@ ifneq ($(CROSS_COMPILE),) CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) -GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) -endif -ifneq ($(GCC_TOOLCHAIN),) -CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) endif ifneq ($(LLVM_IAS),1) CLANG_FLAGS += -no-integrated-as base-commit: a38fd8748464831584a19438cbb3082b5a2dab15 -- 2.31.0.rc1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as 2021-03-09 20:59 ` [PATCH v2 " Nathan Chancellor @ 2021-03-09 20:59 ` Nathan Chancellor 2021-03-09 21:15 ` [PATCH v2 1/2] Makefile: Remove '--gcc-toolchain' flag Fangrui Song 2021-03-15 16:21 ` Masahiro Yamada 2 siblings, 0 replies; 20+ messages in thread From: Nathan Chancellor @ 2021-03-09 20:59 UTC (permalink / raw) To: Masahiro Yamada, Michal Marek, Nick Desaulniers Cc: linux-kbuild, linux-kernel, clang-built-linux, Sedat Dilek, Fangrui Song, Nathan Chancellor When building with LLVM_IAS=1, there is no point to specifying '--prefix=' because that flag is only used to find GNU cross tools, which will not be used indirectly when using the integrated assembler. All of the tools are invoked directly from PATH or a full path specified via the command line, which does not depend on the value of '--prefix='. Sharing commands to reproduce issues becomes a little bit easier without a '--prefix=' value because that '--prefix=' value is specific to a user's machine due to it being an absolute path. Some further notes from Fangrui Song: clang can spawn GNU as (if -f?no-integrated-as is specified) and GNU objcopy (-f?no-integrated-as and -gsplit-dwarf and -g[123]). objcopy is only used for GNU as assembled object files. With integrated assembler, the object file streamer creates .o and .dwo simultaneously. With GNU as, two objcopy commands are needed to extract .debug*.dwo to .dwo files && another command to remove .debug*.dwo sections. A small consequence of this change (to keep things simple) is that '--prefix=' will always be specified now, even with a native build, when it was not before. This should not be an issue due to the way that the Makefile searches for the prefix (based on elfedit's location). This ends up improving the experience for host builds because PATH is better respected and matches GCC's behavior more closely. See the below thread for more details: https://lore.kernel.org/r/20210205213651.GA16907@Ryzen-5-4500U.localdomain/ Signed-off-by: Nathan Chancellor <nathan@kernel.org> --- v1 -> v2: * Fix position of -no-integrated-as flag to fix native build (thanks to Masahiro for catching it and sorry for the breakage). * Add Fangrui's comments about what GNU binaries clang can spawn at Masahiro's request. * Reword commit message. I did not carry tags forward so that people could re-review and test. Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 182e93d91198..15292a6d63f5 100644 --- a/Makefile +++ b/Makefile @@ -566,11 +566,11 @@ CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1 | sed 's/\#//g ifneq ($(findstring clang,$(CC_VERSION_TEXT)),) ifneq ($(CROSS_COMPILE),) CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) -GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) -CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) endif ifneq ($(LLVM_IAS),1) CLANG_FLAGS += -no-integrated-as +GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) +CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) endif CLANG_FLAGS += -Werror=unknown-warning-option KBUILD_CFLAGS += $(CLANG_FLAGS) -- 2.31.0.rc1 ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH v2 1/2] Makefile: Remove '--gcc-toolchain' flag 2021-03-09 20:59 ` [PATCH v2 " Nathan Chancellor 2021-03-09 20:59 ` [PATCH v2 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as Nathan Chancellor @ 2021-03-09 21:15 ` Fangrui Song 2021-03-15 16:21 ` Masahiro Yamada 2 siblings, 0 replies; 20+ messages in thread From: Fangrui Song @ 2021-03-09 21:15 UTC (permalink / raw) To: Nathan Chancellor Cc: Masahiro Yamada, Michal Marek, Nick Desaulniers, linux-kbuild, linux-kernel, clang-built-linux, Sedat Dilek On 2021-03-09, Nathan Chancellor wrote: >This flag was originally added to allow clang to find the GNU cross >tools in commit 785f11aa595b ("kbuild: Add better clang cross build >support"). This flag was not enough to find the tools at times so >'--prefix' was added to the list in commit ef8c4ed9db80 ("kbuild: allow >to use GCC toolchain not in Clang search path") and improved upon in >commit ca9b31f6bb9c ("Makefile: Fix GCC_TOOLCHAIN_DIR prefix for Clang >cross compilation"). Now that '--prefix' specifies a full path and >prefix, '--gcc-toolchain' serves no purpose because the kernel builds >with '-nostdinc' and '-nostdlib'. > >This has been verified with self compiled LLVM 10.0.1 and LLVM 13.0.0 as >well as a distribution version of LLVM 11.1.0 without binutils in the >LLVM toolchain locations. > >Link: https://reviews.llvm.org/D97902 >Signed-off-by: Nathan Chancellor <nathan@kernel.org> The wording looks good. Reviewed-by: Fangrui Song <maskray@google.com> ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 1/2] Makefile: Remove '--gcc-toolchain' flag 2021-03-09 20:59 ` [PATCH v2 " Nathan Chancellor 2021-03-09 20:59 ` [PATCH v2 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as Nathan Chancellor 2021-03-09 21:15 ` [PATCH v2 1/2] Makefile: Remove '--gcc-toolchain' flag Fangrui Song @ 2021-03-15 16:21 ` Masahiro Yamada 2021-03-15 16:41 ` Sedat Dilek 2 siblings, 1 reply; 20+ messages in thread From: Masahiro Yamada @ 2021-03-15 16:21 UTC (permalink / raw) To: Nathan Chancellor Cc: Michal Marek, Nick Desaulniers, Linux Kbuild mailing list, Linux Kernel Mailing List, clang-built-linux, Sedat Dilek, Fangrui Song On Wed, Mar 10, 2021 at 5:59 AM Nathan Chancellor <nathan@kernel.org> wrote: > > This flag was originally added to allow clang to find the GNU cross > tools in commit 785f11aa595b ("kbuild: Add better clang cross build > support"). This flag was not enough to find the tools at times so > '--prefix' was added to the list in commit ef8c4ed9db80 ("kbuild: allow > to use GCC toolchain not in Clang search path") and improved upon in > commit ca9b31f6bb9c ("Makefile: Fix GCC_TOOLCHAIN_DIR prefix for Clang > cross compilation"). Now that '--prefix' specifies a full path and > prefix, '--gcc-toolchain' serves no purpose because the kernel builds > with '-nostdinc' and '-nostdlib'. > > This has been verified with self compiled LLVM 10.0.1 and LLVM 13.0.0 as > well as a distribution version of LLVM 11.1.0 without binutils in the > LLVM toolchain locations. > > Link: https://reviews.llvm.org/D97902 > Signed-off-by: Nathan Chancellor <nathan@kernel.org> > --- > > v1 -> v2: > > * Improve commit message (add history behind flag and link to Fangrui's > documentation improvement). Both applied to linux-kbuild. Thanks. > I did not carry tags forward so that people could re-review and test. > > Makefile | 4 ---- > 1 file changed, 4 deletions(-) > > diff --git a/Makefile b/Makefile > index 31dcdb3d61fa..182e93d91198 100644 > --- a/Makefile > +++ b/Makefile > @@ -568,10 +568,6 @@ ifneq ($(CROSS_COMPILE),) > CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) > GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) > CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) > -GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) > -endif > -ifneq ($(GCC_TOOLCHAIN),) > -CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) > endif > ifneq ($(LLVM_IAS),1) > CLANG_FLAGS += -no-integrated-as > > base-commit: a38fd8748464831584a19438cbb3082b5a2dab15 > -- > 2.31.0.rc1 > -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 1/2] Makefile: Remove '--gcc-toolchain' flag 2021-03-15 16:21 ` Masahiro Yamada @ 2021-03-15 16:41 ` Sedat Dilek 2021-03-16 15:36 ` Masahiro Yamada 0 siblings, 1 reply; 20+ messages in thread From: Sedat Dilek @ 2021-03-15 16:41 UTC (permalink / raw) To: Masahiro Yamada Cc: Nathan Chancellor, Michal Marek, Nick Desaulniers, Linux Kbuild mailing list, Linux Kernel Mailing List, clang-built-linux, Fangrui Song On Mon, Mar 15, 2021 at 5:22 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > On Wed, Mar 10, 2021 at 5:59 AM Nathan Chancellor <nathan@kernel.org> wrote: > > > > This flag was originally added to allow clang to find the GNU cross > > tools in commit 785f11aa595b ("kbuild: Add better clang cross build > > support"). This flag was not enough to find the tools at times so > > '--prefix' was added to the list in commit ef8c4ed9db80 ("kbuild: allow > > to use GCC toolchain not in Clang search path") and improved upon in > > commit ca9b31f6bb9c ("Makefile: Fix GCC_TOOLCHAIN_DIR prefix for Clang > > cross compilation"). Now that '--prefix' specifies a full path and > > prefix, '--gcc-toolchain' serves no purpose because the kernel builds > > with '-nostdinc' and '-nostdlib'. > > > > This has been verified with self compiled LLVM 10.0.1 and LLVM 13.0.0 as > > well as a distribution version of LLVM 11.1.0 without binutils in the > > LLVM toolchain locations. > > > > Link: https://reviews.llvm.org/D97902 > > Signed-off-by: Nathan Chancellor <nathan@kernel.org> > > --- > > > > v1 -> v2: > > > > * Improve commit message (add history behind flag and link to Fangrui's > > documentation improvement). > > > Both applied to linux-kbuild. Thanks. > Sorry for being pedantic: This misses my Tested-by#s (see [1]). Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM/Clang v13-git AFAICS v2 changes some comments in the commit only but not code? - Sedat - [1] https://marc.info/?l=linux-kernel&m=161480031518629&w=2 [2] https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/commit/?h=kbuild&id=d4aa405bc9cd506532f075456645716cdd1739c1 > > > > > > I did not carry tags forward so that people could re-review and test. > > > > Makefile | 4 ---- > > 1 file changed, 4 deletions(-) > > > > diff --git a/Makefile b/Makefile > > index 31dcdb3d61fa..182e93d91198 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -568,10 +568,6 @@ ifneq ($(CROSS_COMPILE),) > > CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) > > GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) > > CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) > > -GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) > > -endif > > -ifneq ($(GCC_TOOLCHAIN),) > > -CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) > > endif > > ifneq ($(LLVM_IAS),1) > > CLANG_FLAGS += -no-integrated-as > > > > base-commit: a38fd8748464831584a19438cbb3082b5a2dab15 > > -- > > 2.31.0.rc1 > > > > > -- > Best Regards > Masahiro Yamada ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 1/2] Makefile: Remove '--gcc-toolchain' flag 2021-03-15 16:41 ` Sedat Dilek @ 2021-03-16 15:36 ` Masahiro Yamada 0 siblings, 0 replies; 20+ messages in thread From: Masahiro Yamada @ 2021-03-16 15:36 UTC (permalink / raw) To: Sedat Dilek Cc: Nathan Chancellor, Michal Marek, Nick Desaulniers, Linux Kbuild mailing list, Linux Kernel Mailing List, clang-built-linux, Fangrui Song On Tue, Mar 16, 2021 at 1:42 AM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > On Mon, Mar 15, 2021 at 5:22 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > > > On Wed, Mar 10, 2021 at 5:59 AM Nathan Chancellor <nathan@kernel.org> wrote: > > > > > > This flag was originally added to allow clang to find the GNU cross > > > tools in commit 785f11aa595b ("kbuild: Add better clang cross build > > > support"). This flag was not enough to find the tools at times so > > > '--prefix' was added to the list in commit ef8c4ed9db80 ("kbuild: allow > > > to use GCC toolchain not in Clang search path") and improved upon in > > > commit ca9b31f6bb9c ("Makefile: Fix GCC_TOOLCHAIN_DIR prefix for Clang > > > cross compilation"). Now that '--prefix' specifies a full path and > > > prefix, '--gcc-toolchain' serves no purpose because the kernel builds > > > with '-nostdinc' and '-nostdlib'. > > > > > > This has been verified with self compiled LLVM 10.0.1 and LLVM 13.0.0 as > > > well as a distribution version of LLVM 11.1.0 without binutils in the > > > LLVM toolchain locations. > > > > > > Link: https://reviews.llvm.org/D97902 > > > Signed-off-by: Nathan Chancellor <nathan@kernel.org> > > > --- > > > > > > v1 -> v2: > > > > > > * Improve commit message (add history behind flag and link to Fangrui's > > > documentation improvement). > > > > > > Both applied to linux-kbuild. Thanks. > > > > Sorry for being pedantic: This misses my Tested-by#s (see [1]). > > Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM/Clang v13-git > > AFAICS v2 changes some comments in the commit only but not code? For 1/2, yes. The difference is only comments. For 2/2, the code was changed. Actually, v1 was wrong. That is why the tags were dropped. I will re-add the tags to 1/2 since there is no code diff. If you re-test 2/2, I will add your tag again. > - Sedat - > > [1] https://marc.info/?l=linux-kernel&m=161480031518629&w=2 > [2] https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/commit/?h=kbuild&id=d4aa405bc9cd506532f075456645716cdd1739c1 > > > > > > > > > > > > I did not carry tags forward so that people could re-review and test. > > > > > > Makefile | 4 ---- > > > 1 file changed, 4 deletions(-) > > > > > > diff --git a/Makefile b/Makefile > > > index 31dcdb3d61fa..182e93d91198 100644 > > > --- a/Makefile > > > +++ b/Makefile > > > @@ -568,10 +568,6 @@ ifneq ($(CROSS_COMPILE),) > > > CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) > > > GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) > > > CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) > > > -GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) > > > -endif > > > -ifneq ($(GCC_TOOLCHAIN),) > > > -CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) > > > endif > > > ifneq ($(LLVM_IAS),1) > > > CLANG_FLAGS += -no-integrated-as > > > > > > base-commit: a38fd8748464831584a19438cbb3082b5a2dab15 > > > -- > > > 2.31.0.rc1 > > > > > > > > > -- > > Best Regards > > Masahiro Yamada -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2021-09-29 19:32 UTC | newest] Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-03-02 21:06 [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag Nathan Chancellor 2021-03-02 21:06 ` [PATCH 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as Nathan Chancellor 2021-03-02 22:02 ` Fangrui Song 2021-03-02 22:09 ` Nick Desaulniers 2021-03-02 22:40 ` Nick Desaulniers 2021-03-09 19:55 ` Masahiro Yamada 2021-03-09 19:58 ` Masahiro Yamada 2021-09-29 17:26 ` kernel test robot 2021-09-29 19:32 ` kernel test robot 2021-03-02 21:43 ` [PATCH 1/2] Makefile: Remove '--gcc-toolchain' flag Fangrui Song 2021-03-03 8:33 ` Masahiro Yamada 2021-03-02 22:33 ` Nick Desaulniers 2021-03-03 3:25 ` Sedat Dilek 2021-03-03 14:22 ` Sedat Dilek 2021-03-09 20:59 ` [PATCH v2 " Nathan Chancellor 2021-03-09 20:59 ` [PATCH v2 2/2] Makefile: Only specify '--prefix=' when building with clang + GNU as Nathan Chancellor 2021-03-09 21:15 ` [PATCH v2 1/2] Makefile: Remove '--gcc-toolchain' flag Fangrui Song 2021-03-15 16:21 ` Masahiro Yamada 2021-03-15 16:41 ` Sedat Dilek 2021-03-16 15:36 ` Masahiro Yamada
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).