Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3132062ybi; Thu, 18 Jul 2019 21:39:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIwe/7SvoywGWv5cmAkYE74HLvBHtJlaKKncm7mOotHRBs87hMhQdZlIur9tCU2mAFxQAi X-Received: by 2002:a63:d301:: with SMTP id b1mr44427340pgg.379.1563511162144; Thu, 18 Jul 2019 21:39:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563511162; cv=none; d=google.com; s=arc-20160816; b=i7Yei0TqmYxywDvLEP8BBimndR5erBpCx8kZXeJrfQUTQys3+RXDXOzi2P8PF85D/w OoKcJerf/rXy3UHqjFSWP//VnvR0ECUMDpF8gxgihOwlwN6tvsrfqEkl09yt5pF/ctjK Q+2rDon+eULHzc9UL/SCIEldmY9p23d4zAGNL67jRGL1lYWw5U+kbpzfI30zZ+DSjUxp SFMZsrXzAxqFopn5gw59+Dr50tpERYPBN/EBKqzfArlwuD8hf7fo4f1at0+PnmDNCdHV QYUg9KJyLPD90vZAbROOm/A7GjYPExBKo8GR80G4NXeiYwXQ4jRxs4X9zPKHQzydy6LN 3foA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qLawFAgP5gj8KvEiJ1azy91FlZxok7StJscPn0zZOxU=; b=Ur2cMqNgM+U/a/I3+0Mj5UYUqLTSNOEtaxIEN902DR6hLbtf62TMwHCRpFuvqC43ed WcyRXtwRUdAx/TZjes4YNOwg37g22CzZrZVy8CtAwGX0dSleWeBAULHni7f+utMDFIUO KiSMCnQ+YxYYRh9OrS0Wt5sA1DK3u5QvXiEHL20BhIqthuwd8h7jw32s/NfpkYi9lxBy n9N4Lkp3PloDRqoB7rOWoeDExgkfXMCnF4YjGyxpUzE2vnFU6PMfGcdyYhc2xIEHMXMT WtGEWDHuEizCpuIk8QOMAnntTqOp46QrVxaGkZVRJ3tonbdl/FXxcfjN2RHILp5l55dx F+HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lfzGVIiF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i41si2356734pje.45.2019.07.18.21.39.07; Thu, 18 Jul 2019 21:39:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lfzGVIiF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727661AbfGSD7q (ORCPT + 99 others); Thu, 18 Jul 2019 23:59:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:59362 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728825AbfGSD7k (ORCPT ); Thu, 18 Jul 2019 23:59:40 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 13181218B8; Fri, 19 Jul 2019 03:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508780; bh=vGc6FxhYPYV+Cpup7jSMVNC69MvH/z5xwnXfVdaz2QM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lfzGVIiFdABokw3tatksEm6fBcIUwRNBs/o8pCeNvLIrINsJxXGB7vkduFkWq2ZBq y/h7sJmdHPgqzjRMjewT3eEdG2DVKKJp7hoV30Q9inPWKUQ9reVWgeuwKAh9kGvTls 5GQloD75n/+Zuif5+f7AsFQTN+TZBskk7oYV33H8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nathan Chancellor , Peter Smith , Nick Desaulniers , Masahiro Yamada , Sasha Levin , linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH AUTOSEL 5.2 086/171] kbuild: Add -Werror=unknown-warning-option to CLANG_FLAGS Date: Thu, 18 Jul 2019 23:55:17 -0400 Message-Id: <20190719035643.14300-86-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nathan Chancellor [ Upstream commit 589834b3a0097a4908f4112eac0ca2feb486fa32 ] In commit ebcc5928c5d9 ("arm64: Silence gcc warnings about arch ABI drift"), the arm64 Makefile added -Wno-psabi to KBUILD_CFLAGS, which is a GCC only option so clang rightfully complains: warning: unknown warning option '-Wno-psabi' [-Wunknown-warning-option] https://clang.llvm.org/docs/DiagnosticsReference.html#wunknown-warning-option However, by default, this is merely a warning so the build happily goes on with a slew of these warnings in the process. Commit c3f0d0bc5b01 ("kbuild, LLVMLinux: Add -Werror to cc-option to support clang") worked around this behavior in cc-option by adding -Werror so that unknown flags cause an error. However, this all happens silently and when an unknown flag is added to the build unconditionally like -Wno-psabi, cc-option will always fail because there is always an unknown flag in the list of flags. This manifested as link time failures in the arm64 libstub because -fno-stack-protector didn't get added to KBUILD_CFLAGS. To avoid these weird cryptic failures in the future, make clang behave like gcc and immediately error when it encounters an unknown flag by adding -Werror=unknown-warning-option to CLANG_FLAGS. This can be added unconditionally for clang because it is supported by at least 3.0.0, according to godbolt [1] and 4.0.0, according to its documentation [2], which is far earlier than we typically support. [1]: https://godbolt.org/z/7F7rm3 [2]: https://releases.llvm.org/4.0.0/tools/clang/docs/DiagnosticsReference.html#wunknown-warning-option Link: https://github.com/ClangBuiltLinux/linux/issues/511 Link: https://github.com/ClangBuiltLinux/linux/issues/517 Suggested-by: Peter Smith Signed-off-by: Nathan Chancellor Tested-by: Nick Desaulniers Signed-off-by: Masahiro Yamada Signed-off-by: Sasha Levin --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index d8f5dbfd6b76..f02079b98e7e 100644 --- a/Makefile +++ b/Makefile @@ -528,6 +528,7 @@ ifneq ($(GCC_TOOLCHAIN),) CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) endif CLANG_FLAGS += -no-integrated-as +CLANG_FLAGS += -Werror=unknown-warning-option KBUILD_CFLAGS += $(CLANG_FLAGS) KBUILD_AFLAGS += $(CLANG_FLAGS) export CLANG_FLAGS -- 2.20.1