Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1844248pxy; Mon, 2 Aug 2021 11:41:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT+3Ich9xAYLswtZEFkX3CaaFoufWL5TUq6r7m3SMm5tBr2eoqyuR/2tEuEBeAr75sNrhb X-Received: by 2002:a05:6402:30bb:: with SMTP id df27mr16363938edb.186.1627929665426; Mon, 02 Aug 2021 11:41:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627929665; cv=none; d=google.com; s=arc-20160816; b=Dp995qIR8bZg/RwDA/U66TEfpR9w4anFSdfeAd9VSiGxu4bVnVH6N4y/zfmofr2Gb3 jjtCP3s4vPgenNE+mWEfk4FdRT9LycxBuG8ys/e8pbfHplnwAU0ubrwOHSE09beyrGZZ Cmj79ucYgsn27/ekIYe86kpQKDMMep/eLka1+FPA5LNg4c1O+ojFWxe8HeGTE6z1NP3i 25sUy8xHaS3XNiToVUKSWaS5nGESqJS9jHL1NSjFD39N/5QWU8kgz6QYhVm8Wz9ZxAk7 Qt5CBrd2cB80ZyzLepnHR0J0yM7wROjaxjvwD5FmfXqx3NoLmnLk5yAXQ7MNzFIA0W0f qUAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=gB4C2V/JRguj4rIBL7q84P8CEYcrLKzVf1rrlRWL8ws=; b=VDPn8Gom8ynmqCU793gCp4FUOOZWJgKqBkqn0ZWPPf/hi0Ovx6/CfNP5i7FCpZoZ1l 8cz6c87KrsFMHOqEEmcz17FXMtgSDrbBQmRJBRG0/BxTGQlB4wwmiNj4r0rvTiEaDPWS 0JdswzV5MBM/IwNzlf4L2RSg7PEg1Sv0Q1mZcSOro2PMK0X875cg0a1BEUSCHwb1vKsp G+Q9zBeO2Yug3yibw+slPIwTEWGjstYTqOrrXLH/VvxeUSH4CL+nvULpo3n2ojSIoXCc I8TSU2rA3DAzdPTrALne3bIFaPn4IArB68fwIfxf8n4r7QfQ/18tLFzR/4NaV5Yqxpth fSgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ibOF2huE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 18si11261168ejj.568.2021.08.02.11.40.42; Mon, 02 Aug 2021 11:41:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ibOF2huE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229903AbhHBSja (ORCPT + 99 others); Mon, 2 Aug 2021 14:39:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbhHBSj3 (ORCPT ); Mon, 2 Aug 2021 14:39:29 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DAA6C061760 for ; Mon, 2 Aug 2021 11:39:20 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id f22-20020a25b0960000b029055ed6ffbea6so19817216ybj.14 for ; Mon, 02 Aug 2021 11:39:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=gB4C2V/JRguj4rIBL7q84P8CEYcrLKzVf1rrlRWL8ws=; b=ibOF2huEqj8zm7B5cvTjuBhfuojGGoi5tyhfAmlRya+6n1AKH2xsdr32hT93l0oM2F oJ/xeRaqKS0JtzQ3Zrl0fw6lJhRf1CneqRAdyrm1cwO0jMNuPMGeJh5WnZj/1uN0rnih 1157OL1ZTTXVJ7HXH+xo6hQDGsXwt6VqCYIEfRruduII6ZqWSNjdSwND2rcaq0j+10Pc S2JR8/KG06oHR/3oivBq2sYIba7r1V3syN7AlmYKivGvn1n9aoVEciM281hJD3qRw/KZ 6dAGOpKr2rXfm39y2MvRvnug12KNDYvGTQJwvtMFYHkraE8bhfAkYHf8tYpxOi5VBlgg d87w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=gB4C2V/JRguj4rIBL7q84P8CEYcrLKzVf1rrlRWL8ws=; b=gOsssXGstQtYCYwCYOO+S7HNH2kzuxEdLw2uu+eilq2/d4QtycV7ppM1l7TTglL3uo spR42ptCJnYr77unrkku9um+67JHmqjRhOwVZseZgphzMF/va6swf2ZymNf/QCWUUv7p i57NFpqDuY1NTVQJXivJhhEIunae4d/ZUEm6sT9ZFEcNCNu7HNKWi2FhyywsUT8x1tkW ZHVtuSivIQAKe1gQi4ZyvoAji75tO5v/QkweJZHe0nnwVJvawkkfSDF/P06dQKsYvp9O PvgU1aOSqGIj/2FD19cQkia9ntOzqMyFr4Aj4B6Z389zD47h7FP4nsYYT+QPa1Ayvska 58Bg== X-Gm-Message-State: AOAM5337UII0sPrqjQKN0H6eostQQSQjIBTg+C7RI4PS2jH0oXK3D7P/ FwUssUi8oa463gLTfQqhWQtFejBXUVKiuoS1F88= X-Received: from ndesaulniers1.mtv.corp.google.com ([2620:15c:211:202:3db0:42c:8665:a4ae]) (user=ndesaulniers job=sendgmr) by 2002:a25:be09:: with SMTP id h9mr24786099ybk.239.1627929559410; Mon, 02 Aug 2021 11:39:19 -0700 (PDT) Date: Mon, 2 Aug 2021 11:39:08 -0700 In-Reply-To: <20210802183910.1802120-1-ndesaulniers@google.com> Message-Id: <20210802183910.1802120-2-ndesaulniers@google.com> Mime-Version: 1.0 References: <20210802183910.1802120-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog Subject: [PATCH v6 1/3] Makefile: move initial clang flag handling into scripts/Makefile.clang From: Nick Desaulniers To: Masahiro Yamada Cc: Miguel Ojeda , Fangrui Song , Michal Marek , Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com, Geert Uytterhoeven , Christoph Hellwig , Linus Torvalds , Nick Desaulniers , Nathan Chancellor Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With some of the changes we'd like to make to CROSS_COMPILE, the initial block of clang flag handling which controls things like the target triple, whether or not to use the integrated assembler and how to find GAS, and erroring on unknown warnings is becoming unwieldy. Move it into its own file under scripts/. Reviewed-by: Nathan Chancellor Signed-off-by: Nick Desaulniers --- MAINTAINERS | 1 + Makefile | 15 +-------------- scripts/Makefile.clang | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 scripts/Makefile.clang diff --git a/MAINTAINERS b/MAINTAINERS index 19135a9d778e..3af8d39f43ef 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4501,6 +4501,7 @@ B: https://github.com/ClangBuiltLinux/linux/issues C: irc://chat.freenode.net/clangbuiltlinux F: Documentation/kbuild/llvm.rst F: include/linux/compiler-clang.h +F: scripts/Makefile.clang F: scripts/clang-tools/ K: \b(?i:clang|llvm)\b diff --git a/Makefile b/Makefile index 6b555f64df06..444558e62cbc 100644 --- a/Makefile +++ b/Makefile @@ -586,20 +586,7 @@ endif CC_VERSION_TEXT = $(subst $(pound),,$(shell $(CC) --version 2>/dev/null | head -n 1)) ifneq ($(findstring clang,$(CC_VERSION_TEXT)),) -ifneq ($(CROSS_COMPILE),) -CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) -endif -ifeq ($(LLVM_IAS),1) -CLANG_FLAGS += -integrated-as -else -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) -KBUILD_AFLAGS += $(CLANG_FLAGS) -export CLANG_FLAGS +include $(srctree)/scripts/Makefile.clang endif # Include this also for config targets because some architectures need diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang new file mode 100644 index 000000000000..297932e973d4 --- /dev/null +++ b/scripts/Makefile.clang @@ -0,0 +1,14 @@ +ifneq ($(CROSS_COMPILE),) +CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) +endif +ifeq ($(LLVM_IAS),1) +CLANG_FLAGS += -integrated-as +else +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) +KBUILD_AFLAGS += $(CLANG_FLAGS) +export CLANG_FLAGS -- 2.32.0.554.ge1b32706d8-goog