From ecc956d2c769466fd6dccbeb4e1f5d1540095880 Mon Sep 17 00:00:00 2001
From: ignisf <bordjukov@gmail.com>
Date: Wed, 9 Jan 2013 11:53:34 +0200
Subject: [PATCH] Fix Malformed archive issue

GYP creates thin archives by default which makes using the binary
version of the gem impossible.
---
 Rakefile             | 2 +-
 ext/libv8/builder.rb | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/Rakefile b/Rakefile
index a7daee0..16bb5c6 100644
--- a/Rakefile
+++ b/Rakefile
@@ -36,7 +36,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}
+    sh %Q{#{make} -j2 #{libv8_arch}.release ARFLAGS.target=crs}
   end
 end
 
diff --git a/ext/libv8/builder.rb b/ext/libv8/builder.rb
index 3689c22..3ce9425 100644
--- a/ext/libv8/builder.rb
+++ b/ext/libv8/builder.rb
@@ -17,6 +17,10 @@ module Libv8
       # http://svnweb.freebsd.org/ports/head/lang/v8/Makefile?view=markup
       flags << "strictaliasing=off" if RUBY_PLATFORM.include?("freebsd") and !check_gcc_compiler(compiler)
 
+      # Fix Malformed archive issue caused by GYP creating thin archives by
+      # default.
+      flags << "ARFLAGS.target=crs"
+
       "#{libv8_arch}.#{profile} #{flags.join ' '}"
     end