seemoo-lab/owl

Compilation error on GCC 10 due to multiple definitions of __packed

frol opened this issue · 3 comments

frol commented

Starting from the upcoming GCC release 10, the default of -fcommon option will change to -fno-common - this leads to build errors:

[ 51%] Linking C static library libawdl.a
[ 51%] Built target awdl
Scanning dependencies of target owl
[ 54%] Building C object daemon/CMakeFiles/owl.dir/io.c.o
[ 56%] Building C object daemon/CMakeFiles/owl.dir/core.c.o
[ 59%] Building C object daemon/CMakeFiles/owl.dir/netutils.c.o
[ 62%] Building C object daemon/CMakeFiles/owl.dir/owl.c.o
[ 64%] Linking C executable owl
/usr/bin/ld: ../src/libawdl.a(rx.c.o):(.bss+0x0): multiple definition of `__packed'; ../src/libawdl.a(tx.c.o):(.bss+0x0): first defined here
/usr/bin/ld: ../libradiotap.a(radiotap.c.o):(.bss+0x0): multiple definition of `__packed'; ../src/libawdl.a(tx.c.o):(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status

See also:
sahlberg/libiscsi#308
https://bugzilla.suse.com/show_bug.cgi?id=1160276
https://bugzilla.suse.com/show_bug.cgi?id=1160244

removing `__packed' from radiotap/radiotap.h fixed it.

patch:

From 771899b4f78ecfa9fe068015cad3f1783e766c92 Mon Sep 17 00:00:00 2001
From: 3XITLiGHT <x0c_ff@protonmail.com>
Date: Wed, 20 May 2020 07:39:25 +0200
Subject: [PATCH]  radiotap: remove `__packed` from struct
 ieee80211_radiotap_header declaration

Fix compilation error on GCC 10 due to multiple definitions of __packed

Signed-off-by: 3XITLiGHT <x0c_ff@protonmail.com>
---
 radiotap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/radiotap.h b/radiotap.h
index 2055194..b9af740 100644
--- a/radiotap.h
+++ b/radiotap.h
@@ -50,7 +50,7 @@ struct ieee80211_radiotap_header {
 	 * @it_present: (first) present word
 	 */
 	uint32_t it_present;
-} __packed;
+};
 
 /* version is always 0 */
 #define PKTHDR_RADIOTAP_VERSION	0
-- 
2.26.2

This happened for me when installing from AUR, and this patch fixes it. Thanks! My system is on gcc 10.1.0.

This was a problem with radiotap-library as they use __packed instead of __attribute__((__packed__)). My pull request radiotap/radiotap-library#6 was just merged and solves this problem (#32) and #34.