qmk / qmk_firmware

Open-source keyboard firmware for Atmel AVR and Arm USB families
https://qmk.fm
GNU General Public License v2.0
18.24k stars 39.3k forks source link

[Bug] Crkbd firmware will not link #9147

Closed soweliniko closed 4 years ago

soweliniko commented 4 years ago

Describe the Bug

When I try and build the crkbd default firmware (make crkbd:default) it will not link, giving me this error:

Linking: .build/crkbd_rev1_default.elf                                                              [ERRORS]
 | 
 | /usr/bin/avr-ld: .build/obj_crkbd_rev1_default/./lib/layer_state_reader.o:/home/nihilazo/projects/qmk_firmware/keyboards/crkbd/ssd1306.h:68: multiple definition of `display'; .build/obj_crkbd_rev1_default/ssd1306.o:/home/nihilazo/projects/qmk_firmware/keyboards/crkbd/ssd1306.h:68: first defined here
 | /usr/bin/avr-ld: .build/obj_crkbd_rev1_default/./lib/logo_reader.o:/home/nihilazo/projects/qmk_firmware/keyboards/crkbd/ssd1306.h:68: multiple definition of `display'; .build/obj_crkbd_rev1_default/ssd1306.o:/home/nihilazo/projects/qmk_firmware/keyboards/crkbd/ssd1306.h:68: first defined here
 | /usr/bin/avr-ld: .build/obj_crkbd_rev1_default/./lib/keylogger.o:/home/nihilazo/projects/qmk_firmware/keyboards/crkbd/ssd1306.h:68: multiple definition of `display'; .build/obj_crkbd_rev1_default/ssd1306.o:/home/nihilazo/projects/qmk_firmware/keyboards/crkbd/ssd1306.h:68: first defined here
 | /usr/bin/avr-ld: .build/obj_crkbd_rev1_default/keyboards/crkbd/crkbd.o:/home/nihilazo/projects/qmk_firmware/keyboards/crkbd/ssd1306.h:68: multiple definition of `display'; .build/obj_crkbd_rev1_default/ssd1306.o:/home/nihilazo/projects/qmk_firmware/keyboards/crkbd/ssd1306.h:68: first defined here
 | /usr/bin/avr-ld: .build/obj_crkbd_rev1_default/keyboards/crkbd/rev1/rev1.o:/home/nihilazo/projects/qmk_firmware/keyboards/crkbd/ssd1306.h:68: multiple definition of `display'; .build/obj_crkbd_rev1_default/ssd1306.o:/home/nihilazo/projects/qmk_firmware/keyboards/crkbd/ssd1306.h:68: first defined here
 | /usr/bin/avr-ld: .build/obj_crkbd_rev1_default/keyboards/crkbd/keymaps/default/keymap.o:/home/nihilazo/projects/qmk_firmware/keyboards/crkbd/ssd1306.h:68: multiple definition of `display'; .build/obj_crkbd_rev1_default/ssd1306.o:/home/nihilazo/projects/qmk_firmware/keyboards/crkbd/ssd1306.h:68: first defined here
 | collect2: error: ld returned 1 exit status
 | 
make[1]: *** [tmk_core/rules.mk:306: .build/crkbd_rev1_default.elf] Error 1
Make finished with errors

This does not happen with other crkbd keymaps, nor with firmware for other keyboards.

System Information

zvecr commented 4 years ago

Seems to be an issue with avr-gcc 10, which we avoid in the install scripts by forcing 8.3 https://github.com/qmk/qmk_firmware/blob/master/util/linux_install.sh#L80.

Changing where display is created allows the build to pass (however ive not tested this at runtime)

diff --git a/keyboards/crkbd/ssd1306.c b/keyboards/crkbd/ssd1306.c
index 20c2738db..ea91ab129 100644
--- a/keyboards/crkbd/ssd1306.c
+++ b/keyboards/crkbd/ssd1306.c
@@ -13,6 +13,8 @@
 #include "sendchar.h"
 #include "timer.h"

+struct CharacterMatrix display;
+
 extern const unsigned char font[] PROGMEM;

 // Set this to 1 to help diagnose early startup problems
diff --git a/keyboards/crkbd/ssd1306.h b/keyboards/crkbd/ssd1306.h
index ea8c92328..8b83085d0 100644
--- a/keyboards/crkbd/ssd1306.h
+++ b/keyboards/crkbd/ssd1306.h
@@ -66,7 +66,7 @@ struct CharacterMatrix {
   bool dirty;
 };

-struct CharacterMatrix display;
+extern struct CharacterMatrix display;

 bool iota_gfx_init(bool rotate);
 void iota_gfx_task(void);