ruby: building with CFLAGS="something"

Subject: ruby: building with CFLAGS="something"

Date: Sun, 16 May 2021 09:28:35 -0300

To: notmuch@notmuchmail.org

Cc: Felipe Contreras

From: David Bremner


The rest of the (C and C++) codebase supports

    make CFLAGS="-g -O0"

or

    CFLAGS="-g -O0" ./configure
    
but the ruby bindings don't build:

    linking shared-object notmuch.so
    /usr/bin/ld: status.o: warning: relocation against `notmuch_rb_eUnbalancedAtomicError' in read-only section `.text'
    /usr/bin/ld: database.o: relocation R_X86_64_PC32 against symbol `ID_db_create' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: final link failed: bad value
    collect2: error: ld returned 1 exit status
    make[1]: *** [Makefile:262: notmuch.so] Error 1
    make[1]: Leaving directory '/home/bremner/software/upstream/notmuch/bindings/ruby'
    make: *** [bindings/Makefile.local:9: ruby-bindings] Error 2

It would be nice if bindings/ruby/Makefile could be made to confirm to
the notmuch conventions, but since it's autogenerated I don't know how
realistic that is.  Failing that we could think about adjusting the
notmuch build system, ideally conforming to some standard-ish
behaviour.

I guess a hack that might work is to unset the corresponding variables
in the shim bindings/Makefile.local; something like the following, but
more portable

diff --git a/bindings/Makefile.local b/bindings/Makefile.local
index bc960bbc..8e3cd051 100644
--- a/bindings/Makefile.local
+++ b/bindings/Makefile.local
@@ -10,7 +10,7 @@ ifeq ($(HAVE_RUBY_DEV),1)
                LIBNOTMUCH="../../lib/$(LINKER_NAME)" \
                NOTMUCH_SRCDIR='$(NOTMUCH_SRCDIR)' \
                $(RUBY) extconf.rb --vendor
-       $(MAKE) -C $(dir)/ruby
+       env -u CFLAGS $(MAKE) -C $(dir)/ruby
 endif
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: