From: "alanwu (Alan Wu)" Date: 2022-11-24T17:49:07+00:00 Subject: [ruby-core:110882] [Ruby master Bug#19124] Compile with clang: Cannot compile with -flto -fvisibility=hidden Issue #19124 has been updated by alanwu (Alan Wu). Status changed from Open to Feedback Since the linker hangs, I don't think there is much we can do on our end. Assuming Clang mimics GCC I think `LD` should be set to `clang` for LTO. From GCC's man page: >The important thing to keep in mind is that to enable link- >time optimizations you need to use the GCC driver to perform the link step. ---------------------------------------- Bug #19124: Compile with clang: Cannot compile with -flto -fvisibility=hidden https://bugs.ruby-lang.org/issues/19124#change-100241 * Author: steakknife (Barry Allard) * Status: Feedback * Priority: Normal * ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- ## Environment - CentOS 9 Stream x86_64 - 96 threads - 96 GiB RAM - 140 GiB SSD storage ## Reproduction ``` sudo dnf install -y yum-utils sudo yum-config-manager --enable crb sudo dnf install -y \ make bc binutils-gold mold patch git bison xz autoconf automake m4 libtool pkg-config perl-interpreter \ gmp-devel openssl-devel readline-devel libyaml-devel gdbm-devel zlib-devel libffi-devel \ ncurses-devel readline-devel glibc-static glibc-devel llvm-toolset LINKER=gold # also tried lld, bfd, and mold FLAGS='' LINKFLAGS="-fuse-ld=$LINKER -flto -fvisibility=hidden" # works without -flto -fvisibility=hidden EXE_LINKFLAGS='' export \ CC=clang \ CXX=clang++ \ LD=$LINKER \ CPPFLAGS="$FLAGS" \ CFLAGS="$FLAGS" \ CXXFLAGS="$FLAGS" \ DCFLAGS="$FLAGS" \ XCFLAGS="$FLAGS" \ MJIT_CFLAGS="$FLAGS" \ DLDFLAGS="$FLAGS $LINKFLAGS" \ LDFLAGS="$FLAGS $LINKFLAGS" \ XLDFLAGS="$FLAGS $LINKFLAGS $EXE_LINKFLAGS" ./configure --disable-install-doc --enable-shared && \ make -j && \ make test && \ sudo make install ``` ## Expected result Installs ruby. ## Actual result Hangs at linking conftest with 1 process remaining but it never finishes (waiting hours). ``` /usr/bin/ld -export-dynamic --build-id --eh-frame-hdr -m elf_x86_64 -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o conftest /lib/../lib64/crt1.o /lib/../lib64/crti.o /opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/crtbegin.o -L. -L../.. -L. -L/opt/rubies/ruby-3.1.2/lib -L/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12 -L/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib -L/usr/lib -plugin /usr/bin/../lib64/LLVMgold.so -plugin-opt=mcpu=x86-64 -plugin-opt=O3 -plugin-opt=-debugger-tune=gdb /tmp/conftest-b32079.o -export-dynamic --no-as-needed -rpath /opt/rubies/ruby-3.1.2/lib -lruby-static -lz -lpthread -lrt -lrt -lgmp -ldl -lcrypt -lm -lm -lc -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/crtend.o /lib/../lib64/crtn.o ``` -- https://bugs.ruby-lang.org/ Unsubscribe: