fd5affe
From 4667bddd365bcc1dc66c483835971f0083b44b1d Mon Sep 17 00:00:00 2001
fd5affe
From: Sergei Trofimovich <slyfox@gentoo.org>
fd5affe
Date: Wed, 22 Jan 2020 19:38:23 +0000
fd5affe
Subject: [PATCH] icd_generator.rb: fix build failure against gcc-10
fd5affe
fd5affe
On gcc-10 (and gcc-9 -fno-common) build fails as:
fd5affe
fd5affe
```
fd5affe
libtool: link: gcc -shared  -fPIC -DPIC  .libs/libdummy_icd.o .libs/libdummy_icd_gen.o \
fd5affe
    -ldl  -g -O2   -Wl,-soname -Wl,libdummycl.so.0 -o .libs/libdummycl.so.0.0.0
fd5affe
ld: .libs/libdummy_icd_gen.o:/home/slyfox/dev/git/ocl-icd/libdummy_icd_gen.h:226:
fd5affe
  multiple definition of `master_dispatch'; .libs/libdummy_icd.o:/home/slyfox/dev/git/ocl-icd/libdummy_icd_gen.h:226: first defined here
fd5affe
```
fd5affe
fd5affe
gcc-10 will change the default from -fcommon to fno-common:
fd5affe
https://gcc.gnu.org/PR85678.
fd5affe
fd5affe
The error also happens if CFLAGS=-fno-common passed explicitly.
fd5affe
fd5affe
Reported-by: Anthony Parsons
fd5affe
Bug: https://bugs.gentoo.org/706098
fd5affe
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
fd5affe
---
fd5affe
 icd_generator.rb | 2 +-
fd5affe
 1 file changed, 1 insertion(+), 1 deletion(-)
fd5affe
fd5affe
diff --git a/icd_generator.rb b/icd_generator.rb
fd5affe
index 49443b8..764cabb 100644
fd5affe
--- a/icd_generator.rb
fd5affe
+++ b/icd_generator.rb
fd5affe
@@ -207,7 +207,7 @@ def self.generate_libdummy_icd_header
fd5affe
     }
fd5affe
     libdummy_icd_structures += "};\n\n"
fd5affe
     libdummy_icd_structures += "#pragma GCC visibility push(hidden)\n\n"
fd5affe
-    libdummy_icd_structures += "struct _cl_icd_dispatch master_dispatch; \n\n"
fd5affe
+    libdummy_icd_structures += "extern struct _cl_icd_dispatch master_dispatch; \n\n"
fd5affe
     $use_name_in_test.each { |k, f|
fd5affe
       libdummy_icd_structures += "typeof(#{f}) INT#{f};\n"
fd5affe
     }