Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp6329rdb; Thu, 5 Oct 2023 14:36:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHNsXbLst6THyCNHbNHf+jzz5J/RZVXJ79jcTPOIzqOK8mzePIQknR/N7ITLLVCxNxJxqf X-Received: by 2002:a17:90b:1b45:b0:274:4fb:3610 with SMTP id nv5-20020a17090b1b4500b0027404fb3610mr6354667pjb.47.1696541809263; Thu, 05 Oct 2023 14:36:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696541809; cv=none; d=google.com; s=arc-20160816; b=IDxadhA1txNlJNL1MGo8ruUBjHSNjxx2PpmLivPHRUSdlHbpRxcMhk/VOmMsWhD7lc HP86dyCqlr6zpexKbWY5RojQcJ/B84NkSpktN1p27yYpVVRpNodoA8lyWIN87Ll40mRx to2EqMVMUAdHcmGNfJ1XVr/SEIRJXk10H07boErii6KB0TbPde6Ug/4Xqhuh9uH5mpAj fHTjpG1L27Ph8xKAcU6k8jJLTEQ7Bu+eFok0clutXkHaRs2Jq+Xh+O9S0Hjw4cjZmkAh pu1heEQfboI33r6z1JXj8l6uhtebPC6JDfX05vdF+Gc/aZ+wpbrPWp8iOE4CEdwIH97B J8vw== 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=VWddOZrmmasiWu5O0KWGa9lmgFQoWcrVlIGB6YyWgVs=; fh=KMTISqHzRoiX/E42FTgAaaJRx74xkudpLLH28syd5P8=; b=sTIeOi2aQUFJZ+r4/Rdh5Py2Zdoqmaj/cq9xmTBmxAj6p1AhTK7GDcqYYDyFaDDlHS Ugv1LtX4OT228RpRSf/GIuiJxsNGcMCHAIqP8PFllyCqDKIIiHL+WuOJCSYnOP8fz+2G HQCf1Msy0+aoye9+ZjzPMK/zRlFAD3GP868MrzTjo30P4BsCurkjf5xJvXooNz9m2Nd9 RD710dwO8pJ05k+D9J7NB5nk9mZvl11UMwkd7wE5P9gmaF5mWbeGPhNFBrpaE510HBx4 MPwwc0lbWRT9/idg/fq7oa5a2zjf9LZvxTvENVQM/Jnqfw3qpgQNrCcG+g3IBZcfzuKY YaRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4bJSH3eK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id v21-20020a17090a899500b002772b8993ebsi2362691pjn.159.2023.10.05.14.36.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 14:36:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4bJSH3eK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id BEAF88080EF2; Thu, 5 Oct 2023 14:36:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231400AbjJEVgh (ORCPT + 99 others); Thu, 5 Oct 2023 17:36:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbjJEVgf (ORCPT ); Thu, 5 Oct 2023 17:36:35 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F36095 for ; Thu, 5 Oct 2023 14:36:32 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-536ef8a7dcdso4675a12.0 for ; Thu, 05 Oct 2023 14:36:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696541791; x=1697146591; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=VWddOZrmmasiWu5O0KWGa9lmgFQoWcrVlIGB6YyWgVs=; b=4bJSH3eKN6MBY0Fpg0QIuGImOmRogXegcl4rJtKoq4BHU191C99zCRMoMz55rlPTTl IdHXlJVarO7ktFPAKrq3G7RTTRSApiidYU7KAPTnxItPPINLAXJyOUMlL8+Pz5mc2y3t bVWTXXqLg/nk+Cv1NEIIyPzU+lyR3WWwNWaWLXcBy75kL27BFIKk9zEopXfA67pc1YbM YjCWjQIMKGFuW8qy+s43YvrtMUtbuCRKAH2LItQ06bKkezqTHj5kV+oWlzTXHgXRXZ+i 69hnaLjLeqjU2lrsmnGh8Ssdbgw4E9umxVYCnk78nEFjBRnNoAbQRJa+83Ke/zVUaTxb TdJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696541791; x=1697146591; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VWddOZrmmasiWu5O0KWGa9lmgFQoWcrVlIGB6YyWgVs=; b=g3KTNQwkqnsL+ax18S3OcICO8f7V+AoiXjVQYyF8R1SR62lYOmUWUuEkoNQopv3+sf 1quXUlffB7rTLyP0nBtYxW7T5fPsNqtg8Nzk4rjaxu90QAXgfTkAePBQi8lpiO6H2ov7 PISJtoeA4ikegxEF84EEL3UIjYiE9IAMdh+7a6WAeeB2mAypxhK+cYF/hqyXaMMScShH L1cd1nMyCFGcMFxSYDziAhXybKMXt6C/3+EiELDPh81BcRM4D0D6ROuv7ObKHxbcBEPk NdOD1V9Y56ukmmuvzfjo33TAOFF+l2THH604mPeS0tKo0HvYstZ+mED5f7AQUBJOSnJ2 22lg== X-Gm-Message-State: AOJu0Yzfj2Xo8w3orUO/WMSR78HvmlwqJ0C2saqAoNEiJCfYlCNQYxVL JWZ3P9Fd0lUDTNychD+653q+rtDRAqXebAtdgvBQJQ== X-Received: by 2002:a50:9f67:0:b0:522:4741:d992 with SMTP id b94-20020a509f67000000b005224741d992mr121564edf.4.1696541790666; Thu, 05 Oct 2023 14:36:30 -0700 (PDT) MIME-Version: 1.0 References: <20230928194801.2278999-1-mmaurer@google.com> In-Reply-To: From: Matthew Maurer Date: Thu, 5 Oct 2023 14:36:19 -0700 Message-ID: Subject: Re: [PATCH v3] rust: Respect HOSTCC when linking for host To: Masahiro Yamada 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=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Thu, 05 Oct 2023 14:36:47 -0700 (PDT) On Fri, Sep 29, 2023 at 10:59=E2=80=AFPM Masahiro Yamada wrote: > > 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 no= t > > exist. This includes both hostprogs and proc-macros. > > > > Since we are setting the linker to `HOSTCC`, we set the linker flavor t= o > > `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, includin= g > > 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 = FORCE > > 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 ? > > I didn't use it in rust/Makefile because that makefile doesn't directly import scripts/Kbuild.include, and I was under the mistaken impression that scripts/ was supposed to be its own namespace, even if Make wasn't enforcing it. Inspecting other functions in scripts/Kbuild.include though, it's clear they're called elsewhere, so I'll upload another version of the patch using escsq here as well. > > > > > > --emit=3Ddep-info=3D$(depfile) --emit=3Dlink=3D$@ --ext= ern 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= -tree > > # 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