Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5543305rdb; Sun, 17 Sep 2023 01:06:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELbcwDCEhrdTVpwDmO26ovA/8Oq7m9u7ZY2lRBpWWERA5ojf8seP3oBy+ZkVXMQ/k6c/Dx X-Received: by 2002:a17:903:22cc:b0:1c4:13f:9dd3 with SMTP id y12-20020a17090322cc00b001c4013f9dd3mr8137821plg.62.1694938017521; Sun, 17 Sep 2023 01:06:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694938017; cv=none; d=google.com; s=arc-20160816; b=YdxhA6WIw5xUSWILB1iHde9hMK84MVepvq1i0MSvZht3lYKgOUtnhY1kViH0m4U15l MkW1+TJS155+v4YVR2harY6PmwcjwwqA49wUj+AOWGEhM45kfVKQzPUab6oIAaLVYTcI 4uxozFxDm5aOnyXukNYK4f169nN4JYSlmgSHyBLAQ0HTqfXGVob3QpbL3JJO6oM7Qu4F JBBWjgB5BrIYNxTYWsNkVFJcG0ooSGQctAUpp0ol6VDD0VVVakaMMrU2SBTa/yvq9sFO gy1avbZrq8BwNRni/q0d9bXceI8hN+3WYIeLItDNdXAH0Zo1aebUKHByfiTyhthYYqu5 i/Ug== 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 :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :from; bh=lqZdo4cSoaQIllOmN8FxoVmWJKHuKTh22y8m1E3kGxM=; fh=LaQLxh5dBYo+i1rsDQBw9Ajq4JdMT62pREfNEPFc7bM=; b=AXUUdn26+BiecyvY2BgSp64yFWhEgMLed2BLtY2QHQVdzlg3sRyCVE0NN8XgHaJzew ChbON9XLehP7+YJt697j8PUv/vcH4KtCbOPQaiBysqZz57nSLDT4neZkOec5w5O5mB/Y u1Yto25bOB+QVS2Lx0YuMpQhTL8Y9TQJAez71gfG1zxe5UzdX8NIX5Su1TXhF7NSL22Q uVSYpJlLu+QhIINi6y7aZf50P+2UG49UEbWhcmJ5vTxupGke0ATgyrxdQtb8bs/SAF+F wqCGeCxxqM83TdAzd/a1CnaAgDW4G8+4xSQ10Z2IBAeJLHZljQFzazg0LzdT1Xwx6Mjr UD+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kloenk.dev header.s=mail header.b=AnetxXH5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kloenk.dev Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id jy6-20020a17090342c600b001bf0cc53d2csi5930379plb.261.2023.09.17.01.06.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 01:06:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kloenk.dev header.s=mail header.b=AnetxXH5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kloenk.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 9B32883F69BA; Sat, 16 Sep 2023 11:07:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234496AbjIPSHX (ORCPT + 99 others); Sat, 16 Sep 2023 14:07:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233268AbjIPSHG (ORCPT ); Sat, 16 Sep 2023 14:07:06 -0400 X-Greylist: delayed 4433 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 16 Sep 2023 11:07:01 PDT Received: from gimli.kloenk.dev (gimli.kloenk.dev [IPv6:2a01:4f8:c012:b874::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69D75191; Sat, 16 Sep 2023 11:07:01 -0700 (PDT) From: Finn Behrens DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kloenk.dev; s=mail; t=1694887618; bh=lqZdo4cSoaQIllOmN8FxoVmWJKHuKTh22y8m1E3kGxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AnetxXH5p8tp6yPv2FyMgzNrIoXq3PZEtHGyXq6MfoFBLqWrKLWvMJwDE/W1B6jU2 rH291cZ2rAsRXQ9PZ4Mx2jLzG9Z+eRLqKQA7lSRQPdfpo8LzIOie8G3J/hcq0emOzR hZcQoAZNGvLI4J9vf8Wqarn2y2wiXBl7XPA2hZCQ= To: =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= Cc: Matthew Maurer , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Masahiro Yamada , Boqun Feng , Gary Guo , Benno Lossin , Andreas Hindborg , Alice Ryhl , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: Re: [PATCH] rust: Respect HOSTCC when linking for host Date: Sat, 16 Sep 2023 20:06:47 +0200 Message-ID: <0561303E-2089-43FC-AA31-836C7BB844B7@kloenk.dev> In-Reply-To: References: <20230915172900.3784163-1-mmaurer@google.com> <9966E047-44E7-4665-9628-169F3EBE2F06@kloenk.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Sat, 16 Sep 2023 11:07:53 -0700 (PDT) On 16 Sep 2023, at 19:53, Bj=C3=B6rn Roy Baron wrote: > On Saturday, September 16th, 2023 at 18:52, Finn Behrens wrote: > >> >> On 15 Sep 2023, at 19:28, Matthew Maurer wrote: >> >>> Currently, rustc defaults to invoking `cc`, even if `HOSTCC` is defin= ed, >>> resulting in build failures in hermetic environments where `cc` does = not >>> exist. This includes both hostprogs and proc-macros. >>> >>> Since we are setting the linker to `HOSTCC`, we set the linker flavor= to >>> `gcc` explicitly. >> But as `HOSTCC` could also be clang, the linker flavor would then be w= rong, would that create a problem? > > Rustc uses the gcc linker flavor for clang too. There has been a propos= al to split it up, but I'm not sure of the status of that. In any case cl= ang's cli is similar enough to gcc that it works fine to use the gcc link= er flavor. > In that case this looks very reasonable. Second thing I noticed is that `HOSTCC` could be the wrong variable, and = `HOSTLD` would make more sense as we look for the linker and not the gene= ral C compiler. >>> >>> Signed-off-by: Matthew Maurer >>> --- >>> rust/Makefile | 1 + >>> scripts/Makefile.host | 1 + >>> 2 files changed, 2 insertions(+) >>> >>> diff --git a/rust/Makefile b/rust/Makefile >>> index 87958e864be0..2a2352638f11 100644 >>> --- a/rust/Makefile >>> +++ b/rust/Makefile >>> @@ -383,6 +383,7 @@ $(obj)/exports_kernel_generated.h: $(obj)/kernel.= o FORCE >>> quiet_cmd_rustc_procmacro =3D $(RUSTC_OR_CLIPPY_QUIET) P $@ >>> cmd_rustc_procmacro =3D \ >>> $(RUSTC_OR_CLIPPY) $(rust_common_flags) \ >>> + -C linker-flavor=3Dgcc -C linker=3D$(HOSTCC) \ >>> --emit=3Ddep-info=3D$(depfile) --emit=3Dlink=3D$@ --extern proc_ma= cro \ >>> --crate-type proc-macro \ >>> --crate-name $(patsubst lib%.so,%,$(notdir $@)) $< >>> diff --git a/scripts/Makefile.host b/scripts/Makefile.host >>> index 8f7f842b54f9..0aa95a3af1c4 100644 >>> --- a/scripts/Makefile.host >>> +++ b/scripts/Makefile.host >>> @@ -91,6 +91,7 @@ hostcxx_flags =3D -Wp,-MMD,$(depfile) \ >>> # current working directory, which may be not accessible in the out-= of-tree >>> # modules case. >>> hostrust_flags =3D --out-dir $(dir $@) --emit=3Ddep-info=3D$(depfile= ) \ >>> + -C linker-flavor=3Dgcc -C linker=3D$(HOSTCC) \ >>> $(KBUILD_HOSTRUSTFLAGS) $(HOST_EXTRARUSTFLAGS) \ >>> $(HOSTRUSTFLAGS_$(target-stem)) >>> >>> -- >>> 2.42.0.459.ge4e396fd5e-goog