Skip to contentSkip to conversation

tests/vpci: Use $(CC) instead of $(HOSTCC)

PATCH Superseded Michal Orzel 4 participants 10 messages Jun 2, 2025 – Jun 3, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/vpci: Use $(CC) instead of $(HOSTCC)

These tests are supposed to run on target. HOSTCC can be different than CC (when cross-compiling). At the moment, tests installation would put a binary of a wrong format in the destdir.

Fixes e90580f25bd7 ("vpci: introduce basic handlers to trap accesses to the PCI config space")
---
 tools/tests/vpci/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tests/vpci/Makefile +1 -1
index 9450f7593a41..1101a669e118 100644
@@ -11,7 +11,7 @@ run: $(TARGET)
 	./$(TARGET)
 
 $(TARGET): vpci.c vpci.h list.h main.c emul.h
-	$(HOSTCC) $(CFLAGS_xeninclude) -g -o $@ vpci.c main.c
+	$(CC) $(CFLAGS_xeninclude) -g -o $@ vpci.c main.c
 
 .PHONY: clean
 clean:
Signature · 1 line
2.25.1
#1 lore raw
Quoted 6 lines · Michal Orzel

These tests are supposed to run on target. HOSTCC can be different than CC (when cross-compiling). At the moment, tests installation would put a binary of a wrong format in the destdir.

Fixes e90580f25bd7 ("vpci: introduce basic handlers to trap accesses to the PCI config space")

Oh.  This didn't explode in GitlabCI because there's no ARM version of *-tools-tests-*.

Can we fix that too please, seeing as there is a real ARM board?

Also, I guess we have to finally sort out the CC vs HOSTCC debate.

~Andrew

#2 lore raw
Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Michal Orzel

These tests are supposed to run on target. HOSTCC can be different than CC (when cross-compiling). At the moment, tests installation would put a binary of a wrong format in the destdir.

Quoted 7 lines
Quoted 2 lines
Fixes e90580f25bd7 ("vpci: introduce basic handlers to trap accesses to the PCI config space")

Oh.  This didn't explode in GitlabCI because there's no ARM version of *-tools-tests-*.

Can we fix that too please, seeing as there is a real ARM board?

We will add it to our TODO.

Quoted 4 lines

Also, I guess we have to finally sort out the CC vs HOSTCC debate.

~Andrew

~Michal

#3 lore raw
In reply to Andrew Cooper
Quoted 8 lines · Andrew Cooper
Quoted 6 lines · Michal Orzel

These tests are supposed to run on target. HOSTCC can be different than CC (when cross-compiling). At the moment, tests installation would put a binary of a wrong format in the destdir.

Fixes e90580f25bd7 ("vpci: introduce basic handlers to trap accesses to the PCI config space")
Quoted 6 lines

Oh.  This didn't explode in GitlabCI because there's no ARM version of *-tools-tests-*.

Can we fix that too please, seeing as there is a real ARM board?

Also, I guess we have to finally sort out the CC vs HOSTCC debate.

I think the situation here makes pretty clear that HOSTCC is almost always wrong to use for tests/. The emulator test harness is special in that it (in principle) needs a target compiler (CC) and additionally an x86 one (with no present representation). The present way of (partly) distinguishing the two by using CC and HOSTCC was assigning wrong meaning to one (perhaps both) of them. The (or maybe just my) problem is that in the toolchain world it is build, host, and target which are distinguished. As per Michal's description my understanding is that HOSTCC is matching "build" there, not "host".

Jan

#4 lore raw
Quoted 14 lines · Jan Beulich
Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Michal Orzel

These tests are supposed to run on target. HOSTCC can be different than CC (when cross-compiling). At the moment, tests installation would put a binary of a wrong format in the destdir.

Quoted 8 lines
Quoted 2 lines
Fixes e90580f25bd7 ("vpci: introduce basic handlers to trap accesses to the PCI config space")

Oh.  This didn't explode in GitlabCI because there's no ARM version of *-tools-tests-*.

Can we fix that too please, seeing as there is a real ARM board?

Also, I guess we have to finally sort out the CC vs HOSTCC debate.

Quoted 8 lines

