Message ID | 20210410164930.769251-1-yhs@fb.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | BPF |
Headers | show |
Series | support build selftests/bpf with clang | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 11 maintainers not CCed: linux-kselftest@vger.kernel.org netdev@vger.kernel.org kpsingh@kernel.org daniel@iogearbox.net kafai@fb.com clang-built-linux@googlegroups.com ast@kernel.org nathan@kernel.org john.fastabend@gmail.com songliubraving@fb.com shuah@kernel.org |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 10 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
On Sat, Apr 10, 2021 at 6:49 PM Yonghong Song <yhs@fb.com> wrote: > > selftests/bpf/Makefile includes lib.mk. With the following command > make -j60 LLVM=1 LLVM_IAS=1 <=== compile kernel > make -j60 -C tools/testing/selftests/bpf LLVM=1 LLVM_IAS=1 V=1 > some files are still compiled with gcc. This patch > fixed lib.mk issue which sets CC to gcc in all cases. > > Cc: Sedat Dilek <sedat.dilek@gmail.com> > Signed-off-by: Yonghong Song <yhs@fb.com> > --- > tools/testing/selftests/lib.mk | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk > index a5ce26d548e4..9a41d8bb9ff1 100644 > --- a/tools/testing/selftests/lib.mk > +++ b/tools/testing/selftests/lib.mk > @@ -1,6 +1,10 @@ > # This mimics the top-level Makefile. We do it explicitly here so that this > # Makefile can operate with or without the kbuild infrastructure. > +ifneq ($(LLVM),) > +CC := clang > +else > CC := $(CROSS_COMPILE)gcc > +endif > Why not use include "include ../../../scripts/Makefile.include" here and include CC and GNU or LLVM (bin)utils from there? Should the CC line have a $(CROSS_COMPILE) for people doing cross-compilation? CC := $(CROSS_COMPILE)clang - Sedat - > ifeq (0,$(MAKELEVEL)) > ifeq ($(OUTPUT),) > -- > 2.30.2 >
On 4/11/21 3:22 AM, Sedat Dilek wrote: > On Sat, Apr 10, 2021 at 6:49 PM Yonghong Song <yhs@fb.com> wrote: >> >> selftests/bpf/Makefile includes lib.mk. With the following command >> make -j60 LLVM=1 LLVM_IAS=1 <=== compile kernel >> make -j60 -C tools/testing/selftests/bpf LLVM=1 LLVM_IAS=1 V=1 >> some files are still compiled with gcc. This patch >> fixed lib.mk issue which sets CC to gcc in all cases. >> >> Cc: Sedat Dilek <sedat.dilek@gmail.com> >> Signed-off-by: Yonghong Song <yhs@fb.com> >> --- >> tools/testing/selftests/lib.mk | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk >> index a5ce26d548e4..9a41d8bb9ff1 100644 >> --- a/tools/testing/selftests/lib.mk >> +++ b/tools/testing/selftests/lib.mk >> @@ -1,6 +1,10 @@ >> # This mimics the top-level Makefile. We do it explicitly here so that this >> # Makefile can operate with or without the kbuild infrastructure. >> +ifneq ($(LLVM),) >> +CC := clang >> +else >> CC := $(CROSS_COMPILE)gcc >> +endif >> > > Why not use include "include ../../../scripts/Makefile.include" here > and include CC and GNU or LLVM (bin)utils from there? There is a comment above my change, >> # This mimics the top-level Makefile. We do it explicitly here so that this >> # Makefile can operate with or without the kbuild infrastructure. It is intentionally not depending on kbuild (../../../scripts/Makefile.include). > > Should the CC line have a $(CROSS_COMPILE) for people doing cross-compilation? > > CC := $(CROSS_COMPILE)clang The top linux/Makefile has ifneq ($(LLVM),) CC = clang LD = ld.lld AR = llvm-ar NM = llvm-nm OBJCOPY = llvm-objcopy OBJDUMP = llvm-objdump READELF = llvm-readelf STRIP = llvm-strip else CC = $(CROSS_COMPILE)gcc LD = $(CROSS_COMPILE)ld AR = $(CROSS_COMPILE)ar NM = $(CROSS_COMPILE)nm OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump READELF = $(CROSS_COMPILE)readelf STRIP = $(CROSS_COMPILE)strip endif There is no CROSS_COMPILE prefix for llvm. Also see here: https://clang.llvm.org/docs/CrossCompilation.html for clang, cross compilation is mostly related to tweaking compiler options than building a different compiler. Hence, I didn't add $(CROSS_COMPILER) prefix. > > - Sedat - > > >> ifeq (0,$(MAKELEVEL)) >> ifeq ($(OUTPUT),) >> -- >> 2.30.2 >>
On Sun, Apr 11, 2021 at 6:51 PM Yonghong Song <yhs@fb.com> wrote: > > > > On 4/11/21 3:22 AM, Sedat Dilek wrote: > > On Sat, Apr 10, 2021 at 6:49 PM Yonghong Song <yhs@fb.com> wrote: > >> > >> selftests/bpf/Makefile includes lib.mk. With the following command > >> make -j60 LLVM=1 LLVM_IAS=1 <=== compile kernel > >> make -j60 -C tools/testing/selftests/bpf LLVM=1 LLVM_IAS=1 V=1 > >> some files are still compiled with gcc. This patch > >> fixed lib.mk issue which sets CC to gcc in all cases. > >> > >> Cc: Sedat Dilek <sedat.dilek@gmail.com> > >> Signed-off-by: Yonghong Song <yhs@fb.com> > >> --- > >> tools/testing/selftests/lib.mk | 4 ++++ > >> 1 file changed, 4 insertions(+) > >> > >> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk > >> index a5ce26d548e4..9a41d8bb9ff1 100644 > >> --- a/tools/testing/selftests/lib.mk > >> +++ b/tools/testing/selftests/lib.mk > >> @@ -1,6 +1,10 @@ > >> # This mimics the top-level Makefile. We do it explicitly here so that this > >> # Makefile can operate with or without the kbuild infrastructure. > >> +ifneq ($(LLVM),) > >> +CC := clang > >> +else > >> CC := $(CROSS_COMPILE)gcc > >> +endif > >> > > > > Why not use include "include ../../../scripts/Makefile.include" here > > and include CC and GNU or LLVM (bin)utils from there? > > There is a comment above my change, > > >> # This mimics the top-level Makefile. We do it explicitly here so > that this > >> # Makefile can operate with or without the kbuild infrastructure. > > It is intentionally not depending on kbuild > (../../../scripts/Makefile.include). > > > > > Should the CC line have a $(CROSS_COMPILE) for people doing cross-compilation? > > > > CC := $(CROSS_COMPILE)clang > > The top linux/Makefile has > > ifneq ($(LLVM),) > CC = clang > LD = ld.lld > AR = llvm-ar > NM = llvm-nm > OBJCOPY = llvm-objcopy > OBJDUMP = llvm-objdump > READELF = llvm-readelf > STRIP = llvm-strip > else > CC = $(CROSS_COMPILE)gcc > LD = $(CROSS_COMPILE)ld > AR = $(CROSS_COMPILE)ar > NM = $(CROSS_COMPILE)nm > OBJCOPY = $(CROSS_COMPILE)objcopy > OBJDUMP = $(CROSS_COMPILE)objdump > READELF = $(CROSS_COMPILE)readelf > STRIP = $(CROSS_COMPILE)strip > endif > > There is no CROSS_COMPILE prefix for llvm. > Also see here: > https://clang.llvm.org/docs/CrossCompilation.html > for clang, cross compilation is mostly related to > tweaking compiler options than building a different > compiler. > > Hence, I didn't add $(CROSS_COMPILER) prefix. > OK, I see. My last cross-compilation for a linux-kernel is very long ago. I never used it with LLVM toolchain - might be $(CROSS_COMPILE) is only necessary with GNU toolchain. - Sedat - > > > > - Sedat - > > > > > >> ifeq (0,$(MAKELEVEL)) > >> ifeq ($(OUTPUT),) > >> -- > >> 2.30.2 > >>
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk index a5ce26d548e4..9a41d8bb9ff1 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk @@ -1,6 +1,10 @@ # This mimics the top-level Makefile. We do it explicitly here so that this # Makefile can operate with or without the kbuild infrastructure. +ifneq ($(LLVM),) +CC := clang +else CC := $(CROSS_COMPILE)gcc +endif ifeq (0,$(MAKELEVEL)) ifeq ($(OUTPUT),)
selftests/bpf/Makefile includes lib.mk. With the following command make -j60 LLVM=1 LLVM_IAS=1 <=== compile kernel make -j60 -C tools/testing/selftests/bpf LLVM=1 LLVM_IAS=1 V=1 some files are still compiled with gcc. This patch fixed lib.mk issue which sets CC to gcc in all cases. Cc: Sedat Dilek <sedat.dilek@gmail.com> Signed-off-by: Yonghong Song <yhs@fb.com> --- tools/testing/selftests/lib.mk | 4 ++++ 1 file changed, 4 insertions(+)