Skip to contentSkip to conversation

ruby: fix 'pcrel too far' build problem on SuperH architectures

PATCH New Thomas De Schampheleire 2 participants 5 messages Oct 13, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ruby: fix 'pcrel too far' build problem on SuperH architectures

The 'pcrel too far' problem detected in the autobuild on SuperH architectures, seems to be caused by the -Os optimization flag. Using standard optimization fixes the problem.

Fixes http://autobuild.buildroot.net/results/bc36e051e06f596c2fafdd3cc3745bb34b73ace3/

---
 package/ruby/ruby.mk |  7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
package/ruby/ruby.mk +7 -0
@@ -15,6 +15,13 @@ HOST_RUBY_CONF_OPT = --disable-install-d
 RUBY_LICENSE = Ruby or BSD-2c, BSD-3c, others
 RUBY_LICENSE_FILES = LEGAL COPYING BSDL
 
+# With some SuperH toolchains (like Sourcery CodeBench 2012.09), ruby fails to
+# build with 'pcrel too far'. This seems to be caused by the -Os option we pass
+# by default. To fix the problem, use standard -O2 optimization instead.
+ifeq ($(BR2_sh)$(BR2_sh64),y)
+TARGET_CFLAGS += -O2
+endif
+
 # Force optionals to build before we do
 ifeq ($(BR2_PACKAGE_BERKELEYDB),y)
 	RUBY_DEPENDENCIES += berkeleydb
#1 lore raw

PATCH 1/1 ruby: fix 'pcrel too far' build problem on SuperH architectures

Dear Thomas De Schampheleire,

package/ruby/ruby.mk HOST_RUBY_CONF_OPT = --disable-install-d · line 23

Quoted 6 lines · Thomas De Schampheleire
package/ruby/ruby.mk +6 -0
+# With some SuperH toolchains (like Sourcery CodeBench 2012.09), ruby fails to
+# build with 'pcrel too far'. This seems to be caused by the -Os option we pass
+# by default. To fix the problem, use standard -O2 optimization instead.
+ifeq ($(BR2_sh)$(BR2_sh64),y)
+TARGET_CFLAGS += -O2
+endif

I don't think it's the right way of fixing the problem. This is going to affect the CFLAGS of *all* packages. You shouldn't change TARGET_CFLAGS, but instead do:

RUBY_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -O2"

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 ruby: fix 'pcrel too far' build problem on SuperH architectures

Hi Thomas,

Quoted 15 lines · Thomas Petazzoni

Dear Thomas De Schampheleire,

package/ruby/ruby.mk HOST_RUBY_CONF_OPT = --disable-install-d · line 23

Quoted 6 lines · Thomas De Schampheleire
package/ruby/ruby.mk +6 -0
+# With some SuperH toolchains (like Sourcery CodeBench 2012.09), ruby fails to
+# build with 'pcrel too far'. This seems to be caused by the -Os option we pass
+# by default. To fix the problem, use standard -O2 optimization instead.
+ifeq ($(BR2_sh)$(BR2_sh64),y)
+TARGET_CFLAGS += -O2
+endif

I don't think it's the right way of fixing the problem. This is going to affect the CFLAGS of *all* packages. You shouldn't change TARGET_CFLAGS, but instead do:

Quoted 1 line

RUBY_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -O2"

Ah yes, you're right. The above was what I proposed initially, but I tried to be too smart.
I was looking for a way to avoid duplicating TARGET_CFLAGS, because if someone needs to add a new cflag for ruby specifically, they now need to explicitly take the superh case into account.

I'll send a new version.

Thanks,
Thomas

#3 lore raw

PATCH 1/1 ruby: fix 'pcrel too far' build problem on SuperH architectures

Dear Thomas De Schampheleire,

Quoted 6 lines · Thomas De Schampheleire
Quoted 5 lines

I don't think it's the right way of fixing the problem. This is going to affect the CFLAGS of *all* packages. You shouldn't change TARGET_CFLAGS, but instead do:

RUBY_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -O2"

Quoted 7 lines

Ah yes, you're right. The above was what I proposed initially, but I tried to be too smart.
I was looking for a way to avoid duplicating TARGET_CFLAGS, because if someone needs to add a new cflag for ruby specifically, they now need to explicitly take the superh case into account.

I'll send a new version.

The way we usually do this is:

RUBY_CFLAGS = $(TARGET_CFLAGS)

ifeq ($(BR2_sh)$(BR2_sh64),y)
RUBY_CFLAGS += -O2
endif

RUBY_CONF_ENV += CFLAGS="$(RUBY_CFLAGS)"

This way, someone else can easily add another RUBY_CFLAGS +=, and not worry about the SuperH thing.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#4 lore raw

PATCH 1/1 ruby: fix 'pcrel too far' build problem on SuperH architectures

Quoted 22 lines · Thomas Petazzoni

Dear Thomas De Schampheleire,

Quoted 6 lines · Thomas De Schampheleire
Quoted 5 lines

I don't think it's the right way of fixing the problem. This is going to affect the CFLAGS of *all* packages. You shouldn't change TARGET_CFLAGS, but instead do:

RUBY_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -O2"

Quoted 7 lines

Ah yes, you're right. The above was what I proposed initially, but I tried to be too smart.
I was looking for a way to avoid duplicating TARGET_CFLAGS, because if someone needs to add a new cflag for ruby specifically, they now need to explicitly take the superh case into account.

I'll send a new version.

The way we usually do this is:

RUBY_CFLAGS = $(TARGET_CFLAGS)

Quoted 8 lines

ifeq ($(BR2_sh)$(BR2_sh64),y)
RUBY_CFLAGS += -O2
endif

RUBY_CONF_ENV += CFLAGS="$(RUBY_CFLAGS)"

This way, someone else can easily add another RUBY_CFLAGS +=, and not worry about the SuperH thing.

Ok, that indeed looks better. I'll send a third version later.

Thanks for your feedback,
Thomas