Tests failing with undefined symbol: __gmpn_set_str on Xenial

I’ve asked this exact question before here and for the same repository etscrivner/rbsecp256k1. However the old fix - use Xenial - no longer works.

You can find my pull request fixing builds here

My builds were succeeding unmodified for quite a long time and nothing significant has changed in the repository since last year. This leads me to suspect that something has instead changed on the Travis CI side. Would anyone have advice on what that might be and why this would have started failing?

I have both libgmp10 and libgmp-dev dependencies installed AFAICT.

Have tried to reproduce this issue using the travisci/ubuntu:16.04 images on Dockerhub to no avail. This issue seems to be specifically related to how the travisci system is configured itself. Test Dockerfile is below:

FROM travisci/ubuntu-ruby:16.04

RUN apt-get update
RUN apt-get install -y build-essential automake pkg-config libtool \
  libffi-dev libssl-dev python-dev ruby ruby-dev ruby-build

ADD Gemfile Gemfile Rakefile Makefile rbsecp256k1.gemspec /app/
COPY ext /app/ext/
COPY lib /app/lib/
COPY spec /app/spec/

RUN \curl -sSL https://get.rvm.io | bash
RUN /bin/bash -l -c "rvm use 2.4 --install --binary --fuzzy"
RUN ruby --version
RUN gem update --system
# RUN export BUNDLE_GEMFILE=/app/Gemfile
RUN gem install bundler

WORKDIR /app
RUN bundle install --jobs=3 --retry=3
RUN make setup
RUN make build
RUN make test WITH_RECOVERY=1 WITH_ECDH=1

Googling suggests that this happens if you don’t link against the right .so and suggests troubleshooting tools:

gcc - Linux shared library that uses a shared library undefined symbol - Stack Overflow
c++ - Easy check for unresolved symbols in shared libraries? - Stack Overflow

Thanks for the feedback. I am unable to reproduce this error anywhere but within TravisCI itself. I have tried the following and all work:

  • Building on a personal Linux machine.
  • Building on a personal macOS machine.
  • Building in Docker against the TravisCI Ubuntu 16.04 docker image from dockerhub.

All of these work and the library is linked correctly. I see in the output of the Makefile config that the library is found:

checking for -lgmp... yes
checking for secp256k1_recovery.h... no
checking for secp256k1_ecdh.h... no
creating Makefile

All of this is quite puzzling. Especially since this build worked for quite a long time and then started breaking all of a sudden. So my guess is something has changed specifically on TravisCI.

I’ve figured out the issue here. GCC was compiling with the -Wl,--as-needed linker flag by default and this was causing libgmp - which was not needed by the library itself, but instead one of its dependencies, to register as missing.

By adding the -Wl,--no-as-needed flag I was able to fix this.

1 Like

This suggests that that “dependency” is not specifying that it depends on libgmp when it should.