tools: hv: Fix cross-compilation
Subsystems (2)
PATCH 1/1 tools: hv: Fix cross-compilation
Use the native ARCH only incase it is not set, this will allow the cross complilation where ARCH is explicitly set. Add few info prints as well to know what arch and toolchain is getting used to build it.
Additionally, simplify the check for ARCH so that fcopy daemon is build only for x86_64.
--- tools/hv/Makefile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
tools/hv/Makefile +11 -3
@@ -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,18 +20,26 @@ 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)) ALL_SCRIPTS := hv_get_dhcp_info.sh hv_get_dns_info.sh hv_set_ifconfig.sh -all: $(ALL_PROGRAMS) +all: info $(ALL_PROGRAMS) export srctree OUTPUT CC LD CFLAGS include $(srctree)/tools/build/Makefile.include +info: + @echo "---------------------" + @echo "Building for:" + @echo "CC $(CC)" + @echo "LD $(LD)" + @echo "ARCH $(ARCH)" + @echo "---------------------" + HV_KVP_DAEMON_IN := $(OUTPUT)hv_kvp_daemon-in.o $(HV_KVP_DAEMON_IN): FORCE $(Q)$(MAKE) $(build)=hv_kvp_daemon
Signature · 1 line
2.43.0
Wei Liu
maintainerQuoted 30 lines · Saurabh Sengar
Use the native ARCH only incase it is not set, this will allow the cross complilation where ARCH is explicitly set. Add few info prints as well to know what arch and toolchain is getting used to build it.
Additionally, simplify the check for ARCH so that fcopy daemon is build only for
x86_64.Fixes 82b0945ce2c2 ("tools: hv: Add new fcopy application based on uio driver")Reported-by Adrian Vladu <[email protected]>Signed-off-by Saurabh Sengar <[email protected]>--- tools/hv/Makefile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)tools/hv/Makefile +1
-1@@ -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 23
Quoted 5 lines
tools/hv/Makefile +1
-1@@ -20,18 +20,26 @@ 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)
Technically speaking, you can also build this for x86 (32bit). Whether anybody uses it is another question.
Quoted 9 lines
tools/hv/Makefile +1
-1ALL_TARGETS += hv_fcopy_uio_daemon endif ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS)) ALL_SCRIPTS := hv_get_dhcp_info.sh hv_get_dns_info.sh hv_set_ifconfig.sh -all: $(ALL_PROGRAMS) +all: info $(ALL_PROGRAMS)
tools/hv/Makefile override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include · line 41
Quoted 10 lines
tools/hv/Makefile +7
-0export srctree OUTPUT CC LD CFLAGS include $(srctree)/tools/build/Makefile.include +info: + @echo "---------------------" + @echo "Building for:" + @echo "CC $(CC)" + @echo "LD $(LD)" + @echo "ARCH $(ARCH)" + @echo "---------------------"
I don't think this is needed. Anyone who's building the kernel source should know what tool chain they are using and architecture they're building for.
Thanks,
Wei.
Quoted 7 lines
tools/hv/Makefile +1
-0+ HV_KVP_DAEMON_IN := $(OUTPUT)hv_kvp_daemon-in.o $(HV_KVP_DAEMON_IN): FORCE $(Q)$(MAKE) $(build)=hv_kvp_daemonSignature · 1 line
2.43.0
Quoted 33 lines · Wei Liu
Quoted 32 lines · Saurabh Sengar
Use the native ARCH only incase it is not set, this will allow the cross complilation where ARCH is explicitly set. Add few info prints as well to know what arch and toolchain is getting used to build it.
Additionally, simplify the check for ARCH so that fcopy daemon is build only for
x86_64.Fixes 82b0945ce2c2 ("tools: hv: Add new fcopy application based on uio driver")Reported-by Adrian Vladu <[email protected]>Signed-off-by Saurabh Sengar <[email protected]>--- tools/hv/Makefile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)tools/hv/Makefile +1
-1@@ -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,18 +20,26 @@ override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include override CFLAGS += -Wno-address-of-packed-member
Quoted 6 lines
tools/hv/Makefile override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include · line 23
Quoted 3 lines
tools/hv/Makefile +1
-1ALL_TARGETS := hv_kvp_daemon hv_vss_daemon -ifneq ($(ARCH), aarch64) +ifeq ($(ARCH), x86_64)Technically speaking, you can also build this for x86 (32bit). Whether anybody uses it is another question.
My intention is to allow fcopy daemon build only for the arch it has been tested. IMO its better than restricting only for arm64/aarch64.
I tried with gcc '-m32' switch which I believe is for 32 bit x86 compilation I see problems with it on other (kvp daemon) daemons too. I think we never cared about 32 bit.
saurabh@Saurabh:/work/linux-next/tools/hv$ make ARCH=x86 CFLAGS=-m32
make[1]: Entering directory '/work/linux-next/tools/hv'
CC hv_kvp_daemon.o
hv_kvp_daemon.c:25:10: fatal error: sys/poll.h: No such file or directory
25 | #include <sys/poll.h>
| ^~~~~~~~~~~~
compilation terminated.
make[1]: *** [/work/linux-next/tools/build/Makefile.build:106: hv_kvp_daemon.o] Error 1
make[1]: Leaving directory '/work/linux-next/tools/hv'
make: *** [Makefile:37: hv_kvp_daemon-in.o] Error 2I don't have any strong opinion here, if you want I can allow x86 compilation for fcopy daemon as well.
Please let me know what is your preference.
Quoted 13 lines
Quoted 13 lines
tools/hv/Makefile +1
-1ALL_TARGETS += hv_fcopy_uio_daemon endif ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS)) ALL_SCRIPTS := hv_get_dhcp_info.sh hv_get_dns_info.sh hv_set_ifconfig.sh -all: $(ALL_PROGRAMS) +all: info $(ALL_PROGRAMS) export srctree OUTPUT CC LD CFLAGS include $(srctree)/tools/build/Makefile.include
Quoted 11 lines
tools/hv/Makefile override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include · line 41
Quoted 7 lines
tools/hv/Makefile +7
-0+info: + @echo "---------------------" + @echo "Building for:" + @echo "CC $(CC)" + @echo "LD $(LD)" + @echo "ARCH $(ARCH)" + @echo "---------------------"I don't think this is needed. Anyone who's building the kernel source should know what tool chain they are using and architecture they're building for.
I am fine removing it in V2.
- Saurabh
Wei Liu
maintainerQuoted 60 lines · Saurabh Singh Sengar
Quoted 33 lines · Wei Liu
Quoted 32 lines · Saurabh Sengar
Use the native ARCH only incase it is not set, this will allow the cross complilation where ARCH is explicitly set. Add few info prints as well to know what arch and toolchain is getting used to build it.
Additionally, simplify the check for ARCH so that fcopy daemon is build only for
x86_64.Fixes 82b0945ce2c2 ("tools: hv: Add new fcopy application based on uio driver")Reported-by Adrian Vladu <[email protected]>Signed-off-by Saurabh Sengar <[email protected]>--- tools/hv/Makefile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)tools/hv/Makefile +1
-1@@ -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,18 +20,26 @@ override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include override CFLAGS += -Wno-address-of-packed-memberQuoted 6 lines
tools/hv/Makefile override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include · line 23
Quoted 3 lines
tools/hv/Makefile +1
-1ALL_TARGETS := hv_kvp_daemon hv_vss_daemon -ifneq ($(ARCH), aarch64) +ifeq ($(ARCH), x86_64)Technically speaking, you can also build this for x86 (32bit). Whether anybody uses it is another question.
My intention is to allow fcopy daemon build only for the arch it has been tested. IMO its better than restricting only for arm64/aarch64.
I tried with gcc '-m32' switch which I believe is for 32 bit x86 compilation I see problems with it on other (kvp daemon) daemons too. I think we never cared about 32 bit.
saurabh@Saurabh:/work/linux-next/tools/hv$ make ARCH=x86 CFLAGS=-m32 make[1]: Entering directory '/work/linux-next/tools/hv' CC hv_kvp_daemon.o hv_kvp_daemon.c:25:10: fatal error: sys/poll.h: No such file or directory 25 | #include <sys/poll.h> | ^~~~~~~~~~~~ compilation terminated. make[1]: *** [/work/linux-next/tools/build/Makefile.build:106: hv_kvp_daemon.o] Error 1 make[1]: Leaving directory '/work/linux-next/tools/hv' make: *** [Makefile:37: hv_kvp_daemon-in.o] Error 2
Quoted 4 lines
I don't have any strong opinion here, if you want I can allow x86 compilation for fcopy daemon as well.
Please let me know what is your preference.
We can leave the code as-is. If and when someone wants to build this for 32-bit x86, they can fix the code.
I think the number of people who want to build this for 32-bit x86 is diminishing by the day -- it there was a large group in the first place.
Thanks,
Wei.
Thanks, LGTM!
Quoted 58 lines · Saurabh Sengar
Use the native ARCH only incase it is not set, this will allow the cross complilation where ARCH is explicitly set. Add few info prints as well to know what arch and toolchain is getting used to build it.
Additionally, simplify the check for ARCH so that fcopy daemon is build only for
x86_64.Fixes 82b0945ce2c2 ("tools: hv: Add new fcopy application based on uio driver")Reported-by Adrian Vladu <[email protected]>Signed-off-by Saurabh Sengar <[email protected]>--- tools/hv/Makefile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)tools/hv/Makefile +11
-3@@ -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,18 +20,26 @@ 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)) ALL_SCRIPTS := hv_get_dhcp_info.sh hv_get_dns_info.sh hv_set_ifconfig.sh -all: $(ALL_PROGRAMS) +all: info $(ALL_PROGRAMS) export srctree OUTPUT CC LD CFLAGS include $(srctree)/tools/build/Makefile.include +info: + @echo "---------------------" + @echo "Building for:" + @echo "CC $(CC)" + @echo "LD $(LD)" + @echo "ARCH $(ARCH)" + @echo "---------------------" + HV_KVP_DAEMON_IN := $(OUTPUT)hv_kvp_daemon-in.o $(HV_KVP_DAEMON_IN): FORCE $(Q)$(MAKE) $(build)=hv_kvp_daemon
Signature · 2 lines
Thank you, Roman
Adrian Vladu
Reviewed-by Roman KiselThanks for the refined patch, much appreciated.
For Flatcar Container Linux, we would like to use 6.12 kernel, would be great to have this fix backported to the stable branch 6.12.
________________________________________
From: Roman Kisel <[email protected]>
Sent: Friday, December 13, 2024 8:11 PM
To: Saurabh Sengar <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> Cc: [email protected] <[email protected]>; Adrian Vladu <[email protected]>
Subject: Re: [PATCH] tools: hv: Fix cross-compilation
Thanks, LGTM!
Quoted 55 lines · Saurabh Sengar
Use the native ARCH only incase it is not set, this will allow the cross complilation where ARCH is explicitly set. Add few info prints as well to know what arch and toolchain is getting used to build it.
Additionally, simplify the check for ARCH so that fcopy daemon is build only for
x86_64.Fixes 82b0945ce2c2 ("tools: hv: Add new fcopy application based on uio driver")Reported-by Adrian Vladu <[email protected]>Signed-off-by Saurabh Sengar <[email protected]>---
tools/hv/Makefile| 14 +++++++++++---1 file changed, 11 insertions(+), 3 deletions(-)tools/hv/Makefile +0
-0@@ -2,7 +2,7 @@ # Makefile for Hyper-V toolsinclude ../scripts/Makefile.include
tools/hv/Makefile +1
-1-ARCH := $(shell uname -m 2>/dev/null) +ARCH ?= $(shell uname -m 2>/dev/null)sbindir ?=
/usr/sbin
libexecdir ?=/usr/libexec
sharedstatedir ?=/var/libtools/hv/Makefile +0
-0@@ -20,18 +20,26 @@ override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)includeoverride CFLAGS += -Wno-address-of-packed-member
ALL_TARGETS:=hv_kvp_daemonhv_vss_daemontools/hv/Makefile +1
-1-ifneq ($(ARCH), aarch64) +ifeq ($(ARCH), x86_64)
ALL_TARGETS+=hv_fcopy_uio_daemon
endif
ALL_PROGRAMS:= $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
ALL_SCRIPTS:=hv_get_dhcp_info.shhv_get_dns_info.shhv_set_ifconfig.shtools/hv/Makefile +1
-1-all: $(ALL_PROGRAMS) +all: info $(ALL_PROGRAMS)
export srctree OUTPUT CC LD CFLAGS include $(srctree)/tools/build/Makefile.includetools/hv/Makefile +8
-0+info: + @echo "---------------------" + @echo "Building for:" + @echo "CC $(CC)" + @echo "LD $(LD)" + @echo "ARCH $(ARCH)" + @echo "---------------------" +
Quoted 3 lines
HV_KVP_DAEMON_IN:= $(OUTPUT)hv_kvp_daemon-in.o $(HV_KVP_DAEMON_IN): FORCE
$(Q)$(MAKE) $(build)=hv_kvp_daemon
--
Thank you,
Roman