Message ID | 20210730201701.3146910-2-ndesaulniers@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | infer --target from SRCARCH for CC=clang | expand |
On Fri, Jul 30, 2021 at 1:17 PM Nick Desaulniers <ndesaulniers@google.com> wrote: > > +ifeq ($(SRCARCH),arm) > +CLANG_FLAGS += --target=arm-linux-gnueabi ..,. Ugh. A wise man once said: "All problems in computer science can be solved with another level of indirection". Just do it like this: CLANG_TARGET_FLAGS_arm = arm-linux-gnueabi CLANG_TARGET_FLAGS_hexagon = hexagon-linux-gnu .. CLANG_TARGET_FLAGS = $(CLANG_TARGET_FLAGS_$(ARCH)) Which is a lot denser and simpler. And then the only if-statement can be something along the lines of ifeq ($(CLANG_TARGET_FLAGS),) $(error Specify clang target flags) else CLANG_FLAGS += --target=$(CLANG_TARGET_FLAGS) endif Plus add *random handwaving* about all the details for CROSS_COMPILE and friends. Linus
On Fri, Jul 30, 2021 at 2:54 PM Linus Torvalds <torvalds@linux-foundation.org> wrote: > > On Fri, Jul 30, 2021 at 1:17 PM Nick Desaulniers > <ndesaulniers@google.com> wrote: > > > > +ifeq ($(SRCARCH),arm) > > +CLANG_FLAGS += --target=arm-linux-gnueabi > ..,. > > Ugh. > > A wise man once said: "All problems in computer science can be solved > with another level of indirection". > > Just do it like this: > > CLANG_TARGET_FLAGS_arm = arm-linux-gnueabi > CLANG_TARGET_FLAGS_hexagon = hexagon-linux-gnu > .. > CLANG_TARGET_FLAGS = $(CLANG_TARGET_FLAGS_$(ARCH)) > > Which is a lot denser and simpler. > > And then the only if-statement can be something along the lines of > > ifeq ($(CLANG_TARGET_FLAGS),) > $(error Specify clang target flags) > else > CLANG_FLAGS += --target=$(CLANG_TARGET_FLAGS) > endif D'oh, just sent v5 before seeing this. SGTM will work on v6. > > Plus add *random handwaving* about all the details for CROSS_COMPILE > and friends. > > Linus
diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang index 297932e973d4..f983f65dd9f5 100644 --- a/scripts/Makefile.clang +++ b/scripts/Makefile.clang @@ -1,6 +1,32 @@ -ifneq ($(CROSS_COMPILE),) +# Individual arch/{arch}/Makefiles should use -EL/-EB to set intended +# endianness and -m32/-m64 to set word size based on Kconfigs instead of +# relying on the target triple. +ifeq ($(CROSS_COMPILE),) +ifeq ($(SRCARCH),arm) +CLANG_FLAGS += --target=arm-linux-gnueabi +else ifeq ($(SRCARCH),arm64) +CLANG_FLAGS += --target=aarch64-linux-gnu +else ifeq ($(SRCARCH),hexagon) +CLANG_FLAGS += --target=hexagon-linux-gnu +else ifeq ($(SRCARCH),m68k) +CLANG_FLAGS += --target=m68k-linux-gnu +else ifeq ($(SRCARCH),mips) +CLANG_FLAGS += --target=mipsel-linux-gnu +else ifeq ($(SRCARCH),powerpc) +CLANG_FLAGS += --target=powerpc64le-linux-gnu +else ifeq ($(SRCARCH),riscv) +CLANG_FLAGS += --target=riscv64-linux-gnu +else ifeq ($(SRCARCH),s390) +CLANG_FLAGS += --target=s390x-linux-gnu +else ifeq ($(SRCARCH),x86) +CLANG_FLAGS += --target=x86_64-linux-gnu +else +$(error Specify CROSS_COMPILE or add '--target=' option to scripts/Makefile.clang) +endif # SRCARCH +else CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) -endif +endif # CROSS_COMPILE + ifeq ($(LLVM_IAS),1) CLANG_FLAGS += -integrated-as else