ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:110714] [Ruby master Bug#19124] Compile with clang: Cannot compile with -flto -fvisibility=hidden
@ 2022-11-12  1:36 steakknife (Barry Allard)
  2022-11-12  2:22 ` [ruby-core:110718] " steakknife (Barry Allard)
  2022-11-24 17:49 ` [ruby-core:110882] " alanwu (Alan Wu)
  0 siblings, 2 replies; 3+ messages in thread
From: steakknife (Barry Allard) @ 2022-11-12  1:36 UTC (permalink / raw)
  To: ruby-core

Issue #19124 has been reported by steakknife (Barry Allard).

----------------------------------------
Bug #19124: Compile with clang: Cannot compile with -flto -fvisibility=hidden
https://bugs.ruby-lang.org/issues/19124

* Author: steakknife (Barry Allard)
* Status: Open
* 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/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:110718] [Ruby master Bug#19124] Compile with clang: Cannot compile with -flto -fvisibility=hidden
  2022-11-12  1:36 [ruby-core:110714] [Ruby master Bug#19124] Compile with clang: Cannot compile with -flto -fvisibility=hidden steakknife (Barry Allard)
@ 2022-11-12  2:22 ` steakknife (Barry Allard)
  2022-11-24 17:49 ` [ruby-core:110882] " alanwu (Alan Wu)
  1 sibling, 0 replies; 3+ messages in thread
From: steakknife (Barry Allard) @ 2022-11-12  2:22 UTC (permalink / raw)
  To: ruby-core

Issue #19124 has been updated by steakknife (Barry Allard).


`-flto` itself works. `-fvisibility=` is needed for other `-fsanitize=` options.

----------------------------------------
Bug #19124: Compile with clang: Cannot compile with -flto -fvisibility=hidden
https://bugs.ruby-lang.org/issues/19124#change-100056

* Author: steakknife (Barry Allard)
* Status: Open
* 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/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:110882] [Ruby master Bug#19124] Compile with clang: Cannot compile with -flto -fvisibility=hidden
  2022-11-12  1:36 [ruby-core:110714] [Ruby master Bug#19124] Compile with clang: Cannot compile with -flto -fvisibility=hidden steakknife (Barry Allard)
  2022-11-12  2:22 ` [ruby-core:110718] " steakknife (Barry Allard)
@ 2022-11-24 17:49 ` alanwu (Alan Wu)
  1 sibling, 0 replies; 3+ messages in thread
From: alanwu (Alan Wu) @ 2022-11-24 17:49 UTC (permalink / raw)
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-24 17:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-12  1:36 [ruby-core:110714] [Ruby master Bug#19124] Compile with clang: Cannot compile with -flto -fvisibility=hidden steakknife (Barry Allard)
2022-11-12  2:22 ` [ruby-core:110718] " steakknife (Barry Allard)
2022-11-24 17:49 ` [ruby-core:110882] " alanwu (Alan Wu)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).