From nobody Thu Apr 2 22:29:00 2026 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 D8C6427A47F for ; Fri, 13 Feb 2026 19:12:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771009947; cv=none; b=VKaHCJvLqj0z+AXu+hr5ybIrafIUqeDUgZRL78dWEAEl6UUk6kG8HTi8TTshSMneHNphtLZ807/GzJJVYyrXWJJ+uqpoG+bmN/Aigwj10/5Fm4jdEX9Waj2CrVGiii+7w0hWTxIrFYXqU+zZw3huVUn3kqRlR6EUqcjqPiJH6x0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771009947; c=relaxed/simple; bh=OcH8w7RuyScwYrcF3u0PgWhZiy0vC1nFvdfSLmhr6ao=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=dFFcBUdEtvDutekua0DS+x+hT+QZM/Yrv8WwfwhmnLHQZYBgjZtehUSLnXu5aUPe/inLHIumUfoJ4xfIAOIQC9+cZa3eaxkrQCePRzcRd7oBDhtwoK2eJw4R+ji3wU9mebttSxiqp1DgyjUBPngnyoxWo5lxlgDdXb4ylB710q8= 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=KfKmG/+S; arc=none smtp.client-ip=209.85.208.41 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="KfKmG/+S" Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-65a3c320998so1771885a12.2 for ; Fri, 13 Feb 2026 11:12:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771009944; x=1771614744; 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=5ZpqJAf35CDxn8PSc9O1hec1UhW5JRewyjQeoYcibqk=; b=KfKmG/+S5I3jS7qi+NNZtD2TJT/B/XSCTFgYBBgAkw6kMU4v8iC4KwGvE8SzVLFKAD ztdL+1st3kRIDvu2auoIi/oGvDEHzV83nptV9i8K2XDb1pUMwFQopfM00UgEzMARHrdi EBgxshMgO6gxZD7LzEeNxRTp4HhiBoNe9lUus+q+0F6u9SsEY0k/x93V0252j0L0CUkb Liqf3qqcdwJfyjy6+6fDPueamJxgsxNzsYriXIm/rde5XNzborbmf8WRp9wvcBnkRKh0 SlpElXek8dEdr4hWV+4/XvzNsRcQ8e/ScRrGa3g2cnQHtscFuPklzm09pBsqJVHIQUfU tT2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771009944; x=1771614744; 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=5ZpqJAf35CDxn8PSc9O1hec1UhW5JRewyjQeoYcibqk=; b=ZvJYRlm3Hh1zNZiP8pdGrEA95BYIY+OAS3b1xphuP0GtLXWxZgPw0oixxh8VyNevW1 A8DW1OcogI5Eq0Fjm3/fM1EV2H311JPC0F8eNLa8pWoVcVSj7voEoxv34cg+RWdwVvho QV4Jxft9UrYL6c/ByraHxLuzuwG653NW6/Nvcp6/qfSCkS/R+NCULu/2n2fba08h33X/ kf8cTpEU1yDZM9m16YN8TCky//Lkx74/j2Sxr8G+q9MQ3vZr7MXSb5Fos0PHclhzyMhD zK7HFJKOfwhoGJE4pm1TrYjRThQc6eXFGRPrOydLuz52Ea3Ky8pQSdRiMb4ncz7G6KoO sbOA== X-Forwarded-Encrypted: i=1; AJvYcCX9lsdIaghbejBPhV3fWHRnIBHhQRebIRbOG/KyQyJt7HlZC2aBngWoOfHqaG5Prd6ZYlZiiE+XVyjpbeU=@vger.kernel.org X-Gm-Message-State: AOJu0YxF7m5WuvI0z8hi6srQaJYUB7UHAXnGDfLGGQeH3R0KNTcGokQz M+UBSwqAaG2LX11+lT23ghdGve8S02jfl5AUoZ/NKQjWvCjEd8Gcw5Oq X-Gm-Gg: AZuq6aInUoVN7fRYaZqOjLrM77MkkOd8IBHw3bL8QDkL281vqooaX5ErEBbfuctpOCC xjkr5/00lIDmDTqGmRCqeAMHCXg9vyFJ6dGB8yooCXZaxXlwvRULAe5QfjmCSnokqlXgwFrhUHs 4t7DfywqTFvS0tT0c+eRFRIdJKrpBK3GfvXp6m/NMzlicXRyCELykwO4u4p81iHegkxJlyPTQbE dtKDnvILhUILS5t1z7wN5edjieMWy+eOpGDqT6GEJNKKm1dNyLvJ5BQE61jw2B87gsz3J0NDsv9 KdnR4Ek6dV7KAKu27pYplQKSxpw6o2a4s0n8B0dZ/gs7cnr6nDvvmGvTxY7/ryQKhaGJ5pPefCl umBS7EnE0Okb1v1grz8rQlXYPQiBmBxAzxtfMQ0E2Gad1IRFxO/MK+MX719amAaoKM12WppwQ2F tmiO+NljcDK5p2J61VGwZIxiK9KRKjcsB4PBzOxAuLCOwSp3T6ziquekkJzAYcQDe9T0dUEzxzB FHuN9XX5QuBJMckhfPD0YDxr8n8z0o= X-Received: by 2002:a05:6402:398c:b0:65a:3c1b:d87d with SMTP id 4fb4d7f45d1cf-65bb10f4224mr1096630a12.6.1771009943923; Fri, 13 Feb 2026 11:12:23 -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 4fb4d7f45d1cf-65bad3f0b55sm950830a12.23.2026.02.13.11.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Feb 2026 11:12:23 -0800 (PST) From: Dmitrii Dolgov <9erthalion6@gmail.com> To: linux-perf-users@vger.kernel.org, Ian Rogers , Arnaldo Carvalho de Melo , Miguel Ojeda Cc: Namhyung Kim , Linux Kernel Mailing List , Linux Kbuild mailing list , rust-for-linux , Dmitrii Dolgov <9erthalion6@gmail.com> Subject: [PATCH v1] tools build: Fix rust cross compilation Date: Fri, 13 Feb 2026 20:12:09 +0100 Message-ID: <20260213191212.33328-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 explicitly map supported CROSS_COMPILE values to corresponding Rust versions, as suggested by Miguel Ojeda. 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 | 14 ++++++++++++++ tools/perf/Makefile.perf | 2 +- 3 files changed, 24 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..f40c5a70520 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -1163,6 +1163,20 @@ ifndef NO_RUST CFLAGS +=3D -DHAVE_RUST_SUPPORT $(call detected,CONFIG_RUST_SUPPORT) endif + + ifneq ($(CROSS_COMPILE),) + RUST_TARGET_FLAGS_arm :=3D arm-unknown-linux-gnueabi + RUST_TARGET_FLAGS_arm64 :=3D aarch64-unknown-linux-gnu + RUST_TARGET_FLAGS_m68k :=3D m68k-unknown-linux-gnu + RUST_TARGET_FLAGS_mips :=3D mipsel-unknown-linux-gnu + RUST_TARGET_FLAGS_powerpc :=3D powerpc64le-unknown-linux-gnu + RUST_TARGET_FLAGS_riscv :=3D riscv64-unknown-linux-gnu + RUST_TARGET_FLAGS_s390 :=3D s390x-unknown-linux-gnu + RUST_TARGET_FLAGS_x86 :=3D x86_64-unknown-linux-gnu + RUST_TARGET_FLAGS_x86_64 :=3D x86_64-unknown-linux-gnu + + RUST_FLAGS +=3D --target=3D$(RUST_TARGET_FLAGS_$(ARCH)) + endif endif =20 # Among the variables below, these: diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index a6d8ca3e923..f3919838243 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -271,7 +271,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