Hi,
I am unable to complete a bundle install of my project's Gemfile, it is getting very close but fails on the sassc gem. I have created a test case Dockerfile to highlight the issue
FROM oracle/graalvm-ce
ENV BUNDLE_SILENCE_ROOT_WARNING=1
RUN gu install ruby
RUN /opt/graalvm-ce-19.2.0.1/jre/languages/ruby/lib/truffle/post_install_hook.sh
RUN gem install sassc
running docker build -f Dockerfile -t sassc-test:latest . results in
Step 5/5 : RUN gem install sassc
---> Running in 49c557f07280
ERROR: Error installing sassc:
ERROR: Failed to build gem native extension.
current directory: /opt/graalvm-ce-19.2.0.1/jre/languages/ruby/lib/gems/gems/sassc-2.2.1/ext
/opt/graalvm-ce-19.2.0.1/jre/languages/ruby/bin/truffleruby -I /opt/graalvm-ce-19.2.0.1/jre/languages/ruby/lib/mri -r ./siteconf20190927-1-ufgmu8.rb extconf.rb
creating Makefile
current directory: /opt/graalvm-ce-19.2.0.1/jre/languages/ruby/lib/gems/gems/sassc-2.2.1/ext
make "DESTDIR=" clean
current directory: /opt/graalvm-ce-19.2.0.1/jre/languages/ruby/lib/gems/gems/sassc-2.2.1/ext
make "DESTDIR="
compiling ./libsass/src/c99func.c
compiling ./libsass/src/cencode.c
compiling ./libsass/src/ast.cpp
compiling ./libsass/src/ast2c.cpp
compiling ./libsass/src/ast_fwd_decl.cpp
compiling ./libsass/src/ast_sel_cmp.cpp
compiling ./libsass/src/ast_sel_unify.cpp
compiling ./libsass/src/ast_selectors.cpp
compiling ./libsass/src/ast_supports.cpp
compiling ./libsass/src/ast_values.cpp
compiling ./libsass/src/backtrace.cpp
compiling ./libsass/src/base64vlq.cpp
compiling ./libsass/src/bind.cpp
compiling ./libsass/src/c2ast.cpp
compiling ./libsass/src/check_nesting.cpp
compiling ./libsass/src/color_maps.cpp
compiling ./libsass/src/constants.cpp
compiling ./libsass/src/context.cpp
compiling ./libsass/src/cssize.cpp
compiling ./libsass/src/emitter.cpp
compiling ./libsass/src/environment.cpp
compiling ./libsass/src/error_handling.cpp
compiling ./libsass/src/eval.cpp
compiling ./libsass/src/expand.cpp
compiling ./libsass/src/extend.cpp
compiling ./libsass/src/file.cpp
compiling ./libsass/src/fn_colors.cpp
compiling ./libsass/src/fn_lists.cpp
compiling ./libsass/src/fn_maps.cpp
compiling ./libsass/src/fn_miscs.cpp
compiling ./libsass/src/fn_numbers.cpp
compiling ./libsass/src/fn_selectors.cpp
compiling ./libsass/src/fn_strings.cpp
compiling ./libsass/src/fn_utils.cpp
compiling ./libsass/src/inspect.cpp
compiling ./libsass/src/json.cpp
compiling ./libsass/src/lexer.cpp
compiling ./libsass/src/listize.cpp
compiling ./libsass/src/memory/SharedPtr.cpp
compiling ./libsass/src/node.cpp
compiling ./libsass/src/operators.cpp
compiling ./libsass/src/output.cpp
compiling ./libsass/src/parser.cpp
compiling ./libsass/src/plugins.cpp
./libsass/src/plugins.cpp:174:13: warning: '__APPLE__' is not defined, evaluates to 0 [-Wundef]
#if __APPLE__
^
1 warning generated.
compiling ./libsass/src/position.cpp
compiling ./libsass/src/prelexer.cpp
compiling ./libsass/src/remove_placeholders.cpp
compiling ./libsass/src/sass.cpp
compiling ./libsass/src/sass2scss.cpp
compiling ./libsass/src/sass_context.cpp
compiling ./libsass/src/sass_functions.cpp
compiling ./libsass/src/sass_util.cpp
compiling ./libsass/src/sass_values.cpp
compiling ./libsass/src/source_map.cpp
compiling ./libsass/src/subset_map.cpp
compiling ./libsass/src/to_value.cpp
compiling ./libsass/src/units.cpp
compiling ./libsass/src/utf8_string.cpp
compiling ./libsass/src/util.cpp
compiling ./libsass/src/util_string.cpp
compiling ./libsass/src/values.cpp
linking shared-object sassc/libsass.su
/opt/graalvm-ce-19.2.0.1/jre/languages/ruby/lib/cext/linker.rb:67:in `process_args': Unknown argument: -flto (RuntimeError)
from /opt/graalvm-ce-19.2.0.1/jre/languages/ruby/lib/cext/linker.rb:21:in `main'
from /opt/graalvm-ce-19.2.0.1/jre/languages/ruby/lib/cext/linker.rb:150:in `<main>'
make: *** [libsass.su] Error 1
make failed, exit code 2
Gem files will remain installed in /opt/graalvm-ce-19.2.0.1/jre/languages/ruby/lib/gems/gems/sassc-2.2.1 for inspection.
Results logged to /opt/graalvm-ce-19.2.0.1/jre/languages/ruby/lib/gems/extensions/x86_64-linux/19.2.0.1/sassc-2.2.1/gem_make.out
Building native extensions. This could take a while...
Successfully installed ffi-1.11.1
Building native extensions. This could take a while...
The command '/bin/sh -c gem install sassc' returned a non-zero code: 1
Digging led to
https://gcc.gnu.org/wiki/LinkTimeOptimization#Using_LTO-1
So -flto would need to be added to the list of understood flags in custom linker. Since it is an optimisation flag is it optional? If it is then can the custom linker ignore the flag and emit a warning explaining what it has decided to do?
Thank you for the report.
We are aware sassc doesn't install currently due to how the gem is built (which changed in recent releases), but we should have fix soon in the next TruffleRuby release.
there's a flag to disable lto, but there might be other issues...
gem install sassc -- --disable-lto
@ahorek Thanks and as you suspected it leads to a different issue
linking shared-object sassc/libsass.su
strip:libsass.su: File format not recognized
make: *** [libsass.su] Error 1
make failed, exit code 2
Gem files will remain installed in /opt/graalvm-ce-19.2.0.1/jre/languages/ruby/lib/gems/gems/sassc-2.2.1 for inspection.
Results logged to /opt/graalvm-ce-19.2.0.1/jre/languages/ruby/lib/gems/extensions/x86_64-linux/19.2.0.1/sassc-2.2.1/gem_make.out
As a workaround until the next TruffleRuby release, using an older version of sassc like 2.0.1 or older should work. I just tried on TruffleRuby 19.2 and it seems to work fine.
Using the pure-Ruby but deprecated sass gem might also be an option.
For the record, https://github.com/sass/sassc-ruby/pull/127 is what changed how libsass is compiled.
I included the Gemfile.lock file (had excluded it as was having to make some changes to the Gemfile) and this specified 2.0.1 . This has done the trick:
Bundle complete! 60 Gemfile dependencies, 175 gems now installed.
For information the Dockerfile I am using:
FROM oracle/graalvm-ce
ENV RAILS_ENV=production \
NODE_ENV=production \
RAILS_SERVE_STATIC_FILES=true \
RAILS_LOG_TO_STDOUT=true \
RACK_TIMEOUT_SERVICE_TIMEOUT=60 \
BUNDLE_SILENCE_ROOT_WARNING=1
RUN yum -y install git libxml2-devel libxslt-devel postgresql-devel
RUN gu install ruby
RUN /opt/graalvm-ce-19.2.0.1/jre/languages/ruby/lib/truffle/post_install_hook.sh
RUN bundle config build.nokogiri --use-system-libraries
COPY Gemfile Gemfile.lock ./
RUN bundle install
The git install is because of some non packaged gems. The libxml2 and libxslt were required by nokogiri .
BUNDLE_SILENCE_ROOT_WARNING=1 is what is done in the 'official' Ruby Docker images.
Will now try and get it running and eventually passing CI!
I think that
https://github.com/oracle/truffleruby/blob/master/lib/mri/mkmf.rb#L15
Makes the explicit RUN bundle config build.nokogiri --use-system-libraries unnecessary.
BUNDLESILENCE_ROOT_WARNING=1is what is done in the 'official' Ruby Docker images.
I would recommend dropping privileges and using Docker's USER command, and then running bundle as a normal user, but of course that's your call.
Will now try and get it running and eventually passing CI!
Great!
Makes the explicit
RUN bundle config build.nokogiri --use-system-librariesunnecessary.
Indeed, but it doesn't hurt to be explicit and makes it more resilient to changes. The reason we do this is because nokogiri wouldn't compile at all otherwise with TruffleRuby's current strategy for compiling C extensions. That might possibly change in the future.
The new llvm toolchain fix this issue. I believe this can be closed.
@rafaelfranca Thanks for confirming, I'll close this then and it will be available in the next release.
I have tested with the new release
FROM oracle/graalvm-ce:19.3.0
ENV BUNDLE_SILENCE_ROOT_WARNING=1
RUN gu install ruby
RUN /opt/graalvm-ce-java8-19.3.0/jre/languages/ruby/lib/truffle/post_install_hook.sh
RUN gem install sassc
and it works
Step 5/5 : RUN gem install sassc
---> Running in eb773f65d6a3
Building native extensions. This could take a while...
Successfully installed ffi-1.11.2
Building native extensions. This could take a while...
Successfully installed sassc-2.2.1
Parsing documentation for ffi-1.11.2
Installing ri documentation for ffi-1.11.2
Parsing documentation for sassc-2.2.1
Installing ri documentation for sassc-2.2.1
Done installing documentation for ffi, sassc after 147 seconds
2 gems installed
Removing intermediate container eb773f65d6a3
---> 631ed3296afb
Successfully built 631ed3296afb
Successfully tagged sassc-test:latest
@petenorth Excellent, thanks for confirming.
I'll add TruffleRuby in sassc's CI.
Most helpful comment
I included the
Gemfile.lockfile (had excluded it as was having to make some changes to theGemfile) and this specified2.0.1. This has done the trick:Bundle complete! 60 Gemfile dependencies, 175 gems now installed.For information the Dockerfile I am using:
The
gitinstall is because of some non packaged gems. Thelibxml2andlibxsltwere required bynokogiri.BUNDLE_SILENCE_ROOT_WARNING=1is what is done in the 'official' Ruby Docker images.Will now try and get it running and eventually passing CI!