From 35c198a3fb203eef3d7c89bf54667b5b2e0aef57 Mon Sep 17 00:00:00 2001 From: ignisf Date: Sun, 6 Jan 2013 11:58:14 +0200 Subject: [PATCH 1/4] Add no-strict-aliasing to FreeBSD/gcc42 builds Remove the patch that was not getting applied on rake build on a buildhost and add a conditional make flag in builder.rb. This commit fixes #68 --- Rakefile | 1 - ext/libv8/builder.rb | 5 ++++- patches/gcc42-on-freebsd.patch | 14 -------------- 3 files changed, 4 insertions(+), 16 deletions(-) delete mode 100644 patches/gcc42-on-freebsd.patch diff --git a/Rakefile b/Rakefile index ebd36412..052db0f0 100644 --- a/Rakefile +++ b/Rakefile @@ -28,7 +28,6 @@ task :checkout do # Based on: https://chromiumcodereview.appspot.com/10079030/patch/1/2 sh "patch -N -p0 -d vendor/v8 < patches/add-freebsd9-and-freebsd10-to-gyp-GetFlavor.patch" sh "patch -N -p1 -d vendor/v8 < patches/fPIC-on-x64.patch" - sh "patch -N -p1 -d vendor/v8 < patches/gcc42-on-freebsd.patch" if RUBY_PLATFORM.include?("freebsd") && !system("pkg_info | grep gcc-4") end desc "compile v8 via the ruby extension mechanism" diff --git a/ext/libv8/builder.rb b/ext/libv8/builder.rb index 33ac22b7..a7671ee3 100644 --- a/ext/libv8/builder.rb +++ b/ext/libv8/builder.rb @@ -11,8 +11,11 @@ class Builder def build_libv8! profile = enable_config('debug') ? 'debug' : 'release' + gypflags = ["-Dhost_arch=#{libv8_arch}"] + gypflags << "-Dv8_no_strict_aliasing=1" if RUBY_PLATFORM.include?("freebsd") && !check_gcc_compiler(compiler) + Dir.chdir(File.expand_path '../../../vendor/v8', __FILE__) do - puts `env CXX=#{compiler} LINK=#{compiler} #{make} #{libv8_arch}.#{profile} GYPFLAGS="-Dhost_arch=#{libv8_arch}"` + puts `env CXX=#{compiler} LINK=#{compiler} #{make} #{libv8_arch}.#{profile} GYPFLAGS="#{gypflags.join ' '}"` end return $?.exitstatus end diff --git a/patches/gcc42-on-freebsd.patch b/patches/gcc42-on-freebsd.patch deleted file mode 100644 index c353c27d..00000000 --- a/patches/gcc42-on-freebsd.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/build/standalone.gypi b/build/standalone.gypi -index ebdf557..c7a59bc 100644 ---- a/build/standalone.gypi -+++ b/build/standalone.gypi -@@ -98,6 +98,9 @@ - [ 'OS=="linux"', { - 'cflags': [ '-ansi' ], - }], -+ [ 'OS=="freebsd"', { -+ 'cflags': [ '-fno-strict-aliasing', ], -+ }], - [ 'visibility=="hidden"', { - 'cflags': [ '-fvisibility=hidden' ], - }], From 3019c31d833afd1e1e3f37750a0f2611a6159c9b Mon Sep 17 00:00:00 2001 From: ignisf Date: Mon, 7 Jan 2013 04:26:54 +0200 Subject: [PATCH 2/4] Add methods for make flags to Libv8::Builder --- ext/libv8/builder.rb | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/ext/libv8/builder.rb b/ext/libv8/builder.rb index a7671ee3..58068c33 100644 --- a/ext/libv8/builder.rb +++ b/ext/libv8/builder.rb @@ -1,3 +1,4 @@ +require 'mkmf' require File.expand_path '../compiler', __FILE__ require File.expand_path '../arch', __FILE__ require File.expand_path '../make', __FILE__ @@ -8,14 +9,28 @@ class Builder include Libv8::Compiler include Libv8::Make - def build_libv8! + def gyp_flags(*flags) + # Fix a compilation failure under MacOS. + # See https://groups.google.com/d/topic/v8-users/Oj-efHLjygc/discussion + flags << "-Dhost_arch=#{libv8_arch}" if RUBY_PLATFORM.include?("darwin") + + # FreeBSD uses gcc 4.2 by default which leads to + # compilation failures due to warnings about aliasing. + flags << "-Dv8_no_strict_aliasing=1" if RUBY_PLATFORM.include?("freebsd") and !check_gcc_compiler(compiler) + + %Q(GYPFLAGS+="#{flags.join(' ')}") unless flags.empty? + end + + def make_flags(*flags) profile = enable_config('debug') ? 'debug' : 'release' + flags << gyp_flags - gypflags = ["-Dhost_arch=#{libv8_arch}"] - gypflags << "-Dv8_no_strict_aliasing=1" if RUBY_PLATFORM.include?("freebsd") && !check_gcc_compiler(compiler) + "#{libv8_arch}.#{profile} #{flags.join ' '}" + end + def build_libv8! Dir.chdir(File.expand_path '../../../vendor/v8', __FILE__) do - puts `env CXX=#{compiler} LINK=#{compiler} #{make} #{libv8_arch}.#{profile} GYPFLAGS="#{gypflags.join ' '}"` + puts `env CXX=#{compiler} LINK=#{compiler} #{make} #{make_flags}` end return $?.exitstatus end From 754fd12de50e9570fb7650207785ca69e185aaa7 Mon Sep 17 00:00:00 2001 From: ignisf Date: Mon, 7 Jan 2013 05:05:37 +0200 Subject: [PATCH 3/4] Get rid of GYPFLAGS modifications The issue in v8 that prevented successful builds under MacOS has been resolved and this makes GYPFLAGS modification unnecessary. (see https://github.com/cowboyd/libv8/pull/71#issuecomment-11937331) --- Rakefile | 2 +- ext/libv8/builder.rb | 16 ++++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Rakefile b/Rakefile index 052db0f0..09d8041c 100644 --- a/Rakefile +++ b/Rakefile @@ -41,7 +41,7 @@ task :manual_compile do require File.expand_path '../ext/libv8/arch.rb', __FILE__ include Libv8::Arch Dir.chdir(V8_Source) do - sh %Q{#{make} -j2 #{libv8_arch}.release GYPFLAGS="-Dhost_arch=#{libv8_arch}"} + sh %Q{#{make} -j2 #{libv8_arch}.release} end end diff --git a/ext/libv8/builder.rb b/ext/libv8/builder.rb index 58068c33..3689c22f 100644 --- a/ext/libv8/builder.rb +++ b/ext/libv8/builder.rb @@ -9,21 +9,13 @@ class Builder include Libv8::Compiler include Libv8::Make - def gyp_flags(*flags) - # Fix a compilation failure under MacOS. - # See https://groups.google.com/d/topic/v8-users/Oj-efHLjygc/discussion - flags << "-Dhost_arch=#{libv8_arch}" if RUBY_PLATFORM.include?("darwin") + def make_flags(*flags) + profile = enable_config('debug') ? 'debug' : 'release' # FreeBSD uses gcc 4.2 by default which leads to # compilation failures due to warnings about aliasing. - flags << "-Dv8_no_strict_aliasing=1" if RUBY_PLATFORM.include?("freebsd") and !check_gcc_compiler(compiler) - - %Q(GYPFLAGS+="#{flags.join(' ')}") unless flags.empty? - end - - def make_flags(*flags) - profile = enable_config('debug') ? 'debug' : 'release' - flags << gyp_flags + # http://svnweb.freebsd.org/ports/head/lang/v8/Makefile?view=markup + flags << "strictaliasing=off" if RUBY_PLATFORM.include?("freebsd") and !check_gcc_compiler(compiler) "#{libv8_arch}.#{profile} #{flags.join ' '}" end From 98715b976fa605cb5aa7e1363fb93a6da56f6039 Mon Sep 17 00:00:00 2001 From: ignisf Date: Mon, 7 Jan 2013 06:12:35 +0200 Subject: [PATCH 4/4] Dispose of unecessary patches. --- lib/libv8/fpic-on-freebsd-amd64.patch | 16 ---------------- patches/src_platform-freebsd.cc.patch | 10 ---------- 2 files changed, 26 deletions(-) delete mode 100644 lib/libv8/fpic-on-freebsd-amd64.patch delete mode 100644 patches/src_platform-freebsd.cc.patch diff --git a/lib/libv8/fpic-on-freebsd-amd64.patch b/lib/libv8/fpic-on-freebsd-amd64.patch deleted file mode 100644 index b5a7c39b..00000000 --- a/lib/libv8/fpic-on-freebsd-amd64.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/SConstruct b/SConstruct -index 4a7e182..b462335 100644 ---- a/SConstruct -+++ b/SConstruct -@@ -124,6 +124,10 @@ LIBRARY_FLAGS = { - 'LIBPATH' : ['/usr/local/lib'], - 'CCFLAGS': ['-ansi'], -- 'LIBS': ['execinfo'] -+ 'LIBS': ['execinfo'], -+ 'arch:x64': { -+ 'CCFLAGS': ['-fPIC'], -+ 'CXXFLAGS': ['-fPIC'] -+ }, - }, - 'os:openbsd': { - 'CPPPATH' : ['/usr/local/include'], diff --git a/patches/src_platform-freebsd.cc.patch b/patches/src_platform-freebsd.cc.patch deleted file mode 100644 index adc671eb..00000000 --- a/patches/src_platform-freebsd.cc.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- src/platform-freebsd.cc.orig 2012-05-12 16:47:50.556202492 +0100 -+++ src/platform-freebsd.cc 2012-05-12 16:37:59.924934272 +0100 -@@ -554,6 +554,7 @@ - ASSERT(result == 0); - result = pthread_mutex_init(&mutex_, &attrs); - ASSERT(result == 0); -+ USE(result); - } - - virtual ~FreeBSDMutex() { pthread_mutex_destroy(&mutex_); }