Skip to contentSkip to conversation

ppc: qtest already exports qtest_rtas_call()

PATCH In review Juan Quintela 4 participants 6 messages Oct 30, 2023 – Nov 7, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppc: qtest already exports qtest_rtas_call()

Having two functions with the same name is a bad idea. As spapr only uses the function locally, made it static.

When you compile with clang, you get this compilation error:

/usr/bin/ld: tests/qtest/libqos/libqos.fa.p/.._libqtest.c.o: in function `qtest_rtas_call':
/scratch/qemu/clang/full/all/../../../../../mnt/code/qemu/full/tests/qtest/libqtest.c:1195: multiple definition of `qtest_rtas_call'; libqemu-ppc64-softmmu.fa.p/hw_ppc_spapr_rtas.c.o:/scratch/qemu/clang/full/all/../../../../../mnt/code/qemu/full/hw/ppc/spapr_rtas.c:536: first defined here
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
make: *** [Makefile:162: run-ninja] Error 1

---
 include/hw/ppc/spapr_rtas.h | 10 ----------
 hw/ppc/spapr_rtas.c         |  4 ++--
 2 files changed, 2 insertions(+), 12 deletions(-)
 delete mode 100644 include/hw/ppc/spapr_rtas.h
include/hw/ppc/spapr_rtas.h deleted +0 -10
deleted file mode 100644
index 383611f10f..0000000000
@@ -1,10 +0,0 @@
-#ifndef HW_SPAPR_RTAS_H
-#define HW_SPAPR_RTAS_H
-/*
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-uint64_t qtest_rtas_call(char *cmd, uint32_t nargs, uint64_t args,
-                         uint32_t nret, uint64_t rets);
-#endif /* HW_SPAPR_RTAS_H */
hw/ppc/spapr_rtas.c +2 -2
index 26c384b261..cec01b2c92 100644
@@ -531,8 +531,8 @@ target_ulong spapr_rtas_call(PowerPCCPU *cpu, SpaprMachineState *spapr,
     return H_PARAMETER;
 }
 
