Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp169796rdb; Fri, 29 Sep 2023 23:03:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFv6BNqt/FwPNrWkbbkGOXZ4Hyxnyw8xmg34w3+NqS+ZyJ0kt1mnzmdWN99D6dYj7Dv6GuG X-Received: by 2002:a05:6a20:9751:b0:14c:6cd9:bf9d with SMTP id hs17-20020a056a20975100b0014c6cd9bf9dmr5879557pzc.35.1696053803565; Fri, 29 Sep 2023 23:03:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696053803; cv=none; d=google.com; s=arc-20160816; b=HJjnTLgj5NDNgIi6O5/b+qFEppKf2hIb74yeD8XITLb0UAFwFEnQaMJIqDiDwHQr63 9oh4yEluY/7fCICt4O48O5gNxip4gyx1lIoOafAlpOb2HrPUrTxsI3LgVDAqJdYqf3TW Am3v93CbqxwUO6Vi0JlAjWj7uwRgJ2mPnqZPnbAivFxFNnEm27hb/CT70l/AzvhF5bHG aOqINR4cwIRpbtQS/hfd4j6FKucXFVUu7ckcXaDFsJcUHyKewHiCUj7triZ2FL2bSamo wpcg/xh0882/YZEvdl8aGM7gboxTYyf3ofmP7r73qCRfNs1FFQf+4KTmqb7imQl1CZmf FiBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Gaku2rau36dx9LqfVdOjDYfFhr6+6BcoEPnbiNbVKAA=; fh=l5MgvwZhWjhp73j8xFiwdtVguZiJQdDXX1kXrKNtHRc=; b=0fJOvTarr6nQmo6XHGNKgma60S2ENcnh3qJyJ5GhYo2bkgDFVGx5TcUNV8lqzOC0vX TwRFsDL/Nv5plNWEBYY/lrU/mnYBUCH7ox4MlZNSQoMBSu3II/yj0DcZi7F0SmlEHvVA vP5pkEaJkq6BWMFTjxkBfHpFxzxWFbg9Tz+Oaulm11ZKdppfpbimfgTVdc3zr4eVmmgo GVTMwVXLpxyVW6h5Gv/kYQwwbz/xFIv4+n9NbXCvGe9lwxvBM/zwj9ymZFubLkoPQfEt cN5TJgkjDDlVDhFIb1HZUG8k8It8rUsWzvQP/bSIa+4MZlRUTqfHyjJ1urcA0DNZmt7Y Z9Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jr7i7wgk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id e21-20020a637455000000b00563f72935e3si10875411pgn.608.2023.09.29.23.03.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 23:03:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jr7i7wgk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 9AF2B823D9D7; Fri, 29 Sep 2023 23:02:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234007AbjI3F7Z (ORCPT + 99 others); Sat, 30 Sep 2023 01:59:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229766AbjI3F7Y (ORCPT ); Sat, 30 Sep 2023 01:59:24 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2FB51AB; Fri, 29 Sep 2023 22:59:21 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36A14C43395; Sat, 30 Sep 2023 05:59:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696053561; bh=fEN/S6mVsSDNV0g4PBlvUaE2VUJdNNjgVZ+Xtar4unE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=jr7i7wgkNdL6Y8zEWyvi5nBrCFgRd7bSuk6cLgxK67kkorEKo48vijY4DenStKNc9 pwG5cS56mxBLCh8ucvI8a1Mzidbx+V4E2jQahFgerDpxwNk2vfOsYpKDpqsbnO4F5s Z3OkmpQepD5VNw99P29rkUOriPTvtdRrW7pbWN+r6VirTBO+Qc3bB9Kai6EWixggKW qf6CyA1Nzqy3OO831ByicN9VkrFBzv/su7MdxK4cYLZyVAS6HDX7qLKfujLpoKdoCn Sx8ellEqDgmvSxdf6blQmCx5l6XA7V13adGOZUMnOdTxunY3IECNF5FzQreRYG11Hw HabW0qll/rgNg== Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-1dce0c05171so6648989fac.3; Fri, 29 Sep 2023 22:59:21 -0700 (PDT) X-Gm-Message-State: AOJu0Yzd2TqML4IZCZRj6k5n2ENUh3AF/E1d35FRRqbSH/1/Qr1q7eNA 73CttS6kUF4debVsepqNWuXs16rklq56ClWSLNk= X-Received: by 2002:a05:6870:2216:b0:1c0:937:455d with SMTP id i22-20020a056870221600b001c00937455dmr6904202oaf.47.1696053560507; Fri, 29 Sep 2023 22:59:20 -0700 (PDT) MIME-Version: 1.0 References: <20230928194801.2278999-1-mmaurer@google.com> In-Reply-To: <20230928194801.2278999-1-mmaurer@google.com> From: Masahiro Yamada Date: Sat, 30 Sep 2023 14:58:43 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3] rust: Respect HOSTCC when linking for host To: Matthew Maurer Cc: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Nathan Chancellor , Nick Desaulniers , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Nicolas Schier , Tom Rix , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Fri, 29 Sep 2023 23:02:30 -0700 (PDT) On Fri, Sep 29, 2023 at 4:48=E2=80=AFAM Matthew Maurer = wrote: > > Currently, rustc defaults to invoking `cc`, even if `HOSTCC` is defined, > 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. The linker-flavor selects both which linker to search > for if the linker is unset, and which kind of linker flags to pass. > Without this flag, `rustc` would attempt to determine which flags to > pass based on the name of the binary passed as `HOSTCC`. `gcc` is the > name of the linker-flavor used by `rustc` for all C compilers, including > both `gcc` and `clang`. > > Signed-off-by: Matthew Maurer > --- > rust/Makefile | 2 ++ > scripts/Makefile.host | 2 ++ > 2 files changed, 4 insertions(+) > > diff --git a/rust/Makefile b/rust/Makefile > index 87958e864be0..da664d7aed51 100644 > --- a/rust/Makefile > +++ b/rust/Makefile > @@ -383,6 +383,8 @@ $(obj)/exports_kernel_generated.h: $(obj)/kernel.o FO= RCE > quiet_cmd_rustc_procmacro =3D $(RUSTC_OR_CLIPPY_QUIET) P $@ > cmd_rustc_procmacro =3D \ > $(RUSTC_OR_CLIPPY) $(rust_common_flags) \ > + -Clinker-flavor=3Dgcc -Clinker=3D$(HOSTCC) \ > + -Clink-args=3D'$(subst ','\'',$(KBUILD_HOSTLDFLAGS))' \ Why not consistently use the escsq macro here too ? > --emit=3Ddep-info=3D$(depfile) --emit=3Dlink=3D$@ --exter= n proc_macro \ > --crate-type proc-macro \ > --crate-name $(patsubst lib%.so,%,$(notdir $@)) $< > diff --git a/scripts/Makefile.host b/scripts/Makefile.host > index 8f7f842b54f9..08d83d9db31a 100644 > --- a/scripts/Makefile.host > +++ b/scripts/Makefile.host > @@ -91,6 +91,8 @@ hostcxx_flags =3D -Wp,-MMD,$(depfile) \ > # current working directory, which may be not accessible in the out-of-t= ree > # modules case. > hostrust_flags =3D --out-dir $(dir $@) --emit=3Ddep-info=3D$(depfile) \ > + -Clinker-flavor=3Dgcc -Clinker=3D$(HOSTCC) \ > + -Clink-args=3D'$(call escsq,$(KBUILD_HOSTLDFLAGS))' \ > $(KBUILD_HOSTRUSTFLAGS) $(HOST_EXTRARUSTFLAGS) \ > $(HOSTRUSTFLAGS_$(target-stem)) > > -- > 2.42.0.582.g8ccd20d70d-goog > -- Best Regards Masahiro Yamada