Skip to contentSkip to conversation

tools: hv: Fix cross-compilation

PATCH Superseded Aditya Garg 1 participant 2 messages Apr 7 – Apr 8

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tools: hv: Fix cross-compilation

Use the native ARCH only in case it is not set, this will allow the cross-compilation where ARCH is explicitly set.

Additionally, simplify the check for ARCH so that fcopy daemon is built only for x86_64.

---
Changes since v1:
- Dropped the info target printing CC, LD and ARCH

v1: https://lore.kernel.org/all/[email protected]/

---
 tools/hv/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/hv/Makefile +2 -2
index 34ffcec264ab..e377caf89fb6 100644
@@ -2,7 +2,7 @@
 # Makefile for Hyper-V tools
 include ../scripts/Makefile.include
 
-ARCH := $(shell uname -m 2>/dev/null)
+ARCH ?= $(shell uname -m 2>/dev/null)
 sbindir ?= /usr/sbin
 libexecdir ?= /usr/libexec
 sharedstatedir ?= /var/lib
@@ -20,7 +20,7 @@ override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
 override CFLAGS += -Wno-address-of-packed-member
 
 ALL_TARGETS := hv_kvp_daemon hv_vss_daemon
-ifneq ($(ARCH), aarch64)
+ifeq ($(ARCH), x86_64)
 ALL_TARGETS += hv_fcopy_uio_daemon
 endif
 ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
Signature · 1 line
2.43.0
#1 lore raw
Quoted 36 lines · Aditya Garg

Use the native ARCH only in case it is not set, this will allow the cross-compilation where ARCH is explicitly set.

Additionally, simplify the check for ARCH so that fcopy daemon is built only for x86_64.

---
Changes since v1:
- Dropped the info target printing CC, LD and ARCH

v1: https://lore.kernel.org/all/[email protected]/

---
  tools/hv/Makefile | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
tools/hv/Makefile +1 -1
index 34ffcec264ab..e377caf89fb6 100644
@@ -2,7 +2,7 @@
  # Makefile for Hyper-V tools
  include ../scripts/Makefile.include
 
-ARCH := $(shell uname -m 2>/dev/null)
+ARCH ?= $(shell uname -m 2>/dev/null)
  sbindir ?= /usr/sbin
  libexecdir ?= /usr/libexec
  sharedstatedir ?= /var/lib

tools/hv/Makefile override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include · line 26

Quoted 8 lines
tools/hv/Makefile +1 -1
@@ -20,7 +20,7 @@ override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
  override CFLAGS += -Wno-address-of-packed-member
 
  ALL_TARGETS := hv_kvp_daemon hv_vss_daemon
-ifneq ($(ARCH), aarch64)
+ifeq ($(ARCH), x86_64)
  ALL_TARGETS += hv_fcopy_uio_daemon
  endif
  ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))

Sashiko AI review flagged an issue, I tested it and confirmed. When building via make tools/hv from the top-level kernel directory, scripts/subarch.include normalizes x86_64 to x86, and since ARCH is exported, the ?= assignment in tools/hv/Makefile preserves the normalized value, causing ifeq ($(ARCH), x86_64) to be false and hv_fcopy_uio_daemon to be silently excluded.

I'll change this to include x86 as well in v3.

Regards,
Aditya