I think the situation here makes pretty clear that HOSTCC is almost always wrong to use for tests/. The emulator test harness is special in that it (in principle) needs a target compiler (CC) and additionally an x86 one (with no present representation). The present way of (partly) distinguishing the two by using CC and HOSTCC was assigning wrong meaning to one (perhaps both) of them. The (or maybe just my) problem is that in the toolchain world it is build, host, and target which are distinguished. As per Michal's description my understanding is that HOSTCC is matching "build" there, not "host".

vPCI is a true unit test.  It can be run in the build environment. Installing it here was to get it run somewhere.

x86_emulator is weird.  It can be run in the build environment, but it is also dependent on CPUID so wants running on target environments too.

Everything else (IIRC) needs a real dom0 to run in, because they make hypercalls.

~Andrew

#5 lore raw
In reply to Jan Beulich
Quoted 16 lines · Jan Beulich
Quoted 8 lines · Andrew Cooper
Quoted 6 lines · Michal Orzel

These tests are supposed to run on target. HOSTCC can be different than CC (when cross-compiling). At the moment, tests installation would put a binary of a wrong format in the destdir.

Fixes e90580f25bd7 ("vpci: introduce basic handlers to trap accesses to the PCI config space")
Quoted 6 lines

Oh.  This didn't explode in GitlabCI because there's no ARM version of *-tools-tests-*.

Can we fix that too please, seeing as there is a real ARM board?

Also, I guess we have to finally sort out the CC vs HOSTCC debate.

Quoted 8 lines

I think the situation here makes pretty clear that HOSTCC is almost always wrong to use for tests/. The emulator test harness is special in that it (in principle) needs a target compiler (CC) and additionally an x86 one (with no present representation). The present way of (partly) distinguishing the two by using CC and HOSTCC was assigning wrong meaning to one (perhaps both) of them. The (or maybe just my) problem is that in the toolchain world it is build, host, and target which are distinguished. As per Michal's description my understanding is that HOSTCC is matching "build" there, not "host".

Yes, I found this issue while building latest Xen with Yocto. Build is x86, host is Arm. HOSTCC is x86 gcc, CC is Arm gcc.

I take as this patch is waiting for a maintainer tag? Not that it needs to wait for some generic cleanup?

~Michal

#6 lore raw
In reply to Michal Orzel
Quoted 15 lines · Michal Orzel

These tests are supposed to run on target. HOSTCC can be different than CC (when cross-compiling). At the moment, tests installation would put a binary of a wrong format in the destdir.

Fixes e90580f25bd7 ("vpci: introduce basic handlers to trap accesses to the PCI config space")
---
 tools/tests/vpci/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tests/vpci/Makefile +0 -0
index 9450f7593a41..1101a669e118 100644

tools/tests/vpci/Makefile run: $(TARGET) · line 14

Quoted 5 lines
tools/tests/vpci/Makefile +1 -1
@@ -11,7 +11,7 @@ run: $(TARGET)
 	./$(TARGET)
 
 $(TARGET): vpci.c vpci.h list.h main.c emul.h
-	$(HOSTCC) $(CFLAGS_xeninclude) -g -o $@ vpci.c main.c
+	$(CC) $(CFLAGS_xeninclude) -g -o $@ vpci.c main.c

This was already posted in:

https://lore.kernel.org/xen-devel/[email protected]/

And got no feedback.

I'm happy for your change to go in, but you might also consider picking up the run target adjustment part of that previous patch.

Thanks, Roger.

#7 lore raw
Quoted 24 lines · Roger Pau Monné
Quoted 15 lines · Michal Orzel

These tests are supposed to run on target. HOSTCC can be different than CC (when cross-compiling). At the moment, tests installation would put a binary of a wrong format in the destdir.

Fixes e90580f25bd7 ("vpci: introduce basic handlers to trap accesses to the PCI config space")
---
 tools/tests/vpci/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tests/vpci/Makefile +0 -0
index 9450f7593a41..1101a669e118 100644

tools/tests/vpci/Makefile run: $(TARGET) · line 14

Quoted 5 lines
tools/tests/vpci/Makefile +1 -1
@@ -11,7 +11,7 @@ run: $(TARGET)
 	./$(TARGET)
 
 $(TARGET): vpci.c vpci.h list.h main.c emul.h
