fix multiple definition linking error due to missing extern
PATCH 1/1 fix multiple definition linking error due to missing extern
GCC 10+ defaults to -fno-common, which enforces proper declaration of external references using "extern". without this change a link would fail with:
lib/raid6/test/algos.c:28: multiple definition of `raid6_call'; lib/raid6/test/test.c:22: first defined here
--- lib/raid6/test/test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/raid6/test/test.c +1 -1
@@ -19,7 +19,7 @@#define NDISKS 16/* Including P and Q */ const char raid6_empty_zero_page[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); -struct raid6_calls raid6_call; +extern struct raid6_calls raid6_call;char *dataptrs[NDISKS ]; char data[NDISKS][PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
Signature · 1 line
2.35.1
Dear Dirk,
Am 06.02.22 um 21:51 schrieb Dirk Müller:
It’d be great of you added a prefix in the commit message summary. Maybe:
Quoted 4 lines
lib/raid6/test: fix multiple definition linking error due to missing externGCC 10+ defaults to -fno-common, which enforces proper declaration of external references using "extern". without this change a link would
Nit: Without
Quoted 6 lines
fail with:
lib/raid6/test/algos.c:28: multiple definition of `raid6_call';lib/raid6/test/test.c:22: first defined hereSigned-off-by Dirk Müller <[email protected]>
Thank you for properly analyzing and fixing it in a better way than my (non-working) attempt [1].
Should it be tagged for the stable series, that means CC’ed to <[email protected]>?
Quoted 9 lines
--- lib/raid6/test/test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/raid6/test/test.c +0
-0
lib/raid6/test/test.c line 25
Quoted 8 lines
lib/raid6/test/test.c +1
-1@@ -19,7 +19,7 @@#define NDISKS 16/* Including P and Q */ const char raid6_empty_zero_page[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); -struct raid6_calls raid6_call; +extern struct raid6_calls raid6_call;char *dataptrs[NDISKS ]; char data[NDISKS][PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
Kind regards,
Paul
[1]: https://lore.kernel.org/linux-raid/[email protected]/T/#u
Song Liu
maintainerQuoted 18 lines · Dirk Müller
GCC 10+ defaults to -fno-common, which enforces proper declaration of external references using "extern". without this change a link would fail with:
lib/raid6/test/algos.c:28: multiple definition of `raid6_call';lib/raid6/test/test.c:22: first defined hereSigned-off-by Dirk Müller <[email protected]>--- lib/raid6/test/test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/raid6/test/test.c +0
-0
lib/raid6/test/test.c line 22
Quoted 5 lines
lib/raid6/test/test.c +1
-1@@ -19,7 +19,7 @@#define NDISKS 16/* Including P and Q */ const char raid6_empty_zero_page[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); -struct raid6_calls raid6_call; +extern struct raid6_calls raid6_call;
Can we just remove this line?
Thanks,
Song
On Dienstag, 8. Februar 2022 06:45:45 CET Song Liu wrote:
Hi Song,
Quoted 4 lines
lib/raid6/test/test.c line 22
Quoted 2 lines
lib/raid6/test/test.c +1
-1-struct raid6_calls raid6_call; +extern struct raid6_calls raid6_call;Can we just remove this line?
oh yes indeed, it is already declared in the header file. that is much simpler. I've sent a PATCH v2 just now.
Thank you,
Dirk