From patchwork Tue Jul 25 09:54:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huacai Chen X-Patchwork-Id: 125494 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2378528vqg; Tue, 25 Jul 2023 03:44:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlEQLUQRiLXLp50jWxTajoDNNtoiiHlQ1ABy0XhC3tunBJC6+DvR2gprAmrBqeIwaAW9oP15 X-Received: by 2002:a17:902:d2c8:b0:1b8:8702:1e7c with SMTP id n8-20020a170902d2c800b001b887021e7cmr2989801plc.33.1690281860819; Tue, 25 Jul 2023 03:44:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690281860; cv=none; d=google.com; s=arc-20160816; b=dmSqHxVNJzGhCRA1XQ1Fc2n8FkvMFp4SpCF+e/F0kROIDzGgU/xsy2YxEUhyklc6WR ofENfm9ZpX1s8Fo95fdLH+rLEJC+yqA8EP+2srN8/zckiSpiySRs42IgKX7zJqW7sOxN zVykRmlRwt9oDe7wUER3F+E7AQ3wn9PXU13q+T56qzZgh0AVWOAkITBVAsVbm2CVw2nV ZmyZMpWffB9m2auoUtS2ulFexh+4Hky67dRLntiODaCZAw6DeO26/Gn2sJYXoUBkApX0 V/yuACEDwDhzr4ASEXcfPB0D+LxslU8/OgG5YV5pegxNFEjBhDiaAJw+fdy/JbWqZuXt e0OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=EgcmWfdNErcJW2memOCwbjOocJf/hQOwgQcIADpg+BU=; fh=5xZmlGRRr2qi/otnqDRHuPmlDBMQPQVJKa2ufmsLGQ4=; b=yZlIdiICPN6cQQK/QknA8JDhTD+3+vqxPnkKShfL+bmeYPOF7himz5JJOfyJBRVIxz M9WAgPlhQfFFbJtn3/iR2HkV8TTE7rJCNaVsTsUBHqULOdTJ2eNd57K+dG3U5etxWhmO 7kcBf0H2SQ5OT3NwTYc6SWs0xL5fMM09p3yhLT6LVD9grhmHXyWMU6w2jaIpYcdu8jPm 5GNxwiaXxsAB+/PfINC/Y+56/xGXvK1NV4aqxZ6pObSUq61J8lEdvKwOhO441aTGFQ57 j0/2Zx+ofcCMNlMarNFsQMdJWhg6qa4DOsTrVbQ862xWWfnI00WcAsSeK0a/gM8PRlR5 d+bA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t7-20020a1709027fc700b001bbbb70c23asi1424385plb.232.2023.07.25.03.44.03; Tue, 25 Jul 2023 03:44:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233150AbjGYJzZ (ORCPT + 99 others); Tue, 25 Jul 2023 05:55:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230092AbjGYJzY (ORCPT ); Tue, 25 Jul 2023 05:55:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FC70E56 for ; Tue, 25 Jul 2023 02:55:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AA069615E6 for ; Tue, 25 Jul 2023 09:55:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CEA4AC433C7; Tue, 25 Jul 2023 09:55:19 +0000 (UTC) From: Huacai Chen To: Huacai Chen Cc: loongarch@lists.linux.dev, Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn, Huacai Chen Subject: [PATCH] LoongArch: Only fiddle with CHECKFLAGS if `need-compiler' Date: Tue, 25 Jul 2023 17:54:51 +0800 Message-Id: <20230725095451.992522-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772388992777762482 X-GMAIL-MSGID: 1772388992777762482 This is a port of commit 4fe4a6374c4db9ae2b ("MIPS: Only fiddle with CHECKFLAGS if `need-compiler'") to LoongArch. We have originally guarded fiddling with CHECKFLAGS in our arch Makefile by checking for the CONFIG_LOONGARCH variable, not set for targets such as `distclean', etc. that neither include `.config' nor use the compiler. Starting from commit 805b2e1d427aab4 ("kbuild: include Makefile.compiler only when compiler is needed") we have had a generic `need-compiler' variable explicitly telling us if the compiler will be used and thus its capabilities need to be checked and expressed in the form of compilation flags. If this variable is not set, then `make' functions such as `cc-option' are undefined, causing all kinds of weirdness to happen if we expect specific results to be returned. It doesn't cause problems on LoongArch now. But as a guard we replace the check for CONFIG_LOONGARCH with one for `need-compiler' instead, so as to prevent the compiler from being ever called for CHECKFLAGS when not needed. Signed-off-by: Huacai Chen --- arch/loongarch/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile index 7811d43ed24a..cb40d36fac20 100644 --- a/arch/loongarch/Makefile +++ b/arch/loongarch/Makefile @@ -116,7 +116,7 @@ KBUILD_CFLAGS += -isystem $(shell $(CC) -print-file-name=include) KBUILD_LDFLAGS += -m $(ld-emul) -ifdef CONFIG_LOONGARCH +ifdef need-compiler CHECKFLAGS += $(shell $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ grep -E -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \ sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g')