-uint64_t qtest_rtas_call(char *cmd, uint32_t nargs, uint64_t args,
-                         uint32_t nret, uint64_t rets)
+static uint64_t qtest_rtas_call(char *cmd, uint32_t nargs, uint64_t args,
+                                uint32_t nret, uint64_t rets)
 {
     int token;
 
Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Juan Quintela

Having two functions with the same name is a bad idea. As spapr only uses the function locally, made it static.

When you compile with clang, you get this compilation error:

Quoted 7 lines

/usr/bin/ld: tests/qtest/libqos/libqos.fa.p/.._libqtest.c.o: in function `qtest_rtas_call':
/scratch/qemu/clang/full/all/../../../../../mnt/code/qemu/full/tests/qtest/libqtest.c:1195: multiple definition of `qtest_rtas_call'; libqemu-ppc64-softmmu.fa.p/hw_ppc_spapr_rtas.c.o:/scratch/qemu/clang/full/all/../../../../../mnt/code/qemu/full/hw/ppc/spapr_rtas.c:536: first defined here
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
make: *** [Makefile:162: run-ninja] Error 1

Thanks,

C.

Quoted 37 lines
---
  include/hw/ppc/spapr_rtas.h | 10 ----------
  hw/ppc/spapr_rtas.c         |  4 ++--
  2 files changed, 2 insertions(+), 12 deletions(-)

delete mode 100644 include/hw/ppc/spapr_rtas.h

include/hw/ppc/spapr_rtas.h deleted +0 -10
deleted file mode 100644
index 383611f10f..0000000000
@@ -1,10 +0,0 @@
-#ifndef HW_SPAPR_RTAS_H
-#define HW_SPAPR_RTAS_H
-/*
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-uint64_t qtest_rtas_call(char *cmd, uint32_t nargs, uint64_t args,
-                         uint32_t nret, uint64_t rets);
-#endif /* HW_SPAPR_RTAS_H */
hw/ppc/spapr_rtas.c +2 -2
index 26c384b261..cec01b2c92 100644
@@ -531,8 +531,8 @@ target_ulong spapr_rtas_call(PowerPCCPU *cpu, SpaprMachineState *spapr,
      return H_PARAMETER;
  }
 
-uint64_t qtest_rtas_call(char *cmd, uint32_t nargs, uint64_t args,
-                         uint32_t nret, uint64_t rets)
+static uint64_t qtest_rtas_call(char *cmd, uint32_t nargs, uint64_t args,
+                                uint32_t nret, uint64_t rets)
  {
      int token;
 
#2 lore raw
Quoted 12 lines · Cédric le Goater
Quoted 11 lines · Juan Quintela

Having two functions with the same name is a bad idea. As spapr only uses the function locally, made it static.

When you compile with clang, you get this compilation error:

/usr/bin/ld: tests/qtest/libqos/libqos.fa.p/.._libqtest.c.o: in function `qtest_rtas_call':
/scratch/qemu/clang/full/all/../../../../../mnt/code/qemu/full/tests/qtest/libqtest.c:1195: multiple definition of `qtest_rtas_call'; libqemu-ppc64-softmmu.fa.p/hw_ppc_spapr_rtas.c.o:/scratch/qemu/clang/full/all/../../../../../mnt/code/qemu/full/hw/ppc/spapr_rtas.c:536: first defined here
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
make: *** [Makefile:162: run-ninja] Error 1

Quoted 4 lines
Quoted 1 line

I think changing the name of one of the functions would be even better. Making it static means it won't confuse the compiler, but it can still confuse people.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#3 lore raw
Quoted 16 lines · David Gibson
Quoted 15 lines · Cédric le Goater
Quoted 14 lines · Juan Quintela

Having two functions with the same name is a bad idea. As spapr only uses the function locally, made it static.

When you compile with clang, you get this compilation error:

/usr/bin/ld: tests/qtest/libqos/libqos.fa.p/.._libqtest.c.o: in function `qtest_rtas_call':
/scratch/qemu/clang/full/all/../../../../../mnt/code/qemu/full/tests/qtest/libqtest.c:1195:
multiple definition of `qtest_rtas_call'; libqemu-ppc64-softmmu.fa.p/hw_ppc_spapr_rtas.c.o:/scratch/qemu/clang/full/all/../../../../../mnt/code/qemu/full/hw/ppc/spapr_rtas.c:536:
first defined here
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
make: *** [Makefile:162: run-ninja] Error 1

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

I think changing the name of one of the functions would be even better. Making it static means it won't confuse the compiler, but it can still confuse people.

I think that made it static when it is not used anywhere else is a good idea.

After that, I don't understand it enough to make a rename that makes sense.

This patch is the typical fix for "make all" with clang fails here. I let ppc maintainers to do anything more sensible.

Later, Juan.

#4 lore raw
Quoted 17 lines · Juan Quintela
Quoted 16 lines · David Gibson
Quoted 15 lines · Cédric le Goater
Quoted 14 lines · Juan Quintela

Having two functions with the same name is a bad idea. As spapr only uses the function locally, made it static.

When you compile with clang, you get this compilation error:

/usr/bin/ld: tests/qtest/libqos/libqos.fa.p/.._libqtest.c.o: in function `qtest_rtas_call':
/scratch/qemu/clang/full/all/../../../../../mnt/code/qemu/full/tests/qtest/libqtest.c:1195:
multiple definition of `qtest_rtas_call'; libqemu-ppc64-softmmu.fa.p/hw_ppc_spapr_rtas.c.o:/scratch/qemu/clang/full/all/../../../../../mnt/code/qemu/full/hw/ppc/spapr_rtas.c:536:
first defined here
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
make: *** [Makefile:162: run-ninja] Error 1

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

I think changing the name of one of the functions would be even better. Making it static means it won't confuse the compiler, but it can still confuse people.

Since it is a spapr file, something like :

static uint64_t spapr_qtest_rtas_call(...)

?

Thanks,

C.

Quoted 11 lines

I think that made it static when it is not used anywhere else is a good idea.

After that, I don't understand it enough to make a rename that makes sense.

This patch is the typical fix for "make all" with clang fails here. I let ppc maintainers to do anything more sensible.

Later, Juan.

#5 lore raw
In reply to Juan Quintela

Queue in ppc-next after amending this in:

$ git diff
hw/ppc/spapr_rtas.c +0 -1
index cec01b2c92..f329693c55 100644
@@ -38,7 +38,6 @@
 
 #include "hw/ppc/spapr.h"
 #include "hw/ppc/spapr_vio.h"
-#include "hw/ppc/spapr_rtas.h"
 #include "hw/ppc/spapr_cpu_core.h"
 #include "hw/ppc/ppc.h"
 

Gitlab complained that we were including a non-existing header.

Thanks,

Daniel

Quoted 49 lines · Juan Quintela

Having two functions with the same name is a bad idea. As spapr only uses the function locally, made it static.

When you compile with clang, you get this compilation error:

/usr/bin/ld: tests/qtest/libqos/libqos.fa.p/.._libqtest.c.o: in function `qtest_rtas_call':
/scratch/qemu/clang/full/all/../../../../../mnt/code/qemu/full/tests/qtest/libqtest.c:1195: multiple definition of `qtest_rtas_call'; libqemu-ppc64-softmmu.fa.p/hw_ppc_spapr_rtas.c.o:/scratch/qemu/clang/full/all/../../../../../mnt/code/qemu/full/hw/ppc/spapr_rtas.c:536: first defined here
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
make: *** [Makefile:162: run-ninja] Error 1

---
  include/hw/ppc/spapr_rtas.h | 10 ----------
  hw/ppc/spapr_rtas.c         |  4 ++--
  2 files changed, 2 insertions(+), 12 deletions(-)

delete mode 100644 include/hw/ppc/spapr_rtas.h

include/hw/ppc/spapr_rtas.h deleted +0 -10
deleted file mode 100644
index 383611f10f..0000000000
@@ -1,10 +0,0 @@
-#ifndef HW_SPAPR_RTAS_H
-#define HW_SPAPR_RTAS_H
-/*
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-uint64_t qtest_rtas_call(char *cmd, uint32_t nargs, uint64_t args,
-                         uint32_t nret, uint64_t rets);
-#endif /* HW_SPAPR_RTAS_H */
hw/ppc/spapr_rtas.c +2 -2
index 26c384b261..cec01b2c92 100644
@@ -531,8 +531,8 @@ target_ulong spapr_rtas_call(PowerPCCPU *cpu, SpaprMachineState *spapr,
      return H_PARAMETER;
  }
 
-uint64_t qtest_rtas_call(char *cmd, uint32_t nargs, uint64_t args,
-                         uint32_t nret, uint64_t rets)
+static uint64_t qtest_rtas_call(char *cmd, uint32_t nargs, uint64_t args,
+                                uint32_t nret, uint64_t rets)
  {
      int token;