-	$(HOSTCC) $(CFLAGS_xeninclude) -g -o $@ vpci.c main.c
+	$(CC) $(CFLAGS_xeninclude) -g -o $@ vpci.c main.c

This was already posted in:

Quoted 6 lines

https://lore.kernel.org/xen-devel/[email protected]/

And got no feedback.

I'm happy for your change to go in, but you might also consider picking up the run target adjustment part of that previous patch.

You're the maintainer of this file. You should tell me what I need to do unless you want to wait for Anthony feedback.

~Michal

#8 lore raw
Quoted 9 lines · Michal
Quoted 6 lines · Roger Pau Monné
Quoted 5 lines · Michal Orzel

These tests are supposed to run on target. HOSTCC can be different than CC (when cross-compiling). At the moment, tests installation would put a binary of a wrong format in the destdir.

Fixes e90580f25bd7 ("vpci: introduce basic handlers to trap accesses to the PCI config space")

Hm, it's unclear to me whether this is the correct fixes tag. Previous to:

96a587a05736 tools/tests: Add install target for vPCI

The test was not installed on the host, and hence didn't need to use CC instead of HOSTCC (or at least that's my understating).

Quoted 18 lines
Quoted 18 lines
Quoted 10 lines
---
 tools/tests/vpci/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tests/vpci/Makefile +0 -0
index 9450f7593a41..1101a669e118 100644

tools/tests/vpci/Makefile run: $(TARGET) · line 14

Quoted 5 lines
tools/tests/vpci/Makefile +1 -1
@@ -11,7 +11,7 @@ run: $(TARGET)
 	./$(TARGET)
 
 $(TARGET): vpci.c vpci.h list.h main.c emul.h
-	$(HOSTCC) $(CFLAGS_xeninclude) -g -o $@ vpci.c main.c
+	$(CC) $(CFLAGS_xeninclude) -g -o $@ vpci.c main.c

This was already posted in:

Quoted 8 lines
Quoted 6 lines

https://lore.kernel.org/xen-devel/[email protected]/

And got no feedback.

I'm happy for your change to go in, but you might also consider picking up the run target adjustment part of that previous patch.

You're the maintainer of this file. You should tell me what I need to do unless you want to wait for Anthony feedback.

I would also add the chunk to adjust the run target if you use CC instead of HOSTCC.

Thanks, Roger.

#9 lore raw
Quoted 11 lines · Roger Pau Monné
Quoted 9 lines · Michal
Quoted 6 lines · Roger Pau Monné
Quoted 5 lines · Michal Orzel

These tests are supposed to run on target. HOSTCC can be different than CC (when cross-compiling). At the moment, tests installation would put a binary of a wrong format in the destdir.

Fixes e90580f25bd7 ("vpci: introduce basic handlers to trap accesses to the PCI config space")
Quoted 7 lines

Hm, it's unclear to me whether this is the correct fixes tag. Previous to:

96a587a05736 tools/tests: Add install target for vPCI

The test was not installed on the host, and hence didn't need to use CC instead of HOSTCC (or at least that's my understating).

You're right. Without install target, HOSTCC could make sense there. I'll change the Fixes commit.

Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 11 lines
---
 tools/tests/vpci/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tests/vpci/Makefile +0 -0
index 9450f7593a41..1101a669e118 100644

tools/tests/vpci/Makefile run: $(TARGET) · line 14

Quoted 5 lines
tools/tests/vpci/Makefile +1 -1
@@ -11,7 +11,7 @@ run: $(TARGET)
 	./$(TARGET)
 
 $(TARGET): vpci.c vpci.h list.h main.c emul.h
-	$(HOSTCC) $(CFLAGS_xeninclude) -g -o $@ vpci.c main.c
+	$(CC) $(CFLAGS_xeninclude) -g -o $@ vpci.c main.c

This was already posted in:

https://lore.kernel.org/xen-devel/[email protected]/

And got no feedback.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I'm happy for your change to go in, but you might also consider picking up the run target adjustment part of that previous patch.

You're the maintainer of this file. You should tell me what I need to do unless you want to wait for Anthony feedback.

I would also add the chunk to adjust the run target if you use CC instead of HOSTCC.

Ok, will do.

~Michal