unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] ruby: improve compilation with CFLAGS
@ 2021-05-17  5:47 Felipe Contreras
  2021-05-17  5:50 ` Felipe Contreras
  2021-05-17 10:53 ` David Bremner
  0 siblings, 2 replies; 4+ messages in thread
From: Felipe Contreras @ 2021-05-17  5:47 UTC (permalink / raw)
  To: notmuch; +Cc: Tomi Ollila

The ruby MakeMakefile generates a makefile that is suboptimal, which has
CFLAGS like this:

  CFLAGS   = $(CCDLFLAGS) -march=x86-64 -mtune=generic \
    -O2 -pipe -fno-plt -fPIC $(ARCH_FLAG)

This works as long as the user doesn't modify the Makefile.

Certain flags (namely -fPIC) need to be present regardless of what
CFLAGS are specified.

The Makefile should have done this instead:

  CFLAGS = -march=x86-64 -mtune=generic -O2
  override CFLAGS += $(CCDLFLAGS) -pipe -fno-plt -fPIC $(ARCH_FLAG)

Unfortunately they didn't, so we need to workaround their lack of
foresight.

We can simply add the necessary flags in the parent Makefile so everyone
is happy.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 bindings/Makefile.local | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bindings/Makefile.local b/bindings/Makefile.local
index bc960bbc..3672e69f 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
+	$(MAKE) -C $(dir)/ruby CFLAGS="$(CFLAGS) -pipe -fno-plt -fPIC"
 endif
 
 python-cffi-bindings: lib/$(LINKER_NAME)
-- 
2.31.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ruby: improve compilation with CFLAGS
  2021-05-17  5:47 [PATCH] ruby: improve compilation with CFLAGS Felipe Contreras
@ 2021-05-17  5:50 ` Felipe Contreras
  2021-05-17 10:53 ` David Bremner
  1 sibling, 0 replies; 4+ messages in thread
From: Felipe Contreras @ 2021-05-17  5:50 UTC (permalink / raw)
  To: notmuch@notmuchmail.org; +Cc: Tomi Ollila

On Mon, May 17, 2021 at 12:48 AM Felipe Contreras
<felipe.contreras@gmail.com> wrote:
>
> The ruby MakeMakefile generates a makefile that is suboptimal, which has
> CFLAGS like this:
>
>   CFLAGS   = $(CCDLFLAGS) -march=x86-64 -mtune=generic \
>     -O2 -pipe -fno-plt -fPIC $(ARCH_FLAG)
>
> This works as long as the user doesn't modify the Makefile.

Great... doesn't modify the CFLAGS.

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ruby: improve compilation with CFLAGS
  2021-05-17  5:47 [PATCH] ruby: improve compilation with CFLAGS Felipe Contreras
  2021-05-17  5:50 ` Felipe Contreras
@ 2021-05-17 10:53 ` David Bremner
  2021-05-22 12:24   ` David Bremner
  1 sibling, 1 reply; 4+ messages in thread
From: David Bremner @ 2021-05-17 10:53 UTC (permalink / raw)
  To: Felipe Contreras, notmuch; +Cc: Tomi Ollila

Felipe Contreras <felipe.contreras@gmail.com> writes:

> The ruby MakeMakefile generates a makefile that is suboptimal, which has
> CFLAGS like this:
>
>   CFLAGS   = $(CCDLFLAGS) -march=x86-64 -mtune=generic \
>     -O2 -pipe -fno-plt -fPIC $(ARCH_FLAG)

Ruby 2.7 doesn't seem to add -fno-plt, so this would be a change for
some people building the ruby bindings. The flag is available from gcc
6.x (2016). For clang I guess it is 2017ish. If anyone thinks this is
too recent of a toolchain dependence, now is your chance to object.

d

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ruby: improve compilation with CFLAGS
  2021-05-17 10:53 ` David Bremner
@ 2021-05-22 12:24   ` David Bremner
  0 siblings, 0 replies; 4+ messages in thread
From: David Bremner @ 2021-05-22 12:24 UTC (permalink / raw)
  To: Felipe Contreras, notmuch; +Cc: Tomi Ollila

David Bremner <david@tethera.net> writes:

> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> The ruby MakeMakefile generates a makefile that is suboptimal, which has
>> CFLAGS like this:
>>
>>   CFLAGS   = $(CCDLFLAGS) -march=x86-64 -mtune=generic \
>>     -O2 -pipe -fno-plt -fPIC $(ARCH_FLAG)
>
> Ruby 2.7 doesn't seem to add -fno-plt, so this would be a change for
> some people building the ruby bindings. The flag is available from gcc
> 6.x (2016). For clang I guess it is 2017ish. If anyone thinks this is
> too recent of a toolchain dependence, now is your chance to object.

Nobody complained, so I applied this to master.

d

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-22 12:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17  5:47 [PATCH] ruby: improve compilation with CFLAGS Felipe Contreras
2021-05-17  5:50 ` Felipe Contreras
2021-05-17 10:53 ` David Bremner
2021-05-22 12:24   ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).