-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to compile ext with multiple definition errors #261
Comments
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? |
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 |
This looks like the culprit: https://gcc.gnu.org/gcc-10/porting_to.html#common
Lines 13 to 15 in 0421d51
I'll try adding |
Works if I declare the variable as an extern as follows.
|
@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!!) |
Glad this helped @luis-novoa! Note that if you can upgrade semian to 0.11.4+, it should compile fine with gcc 10+. |
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). |
The program could be compiled if I set
LDFLAG
explicitly with--allow-multiple-definition
Wondering if the team could resolve these warnings sot that semian could be compiled without
--allow-multiple-definition
flag?The text was updated successfully, but these errors were encountered: