From nobody Thu Apr 2 22:28:55 2026 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (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 86555426D15 for ; Thu, 26 Feb 2026 17:00:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772125237; cv=none; b=IN0QlM/yUsAZU65NvMhCGe/fm2AZJ8fzqRvIYQ8ujMOMnwCGnz1/1d9DsGEURP2ibttyvd63IHzAgYJGm/rNJj1AU0pbCQq1RR/4tUVkGmGio4dd0LGRtFdRY22SrGqrHXhkMl8SWmH6dz4z0TkEn2oH67/t478uo38pKL1MAqY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772125237; c=relaxed/simple; bh=aUmpyzSrby1qhl5sgoZlhWbu9bvueo80bPZ+F/4kLzI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=GIbBKoeRHhlLQ1BGH34lv+Ekpr5CRPB+Hxoueho+6at+6dkXn8aAWQqgFC1tGG/O8KqxtvFGKuD3lo5TOUJ/haN6MY1a40J/fdU5Xa/x9xf12NxjFuvqG0NY+Q6SO8pxSdZZUGpGRFuB2ohUX/946T4AIvnCkN/mw69JHDjPIjU= 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=IfCqnO6v; arc=none smtp.client-ip=209.85.208.45 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="IfCqnO6v" Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-65fb991d7eeso1449611a12.0 for ; Thu, 26 Feb 2026 09:00:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772125234; x=1772730034; 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=ALqBvDE1FO+pe4+Grs49xjYdZp5dzbvZUUI22o6rYDw=; b=IfCqnO6vfhmLflYdiMHsOaSyjTm6lB4X9+UuCJfqLTQ14vkh+aRFUta5VUI45L33IO X5Ts9D4whddgELe8593teHhtfioPSF3JOpJNZ/zYnlLotFp6yctZzYwc+YfpmA/6PZri i7bpd1cfGssKnlZOJ9YY9Ds72DYpUEydm8HrCXWZlHTOzgv05IXZeRAlGS4R72qr+qNS Qey28boiqFD+971y4TZxKF9fOXr9h+6o8+lp83gD9fFgEkVvny0dOfFrK2FsDUZc+hze 72nyJ9jGi4SwulRR2VXjbj7zXgWPW61eFQcDN6p7xV2Lcgh7KthcThnUsEGmA+eqh5+K CRDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772125234; x=1772730034; 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=ALqBvDE1FO+pe4+Grs49xjYdZp5dzbvZUUI22o6rYDw=; b=i3UhmZhq+Iuvr0aO/cUOmVTc7bkedOyfAAgmwaOayxLUtJQDgGcdfpEVER7+1ESBD+ kO9aXesz7SzDDpzucVelOX3lRGEQ8ROEe4d1vNds+PN+WuSMETLfKxhrMZ1vxEIpM4dC C/8ZNrNgO8LDFd8F2onx+2SpTVLSqAOQnwZFonuP1nAIRPfc0t9QEtosgPbM/AGZ2xTu mXeP9IxHgUT4J0HB7GNsaMgYm+5LONkIzDzLgqwKixoqcGjkilh4LxIO292dpjZ1fHRL 2vXWe4HtsM/w9fSHhUPP/5wPEBd2kOhSj/Rt/dq6V0BqMlC+KBzLN5PVcfavk86AVbsy ilAQ== X-Forwarded-Encrypted: i=1; AJvYcCWOL+bMSk4b1AeMkIqtmTYjxT4GamAC3t8vNzNnfST4UakMBTkCmYmtEFD1ZEWzSXGqzyvVgHRtBpmk+Qk=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3d8wSg5YwidGxJ/rDJ+mHDGXGw//0Qrypra0rVLwuX+vBo3G+ MtPocEl3kPnm+FpB3LE4U19XsIme27JryNyaS5MxOnUy55qeJpSoU+7u X-Gm-Gg: ATEYQzz1y8ODqcWsIud6Ki3vI6XNrXFqwgWz0KI6VaqmexjvF6hN3LGkYf+7X+woYkN MgfuPeSevN5N9MIzXsBqti3yXaP6IdG8W4SnsYXy5wxMhoz38Ge0gYbTCadzrjyyJHOy6ezo1EW Q7yy79Vj4m+muGY4j/DbFMeF/e+kublwAHr0kVuVlrU5oNimI4HQVtIcg+ND7ZL7wVA6NOm7gGj PY50N+PcidfpWOhyOE7VFs0Rf7ADFy3dGLbXb9Pytx0WEjeWK2ADV7JweZ880RHxsF75WK1tI25 kQA4rj7+Yufh1ULXZLiZ7zQvNQa/58flw3xTX1CrQARgweArhwW4rjAZI9jj/sIxyR25gW464y/ 9eUmitO7wS/WQNI+UgYPL5MXC14JfHR3Ou3CUdVJ3zNOUVzqvedSO+MrM3bm7zWH1rx+Lz0pelp Sxe5mHupAsZH5XEfjcLoXYb10cTyA0zcaik0v/h6IOMeO4qaOzplNjMX+66w== X-Received: by 2002:a17:907:6d13:b0:b93:335f:18d5 with SMTP id a640c23a62f3a-b935b8ea035mr225250866b.36.1772125233377; Thu, 26 Feb 2026 09:00:33 -0800 (PST) Received: from ddolgov-thinkpadt14sgen1.rmtde.csb ([2a00:20:6364:854a:4ce7:5ea2:2f05:232b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b935ac7371esm77838766b.24.2026.02.26.09.00.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Feb 2026 09:00:32 -0800 (PST) From: Dmitrii Dolgov <9erthalion6@gmail.com> To: linux-perf-users@vger.kernel.org, Ian Rogers , Arnaldo Carvalho de Melo , Miguel Ojeda , Levi Zim Cc: Namhyung Kim , Linux Kernel Mailing List , Linux Kbuild mailing list , rust-for-linux , Nathan Chancellor , Nicolas Schier , Dmitrii Dolgov <9erthalion6@gmail.com> Subject: [PATCH v5] tools build: Fix rust cross compilation Date: Thu, 26 Feb 2026 17:59:59 +0100 Message-ID: <20260226170025.517743-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. E.g. for arm64: LD /tmp/build/tests/workloads/perf-test-in.o aarch64-linux-gnu-ld: /tmp/build/tests/workloads/code_with_type.a(code_= with_type.code_with_type.d12f4324cb53c560-cgu.0.rcgu.o): Relocations in gen= eric ELF (EM: 62) aarch64-linux-gnu-ld: /tmp/build/tests/workloads/code_with_type.a(code_= with_type.code_with_type.d12f4324cb53c560-cgu.0.rcgu.o): Relocations in gen= eric ELF (EM: 62) [...repeated...] aarch64-linux-gnu-ld: /tmp/build/tests/workloads/code_with_type.a(code_= with_type.code_with_type.d12f4324cb53c560-cgu.0.rcgu.o): Relocations in gen= eric ELF (EM: 62) aarch64-linux-gnu-ld: /tmp/build/tests/workloads/code_with_type.a(code_= with_type.code_with_type.d12f4324cb53c560-cgu.0.rcgu.o): Relocations in gen= eric ELF (EM: 62) aarch64-linux-gnu-ld: /tmp/build/tests/workloads/code_with_type.a: erro= r adding symbols: file in wrong format make[5]: *** [/perf/tools/build/Makefile.build:162: /tmp/build/tests/wo= rkloads/perf-test-in.o] Error 1 make[4]: *** [/perf/tools/build/Makefile.build:156: workloads] Error 2 make[3]: *** [/perf/tools/build/Makefile.build:156: tests] Error 2 make[2]: *** [Makefile.perf:785: /tmp/build/perf-test-in.o] Error 2 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [Makefile.perf:289: sub-make] Error 2 make: *** [Makefile:76: all] Error 2 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]. Fixes: 2e05bb52a12 ("perf test workload: Add code_with_type test workload") Link: https://perfwiki.github.io/main/arm64-cross-compilation-dockerfile/ [= 1] Reviewed-by: Ian Rogers Signed-off-by: Dmitrii Dolgov <9erthalion6@gmail.com> --- Changes in v5 - Error out if the target arch is not covered Changes in v4 - Fixed incorrect target name for riscv Changes in v3 - Improved commit message, add an example of the compilation failure Changes in v2: - Map supported CROSS_COMPILE values to corresponding Rust targets tools/build/Build.include | 9 +++++++++ tools/perf/Makefile.config | 18 ++++++++++++++++++ tools/perf/Makefile.perf | 2 +- 3 files changed, 28 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..15fbba9f4ca 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),) + 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 riscv64gc-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 + + ifeq ($(RUST_TARGET_FLAGS_$(ARCH)),) + $(error Unknown rust cross compilation architecture $(ARCH)) + endif + + 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 11b63bafdb2..f7b936deeaa 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -274,7 +274,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: c5a244bf17caf2de22f9e100832b75f72b31d3e6 --=20 2.52.0