Skip to content

Commit

Permalink
kbuild: make Clang build userprogs for target architecture
Browse files Browse the repository at this point in the history
Programs added 'userprogs' should be compiled for the target
architecture i.e. the same architecture as the kernel.

GCC does this correctly since the target architecture is implied
by the toolchain prefix.

Clang builds userspace programs always for the host architecture
because the target triple is currently missing.

Fix this.

Fixes: 7f3a59d ("kbuild: add infrastructure to build userspace programs")
Signed-off-by: Masahiro Yamada <[email protected]>
Reviewed-by: Nick Desaulniers <[email protected]>
Reviewed-by: Nathan Chancellor <[email protected]>
  • Loading branch information
masahir0y committed Jul 1, 2020
1 parent b816b3d commit 7f58b48
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -970,8 +970,8 @@ LDFLAGS_vmlinux += --pack-dyn-relocs=relr
endif

# Align the bit size of userspace programs with the kernel
KBUILD_USERCFLAGS += $(filter -m32 -m64, $(KBUILD_CFLAGS))
KBUILD_USERLDFLAGS += $(filter -m32 -m64, $(KBUILD_CFLAGS))
KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))

# make the checker run with the right architecture
CHECKFLAGS += --arch=$(ARCH)
Expand Down

0 comments on commit 7f58b48

Please sign in to comment.