From 8cc17ae53315091cb1919b9fa7482bb0eda6c6d8 Mon Sep 17 00:00:00 2001 From: Jinwoo Lee Date: Sun, 14 Jun 2015 23:20:24 +1700 Subject: [PATCH] Re: [PATCH] lib, ruby: make use of -Wl,--no-undefined configurable --- f8/15cbda8bda1f3782cdeeb275f773c6c4172e11 | 287 ++++++++++++++++++++++ 1 file changed, 287 insertions(+) create mode 100644 f8/15cbda8bda1f3782cdeeb275f773c6c4172e11 diff --git a/f8/15cbda8bda1f3782cdeeb275f773c6c4172e11 b/f8/15cbda8bda1f3782cdeeb275f773c6c4172e11 new file mode 100644 index 000000000..ea687ff5c --- /dev/null +++ b/f8/15cbda8bda1f3782cdeeb275f773c6c4172e11 @@ -0,0 +1,287 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 2D0576DE0948 + for ; Sat, 13 Jun 2015 23:20:32 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.57 +X-Spam-Level: +X-Spam-Status: No, score=-0.57 tagged_above=-999 required=5 tests=[AWL=-0.000, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, + RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 00d3jE0eCqdQ for ; + Sat, 13 Jun 2015 23:20:29 -0700 (PDT) +Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com + [209.85.220.50]) + by arlo.cworth.org (Postfix) with ESMTPS id 63CC56DE0350 + for ; Sat, 13 Jun 2015 23:20:29 -0700 (PDT) +Received: by pacgb13 with SMTP id gb13so15433456pac.1 + for ; Sat, 13 Jun 2015 23:20:28 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:subject:in-reply-to:references:user-agent:date:message-id + :mime-version:content-type; + bh=+zcSkxkX8+5Yd9amvhK4VyVTROGjVtZ/xpXSk/oDGm0=; + b=t+2Jp9Sn6J1ITC+mG1Z5uGSEC523b7pWBnkzrBO/eDY6fQEO47jYcplvuQW8nC56Tk + 527xdvY8+wBdF82UaT8CfJ/lVNSdzFmFCO1aZ82MWti2HVVh2k6jXpcc+peNkB4R9Xx4 + wBN90UGaYWpls9FGBxMXow+p6lK7wyD3+quZ/wKuOIC4JrgXaIfgd2J1wHPVLIJ1T3qK + Y1pd1KSb2rua+IPQSIP9s1D1+62R/zmjbuurpIu1PZni+/1I7WwNac2IdZEyDJHHNGa/ + MyFG6AA/zbZ5tjfNy1dPyiHCLHVatqmXOXXcTC2XGMjw40veNZe41Hit6DIuSrNMqg+c + ujaQ== +X-Received: by 10.66.66.140 with SMTP id f12mr38067295pat.120.1434262828457; + Sat, 13 Jun 2015 23:20:28 -0700 (PDT) +Received: from localhost ([2601:647:4b02:71ea:edc7:1c56:e47a:dbb0]) + by mx.google.com with ESMTPSA id nt6sm4133442pbc.18.2015.06.13.23.20.25 + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Sat, 13 Jun 2015 23:20:26 -0700 (PDT) +From: Jinwoo Lee +To: David Bremner , David Bremner , + notmuch@notmuchmail.org +Subject: Re: [PATCH] lib, ruby: make use of -Wl,--no-undefined configurable +In-Reply-To: <1434261524-14139-1-git-send-email-david@tethera.net> +References: <1433142542-2307-3-git-send-email-david@tethera.net> + <1434261524-14139-1-git-send-email-david@tethera.net> +User-Agent: Notmuch/0.20.1+21~g4e79903 (http://notmuchmail.org) Emacs/24.5.1 + (x86_64-apple-darwin14.3.0) +Date: Sat, 13 Jun 2015 23:20:24 -0700 +Message-ID: +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="=-=-=" +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 14 Jun 2015 06:20:32 -0000 + +--=-=-= +Content-Type: text/plain + +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. + + +--=-=-= +Content-Type: text/plain +Content-Disposition: attachment; filename=mkmf.log +Content-Description: mkmf.log + +have_local_library: checking for notmuch_database_create in libnotmuch.dylib... -------------------- no + +"xcrun clang -o conftest -I../../lib -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin14 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_SYNC_BUILTINS conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L. -L/usr/local/lib -arch x86_64 -arch i386 -lruby.2.0.0 -lpthread -ldl -lobjc " +ld: warning: directory not found for option '-L/usr/local/lib' +ld: warning: directory not found for option '-L/usr/local/lib' +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: int main(int argc, char **argv) +4: { +5: return 0; +6: } +/* end */ + +"xcrun clang -o conftest -I../../lib -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin14 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_SYNC_BUILTINS conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L. -L/usr/local/lib -arch x86_64 -arch i386 -lruby.2.0.0 ../../lib/libnotmuch.dylib -lpthread -ldl -lobjc " +ld: warning: directory not found for option '-L/usr/local/lib' +ld: warning: directory not found for option '-L/usr/local/lib' +ld: warning: ignoring file ../../lib/libnotmuch.dylib, file was built for x86_64 which is not the architecture being linked (i386): ../../lib/libnotmuch.dylib +Undefined symbols for architecture i386: + "_notmuch_database_create", referenced from: + _t in conftest-2cad94.o +ld: symbol(s) not found for architecture i386 +clang: error: linker command failed with exit code 1 (use -v to see invocation) +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int t(void) { void ((*volatile p)()); p = (void ((*)()))notmuch_database_create; return 0; } + 8: int main(int argc, char **argv) + 9: { +10: if (argc > 1000000) { +11: printf("%p", &t); +12: } +13: +14: return 0; +15: } +/* end */ + +"xcrun clang -o conftest -I../../lib -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin14 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_SYNC_BUILTINS conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L. -L/usr/local/lib -arch x86_64 -arch i386 -lruby.2.0.0 ../../lib/libnotmuch.dylib -lpthread -ldl -lobjc " +conftest.c:7:39: error: too few arguments to function call, expected 2, have 0 +int t(void) { notmuch_database_create(); return 0; } + ~~~~~~~~~~~~~~~~~~~~~~~ ^ +../../lib/notmuch.h:234:1: note: 'notmuch_database_create' declared here +notmuch_status_t +^ +1 error generated. +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int t(void) { notmuch_database_create(); return 0; } + 8: int main(int argc, char **argv) + 9: { +10: if (argc > 1000000) { +11: printf("%p", &t); +12: } +13: +14: return 0; +15: } +/* end */ + +-------------------- + + +--=-=-= +Content-Type: text/plain + + +On Sat, Jun 13, 2015 at 10:58 PM, David Bremner 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@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch + +--=-=-=-- -- 2.26.2