Re: ruby: building with CFLAGS="something"

Subject: Re: ruby: building with CFLAGS="something"

Date: Sun, 16 May 2021 13:41:24 -0500

To: David Bremner

Cc: notmuch@notmuchmail.org

From: Felipe Contreras


On Sun, May 16, 2021 at 7:28 AM David Bremner <david@tethera.net> wrote:
>
>
> 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:

That's because -fPIC is needed.

The way Ruby's mkmf generates the Makefile is wrong, because it should do:

  override CFLAGS+=-fPIC

So that the user can specify other CFLAGS.

However, we can fix that by doing that ourselves:

--- 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
+       $(MAKE) -C $(dir)/ruby CFLAGS="$(CFLAGS) -pipe -fno-plt -fPIC"
 endif

We lose -march=x86-64 -mtune=generic (at least on my machine), but I
guess that's not a big deal since libnotmuch itself isn't getting
compiled with those.

I'll send a patch soonish.

-- 
Felipe Contreras
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: