oracle / truffleruby

A high performance implementation of the Ruby programming language, built on GraalVM.
https://www.graalvm.org/ruby/
Other
3.03k stars 185 forks source link

Unable to install RMagick on truffleruby:debian-22.3.1 #3041

Closed rangeoshun closed 2 months ago

rangeoshun commented 1 year ago

After installing dependencies, the build fails with:

ld.lld: error: unable to find library -lomp
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)

Full log:

$ docker run -ti ghcr.io/graalvm/truffleruby:debian-22.3.1 /bin/bash

# apt update && apt install -y libmagickcore-dev
...
# gem install rmagick
Building native extensions. This could take a while...
ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

    current directory: /opt/truffleruby-22.3.1/lib/gems/gems/rmagick-5.2.0/ext/RMagick
/opt/truffleruby-22.3.1/bin/ruby -I /opt/truffleruby-22.3.1/lib/mri -r ./siteconf20230509-859-lv3jd6.rb extconf.rb
checking for brew... no
checking for pacman... no
checking for Ruby version >= 2.3.0... yes
checking for outdated ImageMagick version (<= 6.7.7)... no
checking for /opt/truffleruby-22.3.1/lib/sulong/native/bin/graalvm-native-clang... yes
/opt/truffleruby-22.3.1/lib/mri/mkmf.rb:545:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.

Contents of mkmf.log:
find_executable: checking for brew... -------------------- no

--------------------

find_executable: checking for pacman... -------------------- no

--------------------

assert_minimum_ruby_version!: checking for Ruby version >= 2.3.0... -------------------- yes

--------------------

assert_has_dev_libs!: checking for outdated ImageMagick version (<= 6.7.7)... -------------------- no

Detected ImageMagick version: 6.9.10
--------------------

find_executable: checking for /opt/truffleruby-22.3.1/lib/sulong/native/bin/graalvm-native-clang... -------------------- yes

--------------------

"/opt/truffleruby-22.3.1/lib/sulong/native/bin/graalvm-native-clang -o conftest -I/opt/truffleruby-22.3.1/lib/cext/include -I/opt/truffleruby-22.3.1/lib/cext/include/ruby/backward -I/opt/truffleruby-22.3.1/lib/cext/include -I.  -DTRUFFLERUBY_ABI_VERSION=3.0.3.22.3.1   -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6   -Werror=implicit-function-declaration -Wno-int-conversion -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types -Wno-format-invalid-specifier -Wno-format-extra-args -ferror-limit=500 conftest.c  -L.   -L/usr/lib/x86_64-linux-gnu -lMagickCore-6.Q16 -Wl,-rpath,/usr/lib/x86_64-linux-gnu     -L/usr/lib/x86_64-linux-gnu -lMagickCore-6.Q16  -lgraalvm-llvm    -L/opt/truffleruby-22.3.1/lib/cext -rpath /opt/truffleruby-22.3.1/lib/cext -ltruffleruby -rpath /opt/truffleruby-22.3.1/lib/sulong/native/lib"
ld.lld: error: unable to find library -lomp
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
Process failed: #<Process::Status: pid 889 exit 1>
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

    from /opt/truffleruby-22.3.1/lib/mri/mkmf.rb:639:in `try_link0'
    from /opt/truffleruby-22.3.1/lib/mri/mkmf.rb:657:in `try_link'
    from extconf.rb:109:in `configure_compile_options'
    from extconf.rb:47:in `initialize'
    from extconf.rb:441:in `<main>'
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/opt/truffleruby-22.3.1/bin/ruby
    --with-pkg-config
    --without-pkg-config
    --with-override-variables
    --without-override-variables

Contents of mkmf.log:
find_executable: checking for brew... -------------------- no

--------------------

find_executable: checking for pacman... -------------------- no

--------------------

assert_minimum_ruby_version!: checking for Ruby version >= 2.3.0... -------------------- yes

--------------------

assert_has_dev_libs!: checking for outdated ImageMagick version (<= 6.7.7)... -------------------- no

Detected ImageMagick version: 6.9.10
--------------------

find_executable: checking for /opt/truffleruby-22.3.1/lib/sulong/native/bin/graalvm-native-clang... -------------------- yes

--------------------

"/opt/truffleruby-22.3.1/lib/sulong/native/bin/graalvm-native-clang -o conftest -I/opt/truffleruby-22.3.1/lib/cext/include -I/opt/truffleruby-22.3.1/lib/cext/include/ruby/backward -I/opt/truffleruby-22.3.1/lib/cext/include -I.  -DTRUFFLERUBY_ABI_VERSION=3.0.3.22.3.1   -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/x86_64-linux-gnu//ImageMagick-6 -I/usr/include/ImageMagick-6   -Werror=implicit-function-declaration -Wno-int-conversion -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types -Wno-format-invalid-specifier -Wno-format-extra-args -ferror-limit=500 conftest.c  -L.   -L/usr/lib/x86_64-linux-gnu -lMagickCore-6.Q16 -Wl,-rpath,/usr/lib/x86_64-linux-gnu     -L/usr/lib/x86_64-linux-gnu -lMagickCore-6.Q16  -lgraalvm-llvm    -L/opt/truffleruby-22.3.1/lib/cext -rpath /opt/truffleruby-22.3.1/lib/cext -ltruffleruby -rpath /opt/truffleruby-22.3.1/lib/sulong/native/lib"
ld.lld: error: unable to find library -lomp
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
Process failed: #<Process::Status: pid 889 exit 1>
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /opt/truffleruby-22.3.1/lib/gems/extensions/x86_64-linux/3.0.3.22.3.1/rmagick-5.2.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /opt/truffleruby-22.3.1/lib/gems/gems/rmagick-5.2.0 for inspection.
Results logged to /opt/truffleruby-22.3.1/lib/gems/extensions/x86_64-linux/3.0.3.22.3.1/rmagick-5.2.0/gem_make.out

Any ideas what might I be missing?

Cheers!

eregon commented 1 year ago

It seems you need to install libomp/openmp. I'm not sure why -fopenmp is passed, maybe that's ImageMagick the gem adding it

rangeoshun commented 1 year ago

It seems you need to install libomp/openmp. I'm not sure why -fopenmp is passed, maybe that's ImageMagick the gem adding it

Thanks for looking into it @eregon!

I have installed libomp-dev. Still the same. I also saw this: https://github.com/oracle/truffleruby/issues/1882#issuecomment-576394240

I have a fix for the problem you have reported, but you may still find issues on some systems. If ImageMagick has been built with OpenMP support then the compiler will be configured to add -fopenmp to the compiler flags, which the version of the LLVM tool chain we currently bundle does not support it at this time.

Is it still true?

rangeoshun commented 1 year ago

@eregon Just checked, and if I compile ImageMagick without openmp, it installs easy.

And it also installs fine with the stock ruby:latest image.

QuantumSand41Fox commented 2 months ago

It seems you need to install libomp/openmp. I'm not sure why -fopenmp is passed, maybe that's ImageMagick the gem adding it

Thanks for looking into it @eregon!

I have installed libomp-dev. Still the same. I also saw this: #1882 (comment)

I have a fix for the problem you have reported, but you may still find issues on some systems. If ImageMagick has been built with OpenMP support then the compiler will be configured to add -fopenmp to the compiler flags, which the version of the LLVM tool chain we currently bundle does not support it at this time.

Is it still true?

Installing libomp-dev fixed the issue for me! I have ruby 3.5.5.

eregon commented 2 months ago

This is solved now that we use the system's C toolchain and gem i rmagick succeeds on 24.0.