From nobody Fri Apr 17 23:07:11 2026 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 29C27BA21 for ; Thu, 12 Feb 2026 18:58:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770922698; cv=none; b=YC2+3acDKfmL31VeYWfvqjPQDRJYt3JYdA8v7jIutNWbtAbyBy4ALomyvuSaC2I6RzxC11VcUYSwT0jx95vhc5yOYP7w52uhJLCeR0bvpCDEhHyx+W3YIXsVjxsNb6mIX7xl8iDlsFMkYNTvyEPN2Unwi0v4PoTwTKHR4mOSdKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770922698; c=relaxed/simple; bh=jaCplkj9P/whtB6A5OAwLdYg/wLmlg32rjwvrTXxAjE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=FUWusETkM7Ox4RL3tYvySgjTnahxzzAk+1St0ZmIM+dNTVlcEv62Nuv04oeZhIiw89WPI8KjKtcUjMPqVE13gKjbQWyKX5QeOXOTCMQcTlUH3dL3O4AtppfENFPjggKVX/SgXqqULvFVummfmG4J8sEUFAdygMu1AJXw0ttkHhU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kFwFomJd; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kFwFomJd" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-b8fa449e618so12500066b.0 for ; Thu, 12 Feb 2026 10:58:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770922695; x=1771527495; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=w7koUxEnJ8qJTQm6zEGAuSnrRJGm+RijWpLIoq7B1u4=; b=kFwFomJdQFbOhNL04C/JzKM4sep4pnI45bobC3v8VecblR9i33nYPGAstx0h701tok Pl3Qsho7jqnrs0DrKaqQCglSEc+ev6jC1+7lOlHga6vP2SSmjgMKT8589Z8nVsTzUcTV pbTbtqFeu0b7wOJvmVU1P0cTZdNgnH6mpt1zu2sB7+Gk6hGOndBr8EqyETOOLufmwSjw Xx/gxQbPONqzLUfv8iaVxxEVobCK/HbIkn0qpa7n1/0f0YhycgtRCKpQk3hBFyVjG56h 7Maievo1A8o5M+MAJ/P4YVPstRKCZ9ap4v4o4Gd9H1GFLVKzLZoSojahGgtgkY89m7wN jROw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770922695; x=1771527495; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=w7koUxEnJ8qJTQm6zEGAuSnrRJGm+RijWpLIoq7B1u4=; b=HgpraxGq1ldl8a/A2K3lq6OcRWMMkms1nQHEzl+Ct+lmUuVxMZAhfMWxqXcf0yMRO0 oec6bRHI/bFPfW6ZxjYpqcvxNAq1pbKjvinQdXW9DC5ecHeCwJ7AZJUB7cS2AgNKiKZs Ap2U8UR81S7FLAINl+UyFKZiIR9a+tVBn17b1KzP4BWU4925b/z56kC27tsBqXBPfqcg SE6LhoSy21g2kKg6WXpnnH0HvNDyM9SPhxHlmUtGtAIEhyZsFMDn1vdfMv9ZrVCKwprh XM6RzyjyirNDcxGFfuRT9c34k4P0m4bb836gkcIm8MA0fYwr8DobfYgP0l8g9DdNaHTW o0pw== X-Forwarded-Encrypted: i=1; AJvYcCXLPE8ypg0OoGl/f+jX+EmMu+05NJlFH/1eC60ZHqyTvIwaMEIKpRxmtlPqYVQ+KT0QRrhX9fmg7LztnHI=@vger.kernel.org X-Gm-Message-State: AOJu0YwdahPq1FqLdDX9tKRKMSUyZJPwMhCsgKIhKSwxg0cUis+PkJgR mS3P6QmqCRBxWudc39pUW7e6vUM/0DIiYzfAGy9cMeOBLJ51GMx3560N X-Gm-Gg: AZuq6aK93VPQTbikqJv3wQm0W3okvMG7epV7fpr5agIXE8hi8185XOhVmfkwa5AOm6c 5J2IcL81KoEKGckLuvd4/aHilSuZWjdWO7p3kgH0fzN5HzecBMT/I/Oz9aq5Wsp9cNqDDvEYHzY GriCGIQjQDCvqHRcrU7iNtYhM7Va1B44mbHeVllle3AglxbI5kgcr+CkpIMtHmhRo5FBu66JNKR kFuYrANySXPzVwVzJMmXNb4ILfn+Ode8ynLEAkfanSvucNulyV6PxX9KGgwXkoOUuXT90HzdOB8 LtJvOYk8cbidcNf50QL0VTZdYvN/Qaa01g2UFDo6ahhwC34dMnjbtbuFl5WFZd2GScl3SSKnbhw 5pMLr/LhZLxkecZHIhKq6kBIPY+lxCq7eyaXQNbaf2xOINHTMD+KHtS5ttq8ZTB71DQLUbOrqRR iGwJmSXUg0NC+cvhabHtgcqQxW/977oU0kCQvO0UyuFqwPfQoIexGttGXtbIyCTc6e3R/ebXY9J qohR8whqU3WoVbmHPTK+Wtr2oUYFsQ= X-Received: by 2002:a17:907:db02:b0:b8f:1c:e815 with SMTP id a640c23a62f3a-b8face16a1cmr1899266b.48.1770922695262; Thu, 12 Feb 2026 10:58:15 -0800 (PST) Received: from ddolgov-thinkpadt14sgen1.local (dslb-002-207-075-089.002.207.pools.vodafone-ip.de. [2.207.75.89]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b8f7a48890esm161664466b.65.2026.02.12.10.58.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 10:58:14 -0800 (PST) From: Dmitrii Dolgov <9erthalion6@gmail.com> To: linux-perf-users@vger.kernel.org, Ian Rogers , Arnaldo Carvalho de Melo Cc: Namhyung Kim , Miguel Ojeda , Linux Kernel Mailing List , Dmitrii Dolgov <9erthalion6@gmail.com> Subject: [PATCH v1] tools build: Fix rust cross compilation Date: Thu, 12 Feb 2026 19:57:14 +0100 Message-ID: <20260212185810.648364-1-9erthalion6@gmail.com> X-Mailer: git-send-email 2.52.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently no target is specified to compile rust code when needed, which breaks cross compilation. Detect required target and pass it via rust_flags to the compiler. Note that CROSS_COMPILE might be different from what rust compiler expects, since it may omit the target vendor value, e.g. "aarch64-linux-gnu" instead of "aarch64-unknown-linux-gnu". Thus provide an explicit RUST_TARGET_ARCH, and if not specified, try to match the CROSS_COMPILE value. Tested using arm64 cross-compilation example from [1]. [1]: https://perfwiki.github.io/main/arm64-cross-compilation-dockerfile/ Signed-off-by: Dmitrii Dolgov <9erthalion6@gmail.com> --- tools/build/Build.include | 9 +++++++++ tools/perf/Makefile.config | 18 ++++++++++++++++++ tools/perf/Makefile.perf | 4 +++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/tools/build/Build.include b/tools/build/Build.include index e45b2eb0d24..cd0baa7a168 100644 --- a/tools/build/Build.include +++ b/tools/build/Build.include @@ -98,6 +98,15 @@ c_flags_2 =3D $(filter-out $(CFLAGS_REMOVE_$(basetarget)= .o), $(c_flags_1)) c_flags =3D $(filter-out $(CFLAGS_REMOVE_$(obj)), $(c_flags_2)) cxx_flags =3D -Wp,-MD,$(depfile) -Wp,-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=3D= \#s" $(CXXFLAGS_$(basetarget).o) $(CXXFLAGS_$(obj)) =20 +### +# Rust flags to be used on rule definition, includes: +# - global $(RUST_FLAGS) +# - per target Rust flags +# - per object Rust flags +rust_flags_1 =3D $(RUST_FLAGS) $(RUST_FLAGS_$(basetarget).o) $(RUST_FLAGS_= $(obj)) +rust_flags_2 =3D $(filter-out $(RUST_FLAGS_REMOVE_$(basetarget).o), $(rust= _flags_1)) +rust_flags =3D $(filter-out $(RUST_FLAGS_REMOVE_$(obj)), $(rust_flags_2)) + ### ## HOSTCC C flags =20 diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index a8dc72cfe48..9b164b442da 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -1163,6 +1163,24 @@ ifndef NO_RUST CFLAGS +=3D -DHAVE_RUST_SUPPORT $(call detected,CONFIG_RUST_SUPPORT) endif + + ifneq ($(CROSS_COMPILE),) + ifneq ($(RUST_TARGET_ARCH),) + RUST_FLAGS +=3D --target=3D$(RUST_TARGET_ARCH) + else + # CROSS_COMPILE specifies the target triple, which may not match what + # Rust expects, e.g. it can omit the target vendor if C toolchain is + # used. For example the value can be aarch64-linux-gnu, where Rust u= ses + # aarch64-unknown-linux-gnu. Try to match that and insert an "unknow= n" + # vendor if omitted. + TRIPLE :=3D $(subst -, ,$(CROSS_COMPILE:%-=3D%)) + ifeq ($(words $(TRIPLE)),3) + RUST_FLAGS +=3D --target=3D$(word 1,$(TRIPLE))-unknown-$(word 2,$(= TRIPLE))-$(word 3,$(TRIPLE)) + else + RUST_FLAGS +=3D --target=3D$(CROSS_COMPILE:%-=3D%) + endif + endif + endif endif =20 # Among the variables below, these: diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index a6d8ca3e923..621800e1716 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -17,6 +17,8 @@ include ../scripts/utilities.mak # # Define CROSS_COMPILE as prefix name of compiler if you want cross-builds. # +# Define RUST_TARGET_ARCH as rust target arch if you want cross-builds. +# # Define LIBPERL to enable perl script extension. # # Define NO_LIBPYTHON to disable python script extension. @@ -271,7 +273,7 @@ ifeq ($(PYLINT),1) PYLINT :=3D $(shell which pylint 2> /dev/null) endif =20 -export srctree OUTPUT RM CC CXX RUSTC LD AR CFLAGS CXXFLAGS V BISON FLEX A= WK +export srctree OUTPUT RM CC CXX RUSTC LD AR CFLAGS CXXFLAGS RUST_FLAGS V B= ISON FLEX AWK export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY PYLINT =20 include $(srctree)/tools/build/Makefile.include base-commit: 5d1ab659fb93eed85d6d8b2937013360157032f4 --=20 2.52.0