Skip to contentSkip to conversation

arm-coreboot: Declare global struct ps2_state as static so symbols don't cause link failure

PATCH In review Glenn Washburn 2 participants 4 messages Dec 3, 2020 – Dec 4, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm-coreboot: Declare global struct ps2_state as static so symbols don't cause link failure

This appears to be a new issue surfaced by switching from gcc 9.3.0 to 10.1.0 cross compiling toolchain. When linking these two object files together, there is an error generated: "multiple definition of `ps2_state'". This only appears to be an issue when --target=arm-linux-gnueabi and --with-platform=coreboot. There's no need for these structs to have global as opposed to file scope, so declaring them as static fixes this issue.

---
 grub-core/term/arm/cros.c  | 2 +-
 grub-core/term/arm/pl050.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
grub-core/term/arm/cros.c +1 -1
index 1ff9f8ccf..a17e49c32 100644
@@ -30,7 +30,7 @@
 #include <grub/fdtbus.h>
 #include <grub/arm/cros_ec.h>
 
-struct grub_ps2_state ps2_state;
+static struct grub_ps2_state ps2_state;
 
 struct grub_cros_ec_keyscan old_scan;
 
grub-core/term/arm/pl050.c +1 -1
index e4cda3056..b082243b0 100644
@@ -29,7 +29,7 @@
 
 static volatile grub_uint32_t *pl050_regs;
 
-struct grub_ps2_state ps2_state;
+static struct grub_ps2_state ps2_state;
 
 static void
 keyboard_controller_wait_until_ready (void)
Signature · 1 line
2.27.0
#1 lore raw

Here is a log file showing the build failure.

https://gitlab.com/grub2-testing/grub/-/jobs/885372725/raw

Quoted 40 lines · On Thu, 3 Dec 2020 00:10:26 -0600 Glenn Washburn…

This appears to be a new issue surfaced by switching from gcc 9.3.0 to 10.1.0 cross compiling toolchain. When linking these two object files together, there is an error generated: "multiple definition of `ps2_state'". This only appears to be an issue when --target=arm-linux-gnueabi and --with-platform=coreboot. There's no need for these structs to have global as opposed to file scope, so declaring them as static fixes this issue.

---
 grub-core/term/arm/cros.c  | 2 +-
 grub-core/term/arm/pl050.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
grub-core/term/arm/cros.c +1 -1
index 1ff9f8ccf..a17e49c32 100644
@@ -30,7 +30,7 @@
 #include <grub/fdtbus.h>
 #include <grub/arm/cros_ec.h>
 
-struct grub_ps2_state ps2_state;
+static struct grub_ps2_state ps2_state;
 
 struct grub_cros_ec_keyscan old_scan;
 
grub-core/term/arm/pl050.c +1 -1
index e4cda3056..b082243b0 100644
@@ -29,7 +29,7 @@
 
 static volatile grub_uint32_t *pl050_regs;
 
-struct grub_ps2_state ps2_state;
+static struct grub_ps2_state ps2_state;
 
 static void
 keyboard_controller_wait_until_ready (void)
#2 lore raw
Quoted 3 lines · On Thu, 3 Dec 2020 00:15:27 -0600 Glenn Washburn <[email protected]>…

Here is a log file showing the build failure.

https://gitlab.com/grub2-testing/grub/-/jobs/885372725/raw

Accidentally deleted this pipeline. Here's another log with the same error.

https://gitlab.com/grub2-testing/grub/-/jobs/888562636/raw

Quoted 43 lines
Quoted 40 lines · On Thu, 3 Dec 2020 00:10:26 -0600 Glenn Washburn…

This appears to be a new issue surfaced by switching from gcc 9.3.0 to 10.1.0 cross compiling toolchain. When linking these two object files together, there is an error generated: "multiple definition of `ps2_state'". This only appears to be an issue when --target=arm-linux-gnueabi and --with-platform=coreboot. There's no need for these structs to have global as opposed to file scope, so declaring them as static fixes this issue.

---
 grub-core/term/arm/cros.c  | 2 +-
 grub-core/term/arm/pl050.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
grub-core/term/arm/cros.c +1 -1
index 1ff9f8ccf..a17e49c32 100644
@@ -30,7 +30,7 @@
 #include <grub/fdtbus.h>
 #include <grub/arm/cros_ec.h>
 
-struct grub_ps2_state ps2_state;
+static struct grub_ps2_state ps2_state;
 
 struct grub_cros_ec_keyscan old_scan;
 
grub-core/term/arm/pl050.c +1 -1
index e4cda3056..b082243b0 100644
@@ -29,7 +29,7 @@
 
 static volatile grub_uint32_t *pl050_regs;
 
-struct grub_ps2_state ps2_state;
+static struct grub_ps2_state ps2_state;
 
 static void
 keyboard_controller_wait_until_ready (void)
#3 lore raw
In reply to Glenn Washburn
Quoted 7 lines · Glenn Washburn

This appears to be a new issue surfaced by switching from gcc 9.3.0 to 10.1.0 cross compiling toolchain. When linking these two object files together, there is an error generated: "multiple definition of `ps2_state'". This only appears to be an issue when --target=arm-linux-gnueabi and --with-platform=coreboot. There's no need for these structs to have global as opposed to file scope, so declaring them as static fixes this issue.

Quoted 5 lines
---
 grub-core/term/arm/cros.c  | 2 +-
 grub-core/term/arm/pl050.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

The same patch is in this [1] patch series. I will add your SOB there and merge the patches into master next week.

Daniel

[1] https://lists.gnu.org/archive/html/grub-devel/2020-12/msg00044.html