From patchwork Mon Aug 19 21:35:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Maurer X-Patchwork-Id: 13769027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5E87C3DA4A for ; Mon, 19 Aug 2024 21:43:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 430626B007B; Mon, 19 Aug 2024 17:43:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B9816B0082; Mon, 19 Aug 2024 17:43:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 259F76B0083; Mon, 19 Aug 2024 17:43:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 050D66B007B for ; Mon, 19 Aug 2024 17:43:22 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A9FF8A161F for ; Mon, 19 Aug 2024 21:43:22 +0000 (UTC) X-FDA: 82470321444.12.1C99A34 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf04.hostedemail.com (Postfix) with ESMTP id D602640012 for ; Mon, 19 Aug 2024 21:43:20 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="2ucw/sCN"; spf=pass (imf04.hostedemail.com: domain of 3r7rDZgcKCHAaaOifSfUccUZS.QcaZWbil-aaYjOQY.cfU@flex--mmaurer.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3r7rDZgcKCHAaaOifSfUccUZS.QcaZWbil-aaYjOQY.cfU@flex--mmaurer.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724103785; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dYHfB1jRSques99oHkY91uNPL3BC6i2xvsHR0qX5+O4=; b=XX3LMB5MS8H301LMdOdyZaeE1d2eCp2E7eC+Er3jOC5LO3yCL5p2TkHh1REfR50uRUpOvF SRVn7EAhYuXvDMCqhfFiQ7cgRkTYPQx2IZBSFuxNQjaBnKfUHtf/pPhrsYK+4vwH/jCjF/ M31Xn2WkFPxJpc6u7H2Fq3xlx5xrQlM= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="2ucw/sCN"; spf=pass (imf04.hostedemail.com: domain of 3r7rDZgcKCHAaaOifSfUccUZS.QcaZWbil-aaYjOQY.cfU@flex--mmaurer.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3r7rDZgcKCHAaaOifSfUccUZS.QcaZWbil-aaYjOQY.cfU@flex--mmaurer.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724103785; a=rsa-sha256; cv=none; b=RmQ66YLGohgWfEEx2b6elAJRcNeB4xhMm/LWJ/rzJkSrmVt4P1giPRJOkhujfd0SrVqgwa n9xXKf3nqPKGSt3wwU96+/lYXqCAFRcZDs3jW9eQ2j8KWMhSZxtoxvKbkmrzfRLVzu8oZl qe2M9d1i5UZt5iMyK9LSOjaNg1k4aJI= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6b41e02c293so56682107b3.0 for ; Mon, 19 Aug 2024 14:43:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1724103800; x=1724708600; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=dYHfB1jRSques99oHkY91uNPL3BC6i2xvsHR0qX5+O4=; b=2ucw/sCNsy2KE2SMNdllqPnLlTb2K1ngXyWCCvqYw8kE8+gY4grOcOAlM4e2erjGyo 0fyxh2tO77eSdJv4MKlLJrzwzEfSCfvY/RQKdQwwslw8VLpcXTVIG1s+wQu8XddxRVVQ JCFo//fOb7S7GahN6PBe0jWmY60PK8pwUwswFKt1ouwLacgYuiruM/dWNLV9lx8BXine PTZRmAocndrNUKbddWczvfLv/AovCVPX/ZjP4VgKAb25eIbVjKoJdVMzMcDJrJrXuhGR 4jiUwqDfHiepdauVI1hU2x3Jf5ANh5qFq7/jdeMxQIYGxajrncsoDXQH2Go/yULtAcBF 9MDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724103800; x=1724708600; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dYHfB1jRSques99oHkY91uNPL3BC6i2xvsHR0qX5+O4=; b=g1OUwosz2uF7+rCYAu5MJeEXjiklW4YoNpeeD5UPmQkdHxr2FmPBgd74iZB8eHGXcf tZ0W8vbZuchKnRIw9MpI13i0DZJP6Kk83h0PK3E7fBy+x3+4LRRKdmTsUljg32JAJ6Q7 f5flPF8pIJzieTERd96ZbsMl2rdwIn/b4CCHW3AFofa9FbEqbADVcr+w7vsXWchLkBVh OehatLPbfQu4Qr3jxxWEIrp5sJG84X72TLsSQcfe1OWB6nxv63tryE1IsIxJvlxTTvcp 9lSulO+QmL503Y3nPlFxErpvGken0nvvGACNqKyOknnk3e41oXcF3Fi1VG3MuNUTdjXL ln/g== X-Forwarded-Encrypted: i=1; AJvYcCXhfGEkIyxVhByTzeIep5Va2m5lRsC0xloOBf30sLJkyx3BxQHc7ok53FufCzd88790WvfC8w3uBi7rV+4DwKbnkLg= X-Gm-Message-State: AOJu0Yxi+qoX5SY0ZGUlFsefoHXrnXyqcOz4KTPFeP57K3CvrrEBh54Y UdKg4Wn7nZIocycxEhlViG6G3ly+k4S194SfCs742AGrWJ140FLpxbXarsy4gLki5wmT0lZfMoE dq0kcYQ== X-Google-Smtp-Source: AGHT+IFwshO87RfhTzH1yMuE+dB46zbPZ1Eu9OzIlegM79V4EtZO9MXEpG14lmgTuz2TbiBW6ciN753E2AAE X-Received: from anyblade.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1791]) (user=mmaurer job=sendgmr) by 2002:a05:690c:2912:b0:62f:f535:f41 with SMTP id 00721157ae682-6b1bc5e4037mr4097737b3.9.1724103343636; Mon, 19 Aug 2024 14:35:43 -0700 (PDT) Date: Mon, 19 Aug 2024 21:35:19 +0000 In-Reply-To: <20240819213534.4080408-1-mmaurer@google.com> Mime-Version: 1.0 References: <20240819213534.4080408-1-mmaurer@google.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog Message-ID: <20240819213534.4080408-2-mmaurer@google.com> Subject: [PATCH v3 1/4] kbuild: rust: Define probing macros for rustc From: Matthew Maurer To: dvyukov@google.com, ojeda@kernel.org, andreyknvl@gmail.com, Masahiro Yamada , Alex Gaynor , Wedson Almeida Filho , Nathan Chancellor Cc: aliceryhl@google.com, samitolvanen@google.com, kasan-dev@googlegroups.com, linux-mm@kvack.org, glider@google.com, ryabinin.a.a@gmail.com, Matthew Maurer , Nicolas Schier , Boqun Feng , Gary Guo , " =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= " , Benno Lossin , Andreas Hindborg , Nick Desaulniers , Bill Wendling , Justin Stitt , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, llvm@lists.linux.dev X-Rspam-User: X-Stat-Signature: 6q4jd5b8u33pxrzabhhn3g7gjmtdshuc X-Rspamd-Queue-Id: D602640012 X-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kKUoiWoQmOtZOGCUOdnjeXcI4T5sR9Nup+NmfrRw3+2/kShuVZvU382tqM0ZKvkYnOFu6+H6kYgCRgdBdMqRgQpX/AEffLy0mtr+sUKvy+8Zk0vuvY+2HJ/fe58C13m38U4CUiiwU5MSu9+6fXlOedF3blWt5tXQM+lBPUNdlsILA96Kb2Dw7zb00P5NtTwMvnIpoQdyglOuTyH5MhPo9yRBvuD5qljIfNO67rGLlziabUNW7Nc8c/lIYVwzEVDp7oQeKDRlxI8KaMfY0M1u7EJGEIX4/cvYtHE0odWqNhCLBJcAMX0LyDbPyqVVp9rIIhpjylAAYeu9bQnXLNoPn86ZAMFr5ZoOQQpUEVunKSBh6cAONcEGh8VLFi55OcT4h+qykJn6coY/OYdPkLleu+3o+e6J1zg9DaAjHA/1M3h1iRFMMipHdigaPplTaWdEYk8ZwqWhUEKEnrXj+aVFchHIsx7oRIOr3fETv4sgEP+t+sBnQItvJCCpllNmyTaXRnMMPGvzl4/YpqCuY6WuQPYXVgHMN2Cx8zaFDqcXbC1iHL2Xx X-Bogosity: Ham, tests=bogofilter, spamicity=0.000347, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Creates flag probe macro variants for `rustc`. These are helpful because: 1. `rustc` support will soon be a minimum rather than a pinned version. 2. We already support multiple LLVMs linked into `rustc`, and these are needed to probe what LLVM parameters `rustc` will accept. Signed-off-by: Matthew Maurer --- scripts/Kconfig.include | 8 ++++++++ scripts/Makefile.compiler | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include index 3ee8ecfb8c04..ffafe269fe9e 100644 --- a/scripts/Kconfig.include +++ b/scripts/Kconfig.include @@ -63,3 +63,11 @@ ld-version := $(shell,set -- $(ld-info) && echo $2) cc-option-bit = $(if-success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null,$(1)) m32-flag := $(cc-option-bit,-m32) m64-flag := $(cc-option-bit,-m64) + +# $(rustc-option,) +# Return y if the Rust compiler supports , n otherwise +# Calls to this should be guarded so that they are not evaluated if +# CONFIG_HAVE_RUST is not set. +# If you are testing for unstable features, consider `rustc-min-version` +# instead, as features may have different completeness while available. +rustc-option = $(success,trap "rm -rf .tmp_$$" EXIT; mkdir .tmp_$$; $(RUSTC) $(1) --crate-type=rlib /dev/null -o .tmp_$$/tmp.rlib) diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler index 92be0c9a13ee..485d66768a32 100644 --- a/scripts/Makefile.compiler +++ b/scripts/Makefile.compiler @@ -72,3 +72,18 @@ clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1) # ld-option # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y) ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3)) + +# __rustc-option +# Usage: MY_RUSTFLAGS += $(call __rustc-option,$(RUSTC),$(MY_RUSTFLAGS),-Cinstrument-coverage,-Zinstrument-coverage) +__rustc-option = $(call try-run,\ + $(1) $(2) $(3) --crate-type=rlib /dev/null -o "$$TMP",$(3),$(4)) + +# rustc-option +# Usage: rustflags-y += $(call rustc-option,-Cinstrument-coverage,-Zinstrument-coverage) +rustc-option = $(call __rustc-option, $(RUSTC),\ + $(KBUILD_RUSTFLAGS),$(1),$(2)) + +# rustc-option-yn +# Usage: flag := $(call rustc-option-yn,-Cinstrument-coverage) +rustc-option-yn = $(call try-run,\ + $(RUSTC) $(KBUILD_RUSTFLAGS) $(1) --crate-type=rlib /dev/null -o "$$TMP",y,n)