[PATCH] lib, ruby: make use of -Wl,--no-undefined configurable
Jinwoo Lee
jinwoo68 at gmail.com
Sat Jun 13 23:20:24 PDT 2015
There are 2 problems.
1. The file, bindings/Makefile.local still has lib/libnotmuch.so as the
dependency of ruby-bindings.
> make: *** No rule to make target `lib/libnotmuch.so', needed by
> `ruby-bindings'. Stop.
2. After manually changing it to lib/libnotmuch.dylib, I still get an
error like below:
> cd bindings/ruby && \
> EXTRA_LDFLAGS="" \
> ruby extconf.rb --vendor
> checking for notmuch_database_create in libnotmuch.so... no
> *** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
> make: *** [ruby-bindings] Error 1
I tried updating extconf.rb to change libnotmuch.so to libnotmuch.dylib
but that still emit a similar error.
And the attached is the log file, mkmf.log generated in bindings/ruby.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mkmf.log
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20150613/1f5ae2aa/attachment.ksh>
-------------- next part --------------
On Sat, Jun 13, 2015 at 10:58 PM, David Bremner <david at tethera.net> wrote:
> In particular this is supposed to help build on systems (presumably
> using a non-gnu ld) where this flag is not available.
> ---
> bindings/Makefile.local | 4 +++-
> bindings/ruby/extconf.rb | 5 +++--
> configure | 13 +++++++++++++
> lib/Makefile.local | 2 +-
> 4 files changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/bindings/Makefile.local b/bindings/Makefile.local
> index 16817f5..d236f01 100644
> --- a/bindings/Makefile.local
> +++ b/bindings/Makefile.local
> @@ -5,7 +5,9 @@ dir := bindings
> # force the shared library to be built
> ruby-bindings: lib/libnotmuch.so
> ifeq ($(HAVE_RUBY_DEV),1)
> - cd $(dir)/ruby && ruby extconf.rb --vendor
> + cd $(dir)/ruby && \
> + EXTRA_LDFLAGS="$(NO_UNDEFINED_LDFLAGS)" \
> + ruby extconf.rb --vendor
> $(MAKE) -C $(dir)/ruby
> else
> @echo Missing dependency, skipping ruby bindings
> diff --git a/bindings/ruby/extconf.rb b/bindings/ruby/extconf.rb
> index 6160db2..6d5607e 100644
> --- a/bindings/ruby/extconf.rb
> +++ b/bindings/ruby/extconf.rb
> @@ -10,8 +10,9 @@ dir = File.join('..', '..', 'lib')
> # includes
> $INCFLAGS = "-I#{dir} #{$INCFLAGS}"
>
> -# make sure there are no undefined symbols
> -$LDFLAGS += ' -Wl,--no-undefined'
> +if ENV['EXTRA_LDFLAGS']
> + $LDFLAGS += " " + ENV['EXTRA_LDFLAGS']
> +end
>
> def have_local_library(lib, path, func, headers = nil)
> checking_for checking_message(func, lib) do
> diff --git a/configure b/configure
> index 13a8dca..b967a4e 100755
> --- a/configure
> +++ b/configure
> @@ -751,6 +751,16 @@ else
> as_needed_ldflags=""
> fi
>
> +printf "Checking for -Wl,--no-undefined... "
> +if ${CC} -Wl,--no-undefined -o minimal minimal.c >/dev/null 2>&1
> +then
> + printf "Yes.\n"
> + no_undefined_ldflags="-Wl,--no-undefined"
> +else
> + printf "No (nothing to worry about).\n"
> + no_undefined_ldflags=""
> +fi
> +
> WARN_CXXFLAGS=""
> printf "Checking for available C++ compiler warning flags... "
> for flag in -Wall -Wextra -Wwrite-strings; do
> @@ -955,6 +965,9 @@ RPATH_LDFLAGS = ${rpath_ldflags}
> # Flags needed to have linker link only to necessary libraries
> AS_NEEDED_LDFLAGS = ${as_needed_ldflags}
>
> +# Flags to have the linker flag undefined symbols in object files
> +NO_UNDEFINED_LDFLAGS = ${no_undefined_ldflags}
> +
> # Whether valgrind header files are available
> HAVE_VALGRIND = ${have_valgrind}
>
> diff --git a/lib/Makefile.local b/lib/Makefile.local
> index f9ecd50..b58b4e8 100644
> --- a/lib/Makefile.local
> +++ b/lib/Makefile.local
> @@ -33,7 +33,7 @@ LIBRARY_SUFFIX = so
> LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)
> SONAME = $(LINKER_NAME).$(LIBNOTMUCH_VERSION_MAJOR)
> LIBNAME = $(SONAME).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE)
> -LIBRARY_LINK_FLAG = -shared -Wl,--version-script=notmuch.sym,-soname=$(SONAME) -Wl,--no-undefined
> +LIBRARY_LINK_FLAG = -shared -Wl,--version-script=notmuch.sym,-soname=$(SONAME) $(NO_UNDEFINED_LDFLAGS)
> ifeq ($(PLATFORM),OPENBSD)
> LIBRARY_LINK_FLAG += -lc
> endif
> --
> 2.1.4
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
More information about the notmuch
mailing list