From nobody Wed Nov 27 16:44:32 2024 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6291413CA93 for ; Tue, 8 Oct 2024 17:32:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728408775; cv=none; b=HJbflbEb3+mtCG5ZDxVxVFO4PGNVUw9S3TF61EIFRZXTJLs7s9ni2HOQvOxdVUnoRrZQ5SDGCWjnfS4Mnb9V3UMrOBIfQG/jp3EJOI1SOEecqQ2W9VbHGY6NdPYQerbhvNSPOCqZHH28fDpL0Lkx6P8/C6rgppUerStJsFWH14A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728408775; c=relaxed/simple; bh=z7EQ2ig9cjE6D99U3+xtPYCE3cc+3J+C5Qs8yl9IAXc=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=C3ih0YrWAKEeSDlMqz4ngLumDSm4QyyloxNGtmhIoMdeD1FCqeY3Etjc2XX42yXx3hMcFeZq4qhFDO2v51CrN/Zeqm3XqydinOF3HRPin6NJOmmgNJVB4c1GszH1mrT8kyYbtWLSX1Ds4OcpL8Fyrsdo9BavkmoJgJAFxxaFACo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=mmSRVWTe; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="mmSRVWTe" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e258c0e02a9so8073060276.3 for ; Tue, 08 Oct 2024 10:32:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728408772; x=1729013572; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=K9V3+KdjHbhSzCFcQ9VsqfbZ9dT/SRjHShMTAr1Mnns=; b=mmSRVWTePN0ioJEksU5DfA/zdID/HbSRMJa8jW7Au/oUsBw8xOV0wHjHaPLXmPSNdo TJzckne79mCuOXFuV+PBIvx6Dn8X49eehpZaiBCbsUImSJC0WXg1DS+ixkuLtOli4K1x Uv97wyhHhDYmjTn7tp4eWzgPICGAzAFYe5eIwu4/pcb5+qDUi7A0cMV7TsD8nUuLqiKy l+pGYOu3UOIYp9oT1xtiPiscKjAFwvi+p01uQ9srtOx+NeCWH8D/7844RIcpg0Hzv99R IAgyw0aBvChFCnws+mKsynGd87dR4EKwNDXKRYUXnIJhI8zShKYdBvMhXtMsHrkBAA8D AXGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728408772; x=1729013572; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=K9V3+KdjHbhSzCFcQ9VsqfbZ9dT/SRjHShMTAr1Mnns=; b=grURR5GpEVg1/KDt/fjhDg76CB19wbxreDUcOZyeL7HFUHGCf9pDOe0LcLb1rSeX1V +sLvQrpRH7JLH+Tp8ypHUoWG8IgV6r9LARl5NzHMCMX+UkeKkg/nVWRBrSldSr0v9WLO x8Qlx/Ar32gTnb9m4GrydHVW+JzITLNJVbhuWfRwmGCWScNAF38BJBRKvpJUON8PD6pS Amqk/N2Zws5XVNz9k/tn9vkONjJr+ZO+8L3vMPCtkHftijkTFvodHB40uIPgrvbP49S6 zfDjZ3Hc/VRmM960paYvTj/L3PntTGQuJJS4jnkB4bE4nSQLqtlhYJiCFHnKnXZpfZuP lCUA== X-Forwarded-Encrypted: i=1; AJvYcCWk/UwEnzDhjxwdhljeRLKB4jB1oXfztTnj9ZhfqAqTgxs33gXXQsSp8h5Vhs6Gw5ZNJTtun0OAnP70Xno=@vger.kernel.org X-Gm-Message-State: AOJu0Yzu/rEMCnfcJtF1Tk7Ryx0mmruKgBatbciUXB8nRPJy3dBNPy0D mAhxMarElBE60Mu/5DH3QCeWwF7563J77rCQGkf6BgrLSv7/2b+CpOza5dM+2mlrMhK/s83tNFE gP/Wyw7h1/wLFXg== X-Google-Smtp-Source: AGHT+IFbafOWdlfZ9N2QUOG3z6snGs4EAIlosLdm8iUthl9i/lxwZzLY1Ty4ETXaz8NvjfdITcEa/v6JPfUVS1o= X-Received: from aliceryhl.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:35bd]) (user=aliceryhl job=sendgmr) by 2002:a25:dcc7:0:b0:e28:f19c:fd4 with SMTP id 3f1490d57ef6-e28f19c1259mr1592276.11.1728408772240; Tue, 08 Oct 2024 10:32:52 -0700 (PDT) Date: Tue, 08 Oct 2024 17:32:33 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIALBsBWcC/4WNQQ6CMBBFr0Jm7ZhORVBW3sOwoGUKTZQhbSUaw t2tXMDl+/n//RUiB88RmmKFwIuPXqYM+lCAHbtpYPR9ZtBKl6TUBcMrJosyp1xEI5JiCt2Mlar 5bNyJqLSQx3Ng59+7+N5mHn1MEj77z0K/9K9yISS8slGVrqgvXX0bRIYHH608od227QuYMio0v QAAAA== X-Developer-Key: i=aliceryhl@google.com; a=openpgp; fpr=49F6C1FAA74960F43A5B86A1EE7A392FDE96209F X-Developer-Signature: v=1; a=openpgp-sha256; l=3950; i=aliceryhl@google.com; h=from:subject:message-id; bh=z7EQ2ig9cjE6D99U3+xtPYCE3cc+3J+C5Qs8yl9IAXc=; b=owEBbQKS/ZANAwAKAQRYvu5YxjlGAcsmYgBnBWy7jrn2VYOgx95pcs0nykyBeqFL0iliRor7J CboJ0lOYAKJAjMEAAEKAB0WIQSDkqKUTWQHCvFIvbIEWL7uWMY5RgUCZwVsuwAKCRAEWL7uWMY5 Rg8ED/9IPvLoJkBpTeX1lQPOD9mPWHoqPar9tLDvdYbO6zNfpcL815e4RfblxSHw9KEmb53yAVF zTGz/NQTjq0DizAFP6NFqFzOpwXrRLCnmxDykeRsGn2Qoreby0/JQMkTRzEdVkj3NCa5UkEr4nR fLlqnqSKfSRSehHwEsvD1tF/O0ZcuKtTG+i0TKv0Soi7kPHk5QZLPzQsGfUAEsMcFqj8R1/mopC GJQxb/BhbjJ55lLppSMUg4qXyj9ZcB6kk+aKhDb2bc8nGv3BTyvoCIcjE+/zTIm8yVD5l3Ra69/ mT04VbHmh4a/1CUUFmjykGVCeKydZ21rkWReoRKYEMmKj5NQR0f77NaRJ096JW894sYAqcNOz3j U9HAPb6YSzIgvYlGuVVFhHA5C+hJJvRBHmLZf8zgCYZUZcAN4Xxqsjdq+opYqFi9zFbCvdaLYmw sLhcA5bEIrtYY+rKBH0vkBa0SE41azadeqC2mCSk53ahIXOpL1LzLziVvn4aoepUG0q/oS3uake OgSmMzNfPvzhmDZT7yxUUNxOykb9O9tLEpLdB3W1UFWdDMiWxxruLWWy6YbN+JhbtofHbPRqwhE pgUovIZIFkfB2J2omtWQ3pOurwA5PbooL9pfozenCajyy/8pC0yTLZv8OxwvWT5eER3sj/Cqu+Y ck3hQNAKND7Hiyg== X-Mailer: b4 0.13.0 Message-ID: <20241008-rustc-option-bootstrap-v2-1-e6e155b8f9f3@google.com> Subject: [PATCH v2] Kbuild: fix issues with rustc-option From: Alice Ryhl To: Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Miguel Ojeda , Matthew Maurer Cc: Alex Gaynor , Boqun Feng , Gary Guo , "=?utf-8?q?Bj=C3=B6rn_Roy_Baron?=" , Benno Lossin , Andreas Hindborg , Trevor Gross , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Alice Ryhl Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Fix a few different compiler errors that cause rustc-option to give wrong results. If KBUILD_RUSTFLAGS or the flags being tested contain any -Z flags, then the error below is generated. The RUSTC_BOOTSTRAP environment variable is added to fix this error. error: the option `Z` is only accepted on the nightly compiler help: consider switching to a nightly toolchain: `rustup default nightly` note: selecting a toolchain with `+toolchain` arguments require a rustup p= roxy; see note: for more information about Rust's stability policy, see error: 1 nightly option were parsed The probe may also fail incorrectly with the below error message. To fix it, the /dev/null argument is replaced with a new rust/probe.rs file that doesn't need even the core part of the standard library. error[E0463]: can't find crate for `std` | =3D note: the `aarch64-unknown-none` target may not be installed =3D help: consider downloading the target with `rustup target add aarch64= -unknown-none` =3D help: consider building the standard library from source with `cargo = build -Zbuild-std` The -o and --out-dir parameters are altered to fix this warning: warning: ignoring --out-dir flag due to -o flag I verified that the Kconfig version of rustc-option doesn't have the same issues. Fixes: c42297438aee ("kbuild: rust: Define probing macros for rustc") Signed-off-by: Alice Ryhl Reviewed-By: Matthew Maurer --- Changes in v2: - Add `export` to RUSTC_BOOTSTRAP. - Fix error about core being missing. - Fix warning about -o flag. - Link to v1: https://lore.kernel.org/r/20241008-rustc-option-bootstrap-v1-= 1-9eb06261d4f7@google.com --- rust/probe.rs | 7 +++++++ scripts/Makefile.compiler | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/rust/probe.rs b/rust/probe.rs new file mode 100644 index 000000000000..bf024e394408 --- /dev/null +++ b/rust/probe.rs @@ -0,0 +1,7 @@ +//! Nearly empty file passed to rustc-option by Make. +//! +//! The no_core attribute is needed because rustc-option otherwise fails d= ue to +//! not being able to find the core part of the standard library. + +#![feature(no_core)] +#![no_core] diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler index 057305eae85c..08d5b7177ea8 100644 --- a/scripts/Makefile.compiler +++ b/scripts/Makefile.compiler @@ -21,6 +21,7 @@ TMPOUT =3D $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXT= MOD))/).tmp_$$$$ # automatically cleaned up. try-run =3D $(shell set -e; \ TMP=3D$(TMPOUT)/tmp; \ + export RUSTC_BOOTSTRAP=3D1; \ trap "rm -rf $(TMPOUT)" EXIT; \ mkdir -p $(TMPOUT); \ if ($(1)) >/dev/null 2>&1; \ @@ -76,7 +77,7 @@ ld-option =3D $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1= ) -v,$(1),$(2),$(3)) # __rustc-option # Usage: MY_RUSTFLAGS +=3D $(call __rustc-option,$(RUSTC),$(MY_RUSTFLAGS),= -Cinstrument-coverage,-Zinstrument-coverage) __rustc-option =3D $(call try-run,\ - $(1) $(2) $(3) --crate-type=3Drlib /dev/null --out-dir=3D$$TMPOUT -o "$$T= MP",$(3),$(4)) + $(1) $(2) $(3) --crate-type=3Drlib $(srctree)/rust/probe.rs --out-dir=3D$= $TMP,$(3),$(4)) =20 # rustc-option # Usage: rustflags-y +=3D $(call rustc-option,-Cinstrument-coverage,-Zinst= rument-coverage) @@ -86,4 +87,4 @@ rustc-option =3D $(call __rustc-option, $(RUSTC),\ # rustc-option-yn # Usage: flag :=3D $(call rustc-option-yn,-Cinstrument-coverage) rustc-option-yn =3D $(call try-run,\ - $(RUSTC) $(KBUILD_RUSTFLAGS) $(1) --crate-type=3Drlib /dev/null --out-dir= =3D$$TMPOUT -o "$$TMP",y,n) + $(RUSTC) $(KBUILD_RUSTFLAGS) $(1) --crate-type=3Drlib $(srctree)/rust/pro= be.rs --out-dir=3D$$TMP,y,n) --- base-commit: 8cf0b93919e13d1e8d4466eb4080a4c4d9d66d7b change-id: 20241008-rustc-option-bootstrap-607e5bf3114c Best regards, --=20 Alice Ryhl