Skip to contentSkip to conversation

x86: fix build with GCC10

PATCH Applied Vitaly Kuznetsov 3 participants 3 messages Jun 17, 2020 – Jun 22, 2020 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: fix build with GCC10

kvm-unit-tests fail to build with GCC10:

/usr/bin/ld: lib/libcflat.a(usermode.o):
./kvm-unit-tests/lib/x86/usermode.c:17: multiple definition of `jmpbuf';
lib/libcflat.a(fault_test.o):
./kvm-unit-tests/lib/x86/fault_test.c:3: first defined here

It seems that 'jmpbuf' doesn't need to be global in either of these files, make it static in both.

---
 lib/x86/fault_test.c | 2 +-
 lib/x86/usermode.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
lib/x86/fault_test.c +1 -1
index 078dae3da640..e15a21864562 100644
@@ -1,6 +1,6 @@
 #include "fault_test.h"
 
-jmp_buf jmpbuf;
+static jmp_buf jmpbuf;
 
 static void restore_exec_to_jmpbuf(void)
 {
lib/x86/usermode.c +1 -1
index f01ad9be1799..f0325236dd05 100644
@@ -14,7 +14,7 @@
 #define USERMODE_STACK_SIZE	0x2000
 #define RET_TO_KERNEL_IRQ	0x20
 
-jmp_buf jmpbuf;
+static jmp_buf jmpbuf;
 
 static void restore_exec_to_jmpbuf(void)
 {
Signature · 1 line
2.25.4
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 11 lines · On Wed, 17 Jun 2020 17:21:24 +0200 Vitaly Kuznetsov <[email protected]> wrote:

kvm-unit-tests fail to build with GCC10:

/usr/bin/ld: lib/libcflat.a(usermode.o):
./kvm-unit-tests/lib/x86/usermode.c:17: multiple definition of
`jmpbuf'; lib/libcflat.a(fault_test.o):
./kvm-unit-tests/lib/x86/fault_test.c:3: first defined here

It seems that 'jmpbuf' doesn't need to be global in either of these files, make it static in both.

I stumbled upon the same issue, and I had independently tested this exact solution :)

Quoted 30 lines
---
 lib/x86/fault_test.c | 2 +-
 lib/x86/usermode.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
lib/x86/fault_test.c +1 -1
index 078dae3da640..e15a21864562 100644
@@ -1,6 +1,6 @@
 #include "fault_test.h"
 
-jmp_buf jmpbuf;
+static jmp_buf jmpbuf;
 
 static void restore_exec_to_jmpbuf(void)
 {
lib/x86/usermode.c +1 -1
index f01ad9be1799..f0325236dd05 100644
@@ -14,7 +14,7 @@
 #define USERMODE_STACK_SIZE	0x2000
 #define RET_TO_KERNEL_IRQ	0x20
 
-jmp_buf jmpbuf;
+static jmp_buf jmpbuf;
 
 static void restore_exec_to_jmpbuf(void)
 {
maintainer Applied
#2 lore raw
In reply to Vitaly Kuznetsov
Quoted 34 lines · Vitaly Kuznetsov

kvm-unit-tests fail to build with GCC10:

/usr/bin/ld: lib/libcflat.a(usermode.o):
./kvm-unit-tests/lib/x86/usermode.c:17: multiple definition of `jmpbuf';
lib/libcflat.a(fault_test.o):
./kvm-unit-tests/lib/x86/fault_test.c:3: first defined here

It seems that 'jmpbuf' doesn't need to be global in either of these files, make it static in both.

---
 lib/x86/fault_test.c | 2 +-
 lib/x86/usermode.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
lib/x86/fault_test.c +1 -1
index 078dae3da640..e15a21864562 100644
@@ -1,6 +1,6 @@
 #include "fault_test.h"
 
-jmp_buf jmpbuf;
+static jmp_buf jmpbuf;
 
 static void restore_exec_to_jmpbuf(void)
 {
lib/x86/usermode.c +0 -0
index f01ad9be1799..f0325236dd05 100644

lib/x86/usermode.c line 20

Quoted 8 lines
lib/x86/usermode.c +1 -1
@@ -14,7 +14,7 @@
 #define USERMODE_STACK_SIZE	0x2000
 #define RET_TO_KERNEL_IRQ	0x20
 
-jmp_buf jmpbuf;
+static jmp_buf jmpbuf;
 
 static void restore_exec_to_jmpbuf(void)
 {

Applied, thanks.

Paolo