What version of protobuf and what language are you using?
Version: d447b29 and 3.21.12
Language: Ruby
What operating system (Linux, Windows, ...) and version?
Linux, Fedora 36
What runtime / compiler are you using (e.g., python version or gcc version)
- Fedora 36, GCC 12.2
- Fedora 38, GCC 13.0
What did you do?
The following script under docker run -ti fedora:36 bash (and fedora:38) fails:
dnf install ruby-devel
dnf group install "C Development Tools and Libraries" "Development Tools"
gem install google-protobuf --platform ruby
What did you expect to see
What did you see instead?
Fedora 38 (GCC 13.0): Installation failure:
gcc -shared -o protobuf_c.so protobuf.o convert.o defs.o message.o repeated_field.o map.o ruby-upb.o wrap_memcpy.o naive.o range2-neon.o range2-sse.o -L. -L/usr/lib64 -L. -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed -Wl,-wrap,memcpy -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -m64 -lruby -lm -lpthread -lc
/usr/bin/ld: /tmp/ccU44S3j.ltrans1.ltrans.o: in function `_upb_EnumReservedNames_New':
/usr/include/bits/string_fortified.h:29: undefined reference to `__wrap_memcpy'
/usr/bin/ld: /tmp/ccU44S3j.ltrans1.ltrans.o: in function `jsondec_string':
/usr/include/bits/string_fortified.h:29: undefined reference to `__wrap_memcpy'
/usr/bin/ld: /usr/include/bits/string_fortified.h:29: undefined reference to `__wrap_memcpy'
/usr/bin/ld: /tmp/ccU44S3j.ltrans1.ltrans.o: in function `jsondec_wellknown':
/usr/include/bits/string_fortified.h:29: undefined reference to `__wrap_memcpy'
/usr/bin/ld: /tmp/ccU44S3j.ltrans1.ltrans.o: in function `jsonenc_putbytes.lto_priv.0':
/usr/include/bits/string_fortified.h:29: undefined reference to `__wrap_memcpy'
/usr/bin/ld: /tmp/ccU44S3j.ltrans1.ltrans.o:/usr/include/bits/string_fortified.h:29: more undefined references to `__wrap_memcpy' follow
collect2: error: ld returned 1 exit status
make: *** [Makefile:266: protobuf_c.so] Error 1
Fedora has enabled LTO when building Ruby, so its RbConfig::CONFIG["CFLAGS"] includes -flto as well.
Removing -Wl,-wrap,memcpy resolves this compilation error.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88643 mentions use of -wrap is not supported when LTO enabled, so it might be worth to do either of:
- as the wrap_memcpy exists for binary distrribution, avoid using this trick when building not for binary distribution
- always add
-fno-lto at extconf.rb
Anything else we should know about your project / environment
What version of protobuf and what language are you using?
Version: d447b29 and 3.21.12
Language: Ruby
What operating system (Linux, Windows, ...) and version?
Linux, Fedora 36
What runtime / compiler are you using (e.g., python version or gcc version)
What did you do?
The following script under
docker run -ti fedora:36 bash(and fedora:38) fails:What did you expect to see
What did you see instead?
Fedora 38 (GCC 13.0): Installation failure:
Fedora has enabled LTO when building Ruby, so its
RbConfig::CONFIG["CFLAGS"]includes-fltoas well.Removing
-Wl,-wrap,memcpyresolves this compilation error.https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88643 mentions use of
-wrapis not supported when LTO enabled, so it might be worth to do either of:-fno-ltoat extconf.rbAnything else we should know about your project / environment