From b76e4455060bcacea027124634704b9f07b393e2 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 14 Jun 2015 07:58:44 +0200 Subject: [PATCH] [PATCH] lib, ruby: make use of -Wl,--no-undefined configurable --- 2c/0e74af163e2d314e8d172d31539f24e4f0d26c | 134 ++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 2c/0e74af163e2d314e8d172d31539f24e4f0d26c diff --git a/2c/0e74af163e2d314e8d172d31539f24e4f0d26c b/2c/0e74af163e2d314e8d172d31539f24e4f0d26c new file mode 100644 index 000000000..0667d801d --- /dev/null +++ b/2c/0e74af163e2d314e8d172d31539f24e4f0d26c @@ -0,0 +1,134 @@ +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 394D66DE0948 + for ; Sat, 13 Jun 2015 23:00:10 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.196 +X-Spam-Level: +X-Spam-Status: No, score=0.196 tagged_above=-999 required=5 tests=[AWL=0.186, + T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] 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 hdEzx7CV_8iv for ; + Sat, 13 Jun 2015 23:00:08 -0700 (PDT) +Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net + [87.98.215.224]) + by arlo.cworth.org (Postfix) with ESMTPS id 2107D6DE0350 + for ; Sat, 13 Jun 2015 23:00:07 -0700 (PDT) +Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim + 4.80) (envelope-from ) + id 1Z40x3-0002Yw-UM; Sun, 14 Jun 2015 05:59:25 +0000 +Received: (nullmailer pid 14190 invoked by uid 1000); Sun, 14 Jun 2015 + 05:59:07 -0000 +From: David Bremner +To: David Bremner , notmuch@notmuchmail.org +Subject: [PATCH] lib, ruby: make use of -Wl,--no-undefined configurable +Date: Sun, 14 Jun 2015 07:58:44 +0200 +Message-Id: <1434261524-14139-1-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: <1433142542-2307-3-git-send-email-david@tethera.net> +References: <1433142542-2307-3-git-send-email-david@tethera.net> +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:00:10 -0000 + +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 + -- 2.26.2