162306a36Sopenharmony_ci# Individual arch/{arch}/Makefiles should use -EL/-EB to set intended
262306a36Sopenharmony_ci# endianness and -m32/-m64 to set word size based on Kconfigs instead of
362306a36Sopenharmony_ci# relying on the target triple.
462306a36Sopenharmony_ciCLANG_TARGET_FLAGS_arm		:= arm-linux-gnueabi
562306a36Sopenharmony_ciCLANG_TARGET_FLAGS_arm64	:= aarch64-linux-gnu
662306a36Sopenharmony_ciCLANG_TARGET_FLAGS_hexagon	:= hexagon-linux-musl
762306a36Sopenharmony_ciCLANG_TARGET_FLAGS_loongarch	:= loongarch64-linux-gnusf
862306a36Sopenharmony_ciCLANG_TARGET_FLAGS_m68k		:= m68k-linux-gnu
962306a36Sopenharmony_ciCLANG_TARGET_FLAGS_mips		:= mipsel-linux-gnu
1062306a36Sopenharmony_ciCLANG_TARGET_FLAGS_powerpc	:= powerpc64le-linux-gnu
1162306a36Sopenharmony_ciCLANG_TARGET_FLAGS_riscv	:= riscv64-linux-gnu
1262306a36Sopenharmony_ciCLANG_TARGET_FLAGS_s390		:= s390x-linux-gnu
1362306a36Sopenharmony_ciCLANG_TARGET_FLAGS_x86		:= x86_64-linux-gnu
1462306a36Sopenharmony_ciCLANG_TARGET_FLAGS_um		:= $(CLANG_TARGET_FLAGS_$(SUBARCH))
1562306a36Sopenharmony_ciCLANG_TARGET_FLAGS		:= $(CLANG_TARGET_FLAGS_$(SRCARCH))
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ciifeq ($(CLANG_TARGET_FLAGS),)
1862306a36Sopenharmony_ci$(error add '--target=' option to scripts/Makefile.clang)
1962306a36Sopenharmony_cielse
2062306a36Sopenharmony_ciCLANG_FLAGS	+= --target=$(CLANG_TARGET_FLAGS)
2162306a36Sopenharmony_ciendif
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ciifeq ($(LLVM_IAS),0)
2462306a36Sopenharmony_ciCLANG_FLAGS	+= -fno-integrated-as
2562306a36Sopenharmony_ciGCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
2662306a36Sopenharmony_ciCLANG_FLAGS	+= --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
2762306a36Sopenharmony_cielse
2862306a36Sopenharmony_ciCLANG_FLAGS	+= -fintegrated-as
2962306a36Sopenharmony_ciendif
3062306a36Sopenharmony_ci# By default, clang only warns when it encounters an unknown warning flag or
3162306a36Sopenharmony_ci# certain optimization flags it knows it has not implemented.
3262306a36Sopenharmony_ci# Make it behave more like gcc by erroring when these flags are encountered
3362306a36Sopenharmony_ci# so they can be implemented or wrapped in cc-option.
3462306a36Sopenharmony_ciCLANG_FLAGS	+= -Werror=unknown-warning-option
3562306a36Sopenharmony_ciCLANG_FLAGS	+= -Werror=ignored-optimization-argument
3662306a36Sopenharmony_ciCLANG_FLAGS	+= -Werror=option-ignored
3762306a36Sopenharmony_ciCLANG_FLAGS	+= -Werror=unused-command-line-argument
3862306a36Sopenharmony_ciKBUILD_CPPFLAGS	+= $(CLANG_FLAGS)
3962306a36Sopenharmony_ciexport CLANG_FLAGS
40