Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3360717pxb; Mon, 18 Oct 2021 13:36:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHc18MFNyRrP3Tff++5AaN9+IdKqPpJgWIKdN/9C8jv8Ac/KVjvwdF9v16v0lXemFqFPLx X-Received: by 2002:a17:907:7fa8:: with SMTP id qk40mr31690378ejc.445.1634589418090; Mon, 18 Oct 2021 13:36:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634589418; cv=none; d=google.com; s=arc-20160816; b=1LTuhkR12V6OYthDHJyA6cRvBYwUMqLTbCJCNzWMqg+NCBqNSuWYa42U4VszleL01I m8wZHQwsrL0MBwemThg2/qp04xedk7QytVL2iouQnpL5G3EIZi03CBGVEJcVpkiCz6/z 04ZVnv0OCfAssY2YQsRw7pf4bHeZ+FNyoq2QY5jM3L5OtKOAv/P5eZvYNFVMGCuVcniJ jKEu6k9iUXlx5Hu8BsgffSVaU6Cuw5E/ZogbrcjUOqDJEyPZo4dDyD/S8Lh4jnb6NK40 yyRAEtSFHtGyihiCD5pLVaPGU5RM4CY6iabtfn8VCLqMPgBT2Nw3Gi5wWQRA9PnnEQDs M3wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=GmZE9aF4Ee2V9RKx7L1BSLdmyNjcvmYBt17tD4vGRiQ=; b=BiNh+YnyT17aOiJbjhI+xA+qcS63ZJbqyS2kXkBRw3DwYxHD8zitNOolgYmmCpFonJ ArVbuS1rIqfCjSS4dIXPSHUfhTy96inGz7ljTJTuC4pSHAInEf5PIDzKGH6e88kfSHIR BvbQWYia/IJew2GWdVk9bwtT2WG7lJyz9gDh67wlg1yHqaEpHK9le3dvOnRZDYmHbcUg NRZB2QjCGihHsUPI+nUrYC1ckk5NPcspdbbWXug87/AypFVBr+e4bTp5W7cX431niRvU tEwA94GGGWCTHUwc9I3pJOHNjzM4zweq2s5ULvi6D6wRgmdA9O8CMUTIEAtdaRdsiLhN N6Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="fW/4xiFT"; 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 c22si19727982edn.592.2021.10.18.13.36.33; Mon, 18 Oct 2021 13:36:58 -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=20210112 header.b="fW/4xiFT"; 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 S231811AbhJRUg5 (ORCPT + 99 others); Mon, 18 Oct 2021 16:36:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229941AbhJRUg4 (ORCPT ); Mon, 18 Oct 2021 16:36:56 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7FE1C06161C for ; Mon, 18 Oct 2021 13:34:44 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id o26so1990770ljj.2 for ; Mon, 18 Oct 2021 13:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GmZE9aF4Ee2V9RKx7L1BSLdmyNjcvmYBt17tD4vGRiQ=; b=fW/4xiFTZMVJcLXLME4J2ssqGuKqgTsuct3PZ1LjKrR/EaUnJjUrsKBG0UZoip93Sw 8oH4wS9BAjsT/sBQDXuWEt1vD36eO3cqd5rEY3zOFrh0ICjEya9BXpqqR4jTLkXzV8s9 kiDDTlh9ab3rNYrHnpvZxxYPpPoS4Tgp3ejkzUqN7hkdOSJC2O2uEgG6zKcVfkuGWCqW DTpgKB82oYu2s6YMSN5OJnIXPY0lkIJyNGL9FYc2kdwHoOND8DBdcyuyGC8Mp5Nh2zwF R4F+pN2AONWm6RwzeHEFP9nJhPaGbZVhdmFsdsdphAyxihqC+BQoB5/c8485tCVb7Io4 ElCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GmZE9aF4Ee2V9RKx7L1BSLdmyNjcvmYBt17tD4vGRiQ=; b=3wQQcPeqeppqEcgSeSkHU9wBhBr4xTT0OkIWOtsC6xJEmkAZJbdRlJhbj+ey4F5Gkr TX+BK8k88b3vEbyjhQ9RuVq5ERzN87L7nEquklwlcNe8RhQkwaNsE0PVJFIq8MUu67X0 UnG7DPpbXE+OrVMuO+Y9qP6W91bEMICpe9j0xP2AulEgr+It7xHyyLPpR9g3NjNCJuK5 gEPBm3uuO8puSq3cLeqvEU59kr0pTnxTttnd84KZDTHL3VUHHkamJOv7wmGxBsDkKT9w Tj8yCoyXv8KMXC0Mu77JfrJTWB9UcaMsLDTPCjADZWAANWgXuaV9xwboM0Mn0FxfJfY3 AXIw== X-Gm-Message-State: AOAM530mLht5ft/oXY90JRlLOns1uxKaeWqkOIo3l+84zjaDOBaCVkIg RqEZZYDxaM+jAxQb88hgLTgTFL3/zv6WJSlzAWdu9g== X-Received: by 2002:a2e:750e:: with SMTP id q14mr2124757ljc.338.1634589282793; Mon, 18 Oct 2021 13:34:42 -0700 (PDT) MIME-Version: 1.0 References: <20211012234606.91717-1-ndesaulniers@google.com> <20211012234606.91717-3-ndesaulniers@google.com> In-Reply-To: From: Nick Desaulniers Date: Mon, 18 Oct 2021 13:34:31 -0700 Message-ID: Subject: Re: [PATCH 2/3] arm64: vdso32: lazily invoke COMPAT_CC To: Masahiro Yamada Cc: Catalin Marinas , Will Deacon , llvm@lists.linux.dev, Linux Kernel Mailing List , linux-arm-kernel , Vincenzo Frascino , Lucas Henneman Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 16, 2021 at 7:20 AM Masahiro Yamada wrote: > > On Fri, Oct 15, 2021 at 5:59 AM Nick Desaulniers > wrote: > > > > On Tue, Oct 12, 2021 at 8:03 PM Masahiro Yamada wrote: > > > > > > On Wed, Oct 13, 2021 at 8:46 AM Nick Desaulniers > > > wrote: > > > > > > > > When running the following command without arm-linux-gnueabi-gcc in > > > > one's $PATH, the following warning is observed: > > > > > > > > $ ARCH=arm64 CROSS_COMPILE_COMPAT=arm-linux-gnueabi- make -j72 LLVM=1 mrproper > > > > make[1]: arm-linux-gnueabi-gcc: No such file or directory > > > > > > > > This is because KCONFIG is not run for mrproper, so CONFIG_CC_IS_CLANG > > > > is not set, and we end up eagerly evaluating various variables that try > > > > to invoke CC_COMPAT. > > > > > > > > This is a similar problem to what was observed in > > > > commit 3ec8a5b33dea ("kbuild: do not export LDFLAGS_vmlinux") > > > > > > > > Cc: Masahiro Yamada > > > > Reported-by: Lucas Henneman > > > > Signed-off-by: Nick Desaulniers > > > > > > > > > There are two ways to fix it: > > > > > > [1]: sink the error message to /dev/null > > > (as in commit dc960bfeedb01cf832c5632ed1f3daed4416b142) > > > [2]: use a recursively-expanded variable as you did. > > > > > > > > > "Simple variable (:=) vs recursive variable (=)" is a trade-off. > > > > > > Please be careful about the cost when you try the [2] approach. > > > > > > > > > > > > Simple variables are immediately expanded while parsing Makefile. > > > There are 7 call-sites for cc32-option, hence > > > the compiler is invoked 7 times for building vdso32, > > > 0 times for cleaning. > > > (Since 57fd251c789647552d32d2fc51bedd4f90d70f9f, > > > try-run is no-op for 'make clean'). > > > > > > > > > > > > > > > Recursive variables are expanded every time they are used. > > > > > > IIUC, if_changed expands the command line 3 times. > > > There are 2 objects (note.o and vgettimeofday.o) > > > There are 7 call-sites for cc32-option. > > > > > > So, the compiler is invoked 42 (3 * 2 * 7) times > > > for building vdso32. > > > > With this patch applied: > > $ ARCH=arm64 CROSS_COMPILE_COMPAT=arm-linux-gnueabi- make LLVM=1 -j72 > > clean defconfig > > $ ARCH=arm64 CROSS_COMPILE_COMPAT=arm-linux-gnueabi- make LLVM=1 -j72 > > arch/arm64/kernel/vdso32/ V=1 | tr -s ' ' | cut -d ' ' -f 2 | grep > > clang | wc -l > > 55 > > $ find arch/arm64/kernel/vdso32/ -name \*.o | xargs rm > > $ ARCH=arm64 CROSS_COMPILE_COMPAT=arm-linux-gnueabi- make LLVM=1 -j72 > > arch/arm64/kernel/vdso32/ V=1 | tr -s ' ' | cut -d ' ' -f 2 | grep > > clang | wc -l > > 2 > > > > Prior to this series: > > $ ARCH=arm64 CROSS_COMPILE_COMPAT=arm-linux-gnueabi- make LLVM=1 -j72 > > clean defconfig > > $ ARCH=arm64 CROSS_COMPILE_COMPAT=arm-linux-gnueabi- make LLVM=1 -j72 > > arch/arm64/kernel/vdso32/ V=1 | tr -s ' ' | cut -d ' ' -f 2 | grep > > clang | wc -l > > 55 > > $ find arch/arm64/kernel/vdso32/ -name \*.o | xargs rm > > $ ARCH=arm64 CROSS_COMPILE_COMPAT=arm-linux-gnueabi- make LLVM=1 -j72 > > arch/arm64/kernel/vdso32/ V=1 | tr -s ' ' | cut -d ' ' -f 2 | grep > > clang | wc -l > > 2 > > > > With patch 3 applied, we can drop CROSS_COMPILE_COMPAT, and we now get: > > $ ARCH=arm64 make LLVM=1 -j72 clean defconfig > > ARCH=arm64 make LLVM=1 -j72 arch/arm64/kernel/vdso32/ V=1 | tr -s ' ' > > | cut -d ' ' -f 2 | grep clang | wc -l > > 44 > > $ find arch/arm64/kernel/vdso32/ -name \*.o | xargs rm > > $ ARCH=arm64 make LLVM=1 -j72 arch/arm64/kernel/vdso32/ V=1 | tr -s ' > > ' | cut -d ' ' -f 2 | grep clang | wc -l > > 2 > > > > Please confirm; perhaps my pipeline missed some invocations? Or was > > there a different target you were referring to? > > > > > > > It is pointless to check the build commands. > > I am talking about how many times $(call cc32-option, ) is evaluated. Of course V=1 doesn't print the cc-option invocations! /s > > > How about adding the following debug code? > > (Everytime cc32-option is evaluated, a file "dummy-cc32-option-" > is created) > > > > diff --git a/arch/arm64/kernel/vdso32/Makefile > b/arch/arm64/kernel/vdso32/Makefile > index 89299a26638b..e40365f5bc38 100644 > --- a/arch/arm64/kernel/vdso32/Makefile > +++ b/arch/arm64/kernel/vdso32/Makefile > @@ -26,9 +26,9 @@ LD_COMPAT ?= $(CROSS_COMPILE_COMPAT)ld > endif > > cc32-option = $(call try-run,\ > - $(CC_COMPAT) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) > + $(CC_COMPAT) $(1) -c -x c /dev/null -o "$$TMP"; touch > dummy-cc32-option-$$$$,$(1),$(2)) > cc32-disable-warning = $(call try-run,\ > - $(CC_COMPAT) -W$(strip $(1)) -c -x c /dev/null -o > "$$TMP",-Wno-$(strip $(1))) > + $(CC_COMPAT) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP"; > touch dummy-cc32-option-$$$$,-Wno-$(strip $(1))) heh, I usually add `($info $$VAR is [${VAR}]); \` debugging statements to these. Touching files is another neat trick. > > # We cannot use the global flags to compile the vDSO files, the main reason > # being that the 32-bit compiler may be older than the main (64-bit) compiler > > > > > > Without this patch: > > masahiro@grover:~/ref/linux$ rm dummy-cc32-* > masahiro@grover:~/ref/linux$ make -s LLVM=1 ARCH=arm64 > CROSS_COMPILE_COMPAT=arm-linux-gnueabi- defconfig clean > arch/arm64/kernel/vdso32/ -j8 > masahiro@grover:~/ref/linux$ ls -1 dummy-cc32-* > dummy-cc32-disable-warning-765530 > dummy-cc32-option-765495 > dummy-cc32-option-765500 > dummy-cc32-option-765505 > dummy-cc32-option-765510 > dummy-cc32-option-765515 > dummy-cc32-option-765520 > dummy-cc32-option-765525 > > > > > With this patch: > > > > masahiro@grover:~/ref/linux$ rm dummy-cc32-* > masahiro@grover:~/ref/linux$ make -s LLVM=1 ARCH=arm64 > CROSS_COMPILE_COMPAT=arm-linux-gnueabi- defconfig clean > arch/arm64/kernel/vdso32/ -j8 > masahiro@grover:~/ref/linux$ ls -1 dummy-cc32-* > dummy-cc32-disable-warning-768908 > dummy-cc32-disable-warning-768949 > dummy-cc32-disable-warning-768990 > dummy-cc32-disable-warning-769035 > dummy-cc32-disable-warning-769076 > dummy-cc32-disable-warning-769117 > dummy-cc32-option-768871 > dummy-cc32-option-768878 > dummy-cc32-option-768883 > dummy-cc32-option-768888 > dummy-cc32-option-768893 > dummy-cc32-option-768898 > dummy-cc32-option-768903 > dummy-cc32-option-768914 > dummy-cc32-option-768919 > dummy-cc32-option-768924 > dummy-cc32-option-768929 > dummy-cc32-option-768934 > dummy-cc32-option-768939 > dummy-cc32-option-768944 > dummy-cc32-option-768955 > dummy-cc32-option-768960 > dummy-cc32-option-768965 > dummy-cc32-option-768970 > dummy-cc32-option-768975 > dummy-cc32-option-768980 > dummy-cc32-option-768985 > dummy-cc32-option-768998 > dummy-cc32-option-769005 > dummy-cc32-option-769010 > dummy-cc32-option-769015 > dummy-cc32-option-769020 > dummy-cc32-option-769025 > dummy-cc32-option-769030 > dummy-cc32-option-769041 > dummy-cc32-option-769046 > dummy-cc32-option-769051 > dummy-cc32-option-769056 > dummy-cc32-option-769061 > dummy-cc32-option-769066 > dummy-cc32-option-769071 > dummy-cc32-option-769082 > dummy-cc32-option-769087 > dummy-cc32-option-769092 > dummy-cc32-option-769097 > dummy-cc32-option-769102 > dummy-cc32-option-769107 > dummy-cc32-option-769112 > > > > > > > The diff of the number of expansions: > > cc32-option 7 -> 42 > cc32-disable-warning 1 -> 6 Indeed, thanks for confirming. An unfortunate dichotomy. Surely there's another way to avoid cc-option+cc-disable-warning calls for the `clean` target? I'll change to just redirecting errors to /dev/null with your Suggested-by tag, but this seems a bit of an unfortunate situation. -- Thanks, ~Nick Desaulniers