Comments (7)
This looks like the culprit: https://gcc.gnu.org/gcc-10/porting_to.html#common
A common mistake in C is omitting
extern
when declaring a global variable in a header file. If the header is included by several files it results in multiple definitions of the same variable. In previous GCC versions this error is ignored. GCC 10 defaults to-fno-common
, which means a linker error will now be reported. To fix this, useextern
in header files when declaring global variables, and ensure each global is defined in exactly one C file. If tentative definitions of particular variables need to be placed in a common block,__attribute__((__common__))
can be used to force that behavior even in code compiled without-fcommon
. As a workaround, legacy C code where all tentative definitions should be placed into a common block can be compiled with-fcommon
.
int x; // tentative definition - avoid in header files
extern int y; // correct declaration in a header file
Lines 13 to 15 in 0421d51
I'll try adding extern
to those declarations.
from semian.
I don't see these values actually being defined more than once. I wonder if some behavior has changed in GCC 10?
Can you reproduce on any older version of GCC, eg, GCC 8?
from semian.
I'm running into this in the Alpine-based Ruby Docker containers. On Alpine 3.12 (gcc 9.3.0) I can install Semian, but on Alpine 3.13 (gcc 10.2.1) I can't:
$ docker run --rm ruby:2.7.2-alpine3.12 sh -c 'apk add build-base openssl-dev && gem install semian --version 0.11.3'
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/20) Upgrading libcrypto1.1 (1.1.1i-r0 -> 1.1.1j-r0)
(2/20) Upgrading libssl1.1 (1.1.1i-r0 -> 1.1.1j-r0)
(3/20) Installing binutils (2.34-r1)
(4/20) Installing libmagic (5.38-r0)
(5/20) Installing file (5.38-r0)
(6/20) Installing isl (0.18-r0)
(7/20) Installing libgomp (9.3.0-r2)
(8/20) Installing libatomic (9.3.0-r2)
(9/20) Installing libgphobos (9.3.0-r2)
(10/20) Installing mpfr4 (4.0.2-r4)
(11/20) Installing mpc1 (1.1.0-r1)
(12/20) Installing gcc (9.3.0-r2)
(13/20) Installing musl-dev (1.1.24-r10)
(14/20) Installing libc-dev (0.7.2-r3)
(15/20) Installing g++ (9.3.0-r2)
(16/20) Installing make (4.3-r0)
(17/20) Installing fortify-headers (1.1-r0)
(18/20) Installing patch (2.7.6-r6)
(19/20) Installing build-base (0.5-r2)
(20/20) Installing openssl-dev (1.1.1j-r0)
Executing busybox-1.31.1-r19.trigger
Executing ca-certificates-20191127-r4.trigger
OK: 219 MiB in 54 packages
Building native extensions. This could take a while...
Successfully installed semian-0.11.3
1 gem installed
$ docker run --rm ruby:2.7.2-alpine3.13 sh -c 'apk add build-base openssl-dev && gem install semian --version 0.11.3'
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
(1/18) Installing binutils (2.35.1-r1)
(2/18) Installing libmagic (5.39-r0)
(3/18) Installing file (5.39-r0)
(4/18) Installing libgomp (10.2.1_pre1-r3)
(5/18) Installing libatomic (10.2.1_pre1-r3)
(6/18) Installing libgphobos (10.2.1_pre1-r3)
(7/18) Installing isl22 (0.22-r0)
(8/18) Installing mpfr4 (4.1.0-r0)
(9/18) Installing mpc1 (1.2.0-r0)
(10/18) Installing gcc (10.2.1_pre1-r3)
(11/18) Installing musl-dev (1.2.2-r0)
(12/18) Installing libc-dev (0.7.2-r3)
(13/18) Installing g++ (10.2.1_pre1-r3)
(14/18) Installing make (4.3-r0)
(15/18) Installing fortify-headers (1.1-r0)
(16/18) Installing patch (2.7.6-r6)
(17/18) Installing build-base (0.5-r2)
(18/18) Installing openssl-dev (1.1.1j-r0)
Executing busybox-1.32.1-r3.trigger
OK: 209 MiB in 54 packages
Building native extensions. This could take a while...
ERROR: Error installing semian:
ERROR: Failed to build gem native extension.
current directory: /usr/local/bundle/gems/semian-0.11.3/ext/semian
/usr/local/bin/ruby -I /usr/local/lib/ruby/2.7.0 -r ./siteconf20210218-1-1wb9nhd.rb extconf.rb
checking for openssl/sha.h... yes
checking for SHA1() in -lcrypto... yes
checking for sys/ipc.h... yes
checking for sys/sem.h... yes
checking for sys/types.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_without_gvl()... yes
creating Makefile
current directory: /usr/local/bundle/gems/semian-0.11.3/ext/semian
make "DESTDIR=" clean
current directory: /usr/local/bundle/gems/semian-0.11.3/ext/semian
make "DESTDIR="
compiling resource.c
compiling semian.c
compiling sysv_semaphores.c
compiling tickets.c
linking shared-object semian/semian.so
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: semian.o:(.bss+0x28): multiple definition of `id_wait_time'; resource.o:(.bss+0x10): first defined here
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: semian.o:(.bss+0x20): multiple definition of `id_timeout'; resource.o:(.bss+0x8): first defined here
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: semian.o:(.bss+0x18): multiple definition of `system_max_semaphore_count'; resource.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:262: semian.so] Error 1
make failed, exit code 2
Gem files will remain installed in /usr/local/bundle/gems/semian-0.11.3 for inspection.
Results logged to /usr/local/bundle/extensions/x86_64-linux-musl/2.7.0/semian-0.11.3/gem_make.out
from semian.
Works if I declare the variable as an extern as follows.
/* changes */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0)
extern int system_max_semaphore_count;
#else
int system_max_semaphore_count=0;
#endif
```
from semian.
I'm running into this in the Alpine-based Ruby Docker containers. On Alpine 3.12 (gcc 9.3.0) I can install Semian, but on Alpine 3.13 (gcc 10.2.1) I can't:
$ docker run --rm ruby:2.7.2-alpine3.12 sh -c 'apk add build-base openssl-dev && gem install semian --version 0.11.3' fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz (1/20) Upgrading libcrypto1.1 (1.1.1i-r0 -> 1.1.1j-r0) (2/20) Upgrading libssl1.1 (1.1.1i-r0 -> 1.1.1j-r0) (3/20) Installing binutils (2.34-r1) (4/20) Installing libmagic (5.38-r0) (5/20) Installing file (5.38-r0) (6/20) Installing isl (0.18-r0) (7/20) Installing libgomp (9.3.0-r2) (8/20) Installing libatomic (9.3.0-r2) (9/20) Installing libgphobos (9.3.0-r2) (10/20) Installing mpfr4 (4.0.2-r4) (11/20) Installing mpc1 (1.1.0-r1) (12/20) Installing gcc (9.3.0-r2) (13/20) Installing musl-dev (1.1.24-r10) (14/20) Installing libc-dev (0.7.2-r3) (15/20) Installing g++ (9.3.0-r2) (16/20) Installing make (4.3-r0) (17/20) Installing fortify-headers (1.1-r0) (18/20) Installing patch (2.7.6-r6) (19/20) Installing build-base (0.5-r2) (20/20) Installing openssl-dev (1.1.1j-r0) Executing busybox-1.31.1-r19.trigger Executing ca-certificates-20191127-r4.trigger OK: 219 MiB in 54 packages Building native extensions. This could take a while... Successfully installed semian-0.11.3 1 gem installed $ docker run --rm ruby:2.7.2-alpine3.13 sh -c 'apk add build-base openssl-dev && gem install semian --version 0.11.3' fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz (1/18) Installing binutils (2.35.1-r1) (2/18) Installing libmagic (5.39-r0) (3/18) Installing file (5.39-r0) (4/18) Installing libgomp (10.2.1_pre1-r3) (5/18) Installing libatomic (10.2.1_pre1-r3) (6/18) Installing libgphobos (10.2.1_pre1-r3) (7/18) Installing isl22 (0.22-r0) (8/18) Installing mpfr4 (4.1.0-r0) (9/18) Installing mpc1 (1.2.0-r0) (10/18) Installing gcc (10.2.1_pre1-r3) (11/18) Installing musl-dev (1.2.2-r0) (12/18) Installing libc-dev (0.7.2-r3) (13/18) Installing g++ (10.2.1_pre1-r3) (14/18) Installing make (4.3-r0) (15/18) Installing fortify-headers (1.1-r0) (16/18) Installing patch (2.7.6-r6) (17/18) Installing build-base (0.5-r2) (18/18) Installing openssl-dev (1.1.1j-r0) Executing busybox-1.32.1-r3.trigger OK: 209 MiB in 54 packages Building native extensions. This could take a while... ERROR: Error installing semian: ERROR: Failed to build gem native extension. current directory: /usr/local/bundle/gems/semian-0.11.3/ext/semian /usr/local/bin/ruby -I /usr/local/lib/ruby/2.7.0 -r ./siteconf20210218-1-1wb9nhd.rb extconf.rb checking for openssl/sha.h... yes checking for SHA1() in -lcrypto... yes checking for sys/ipc.h... yes checking for sys/sem.h... yes checking for sys/types.h... yes checking for rb_thread_blocking_region()... no checking for rb_thread_call_without_gvl()... yes creating Makefile current directory: /usr/local/bundle/gems/semian-0.11.3/ext/semian make "DESTDIR=" clean current directory: /usr/local/bundle/gems/semian-0.11.3/ext/semian make "DESTDIR=" compiling resource.c compiling semian.c compiling sysv_semaphores.c compiling tickets.c linking shared-object semian/semian.so /usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: semian.o:(.bss+0x28): multiple definition of `id_wait_time'; resource.o:(.bss+0x10): first defined here /usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: semian.o:(.bss+0x20): multiple definition of `id_timeout'; resource.o:(.bss+0x8): first defined here /usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: semian.o:(.bss+0x18): multiple definition of `system_max_semaphore_count'; resource.o:(.bss+0x0): first defined here collect2: error: ld returned 1 exit status make: *** [Makefile:262: semian.so] Error 1 make failed, exit code 2 Gem files will remain installed in /usr/local/bundle/gems/semian-0.11.3 for inspection. Results logged to /usr/local/bundle/extensions/x86_64-linux-musl/2.7.0/semian-0.11.3/gem_make.out
@haines I now this is a super old issue, but your reply gave me a hint on why I was having problems installing the semian gem. I believe it's also why you had different results on your dockers. For version 0.10.6, I had to revert gcc and g++ back to version 9 (by default, it was 11). So yeah, that's the fix for that specific version (if anyone needs it. I'm even writing this for myself in the future, just in case!!)
from semian.
Glad this helped @luis-novoa! Note that if you can upgrade semian to 0.11.4+, it should compile fine with gcc 10+.
from semian.
This seems to be an issue with the newer versions of gcc. In my case this error appeared while running a project on a docker container (Alpine image). However it did not appear when i ran the same project on my regular wsl (Ubuntu).
As mentioned before, might be an issue with the most recent versions of gcc.
What fixed it for me was adding the "extern" keyword to the global variables that presented the issue.
Hope this helps!
from semian.
Related Issues (20)
- Circuit not open for GRPC::ActiveCall::Operation failures
- Feature: support static config for Semian::NetHTTP and Semian::GRPC
- Update all development / test gems HOT 2
- Compatibility issues with Redis 5.X HOT 1
- Release v0.14.0 HOT 1
- Random failed tests
- Review tests to cover ActiveRecord problems
- Ruby type RBS vs Sorbet RBI
- Bulkhead resource count produces error HOT 1
- Extract bulkheading ENV settings to configuration part HOT 2
- Investigate possobility when resource is acquired
- Semian does not open circuit immediately and waits for redis pool's reconnection attempts which uses exponential backoff timeout HOT 2
- Release 0.17.0 HOT 3
- Release 0.18.0
- Investigate in Segmetation fault for AR Trilogy HOT 1
- Automate create github release HOT 2
- Release 0.19.0
- Update HTTP examples to handle 500
- Support per-request HTTP Resource naming HOT 4
- Semian incompatible with redis-rb 5.0.7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from semian.