Thanks for the reply Jakob.
The following patch, also at https://gist.github.com/2160061, allows me to build it for Mac OS X in 64bits mode using GYP. Would be great if others confirm it works for them as well. Let me know if there's anything else I need to do. >From d5a233f86a9268d68c57b2a2f1ee0fd379bcf9d6 Mon Sep 17 00:00:00 2001 From: Filipe David Borba Manana <[email protected]> Date: Thu, 22 Mar 2012 18:55:35 +0000 Subject: [PATCH] Add support for Mac OS X 64bit builds with GYP Example: $ export GYP_GENERATORS=make $ make dependencies $ make -j 8 library=shared x64.release --- Makefile | 2 +- build/common.gypi | 34 ++++++++++++++++++++++++++++++++++ tools/gyp/v8.gyp | 10 ++++++++-- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 5dc6ca5..e4e36d8 100644 --- a/Makefile +++ b/Makefile @@ -260,4 +260,4 @@ $(ENVFILE).new: # Dependencies. dependencies: svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp \ - --revision 1026 + --revision 1251 diff --git a/build/common.gypi b/build/common.gypi index 5c0c323..deed625 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -317,6 +317,22 @@ 'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused- parameter', '-Wnon-virtual-dtor', '-Woverloaded- virtual' ], }], + ['OS=="mac" and target_arch=="ia32"', { + 'xcode_settings': { + 'ARCHS': ['i386'], + 'OTHER_CFLAGS': ['-m32'], + 'OTHER_CXXFLAGS': ['-m32'], + 'OTHER_LDFLAGS': ['-m32'] + }, + }], + ['OS=="mac" and target_arch=="x64"', { + 'xcode_settings': { + 'ARCHS': ['x86_64'], + 'OTHER_CFLAGS': ['-m64'], + 'OTHER_CXXFLAGS': ['-m64'], + 'OTHER_LDFLAGS': ['-m64'] + }, + }], ], }, # Debug 'Release': { @@ -358,6 +374,24 @@ # is specified explicitly. 'GCC_STRICT_ALIASING': 'YES', }, + 'conditions': [ + ['target_arch=="ia32"', { + 'xcode_settings': { + 'ARCHS': ['i386'], + 'OTHER_CFLAGS': ['-m32'], + 'OTHER_CXXFLAGS': ['-m32'], + 'OTHER_LDFLAGS': ['-m32'] + }, + }], + ['target_arch=="x64"', { + 'xcode_settings': { + 'ARCHS': ['x86_64'], + 'OTHER_CFLAGS': ['-m64'], + 'OTHER_CXXFLAGS': ['-m64'], + 'OTHER_LDFLAGS': ['-m64'] + }, + }], + ], }], # OS=="mac" ['OS=="win"', { 'msvs_configuration_attributes': { diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp index 764789a..2913cdf 100644 --- a/tools/gyp/v8.gyp +++ b/tools/gyp/v8.gyp @@ -59,6 +59,9 @@ '../../src/v8dll-main.cc', ], 'conditions': [ + ['OS=="mac"', { + 'xcode_settings': {'OTHER_LDFLAGS': ['-dynamiclib', '-all_load']}, + }], ['OS=="win"', { 'defines': [ 'BUILDING_V8_SHARED', @@ -536,7 +539,7 @@ '../../src/arm/stub-cache-arm.cc', ], }], - ['v8_target_arch=="ia32" or v8_target_arch=="mac" or OS=="mac"', { + ['v8_target_arch=="ia32"', { 'sources': [ '../../src/ia32/assembler-ia32-inl.h', '../../src/ia32/assembler-ia32.cc', @@ -601,7 +604,7 @@ '../../src/mips/stub-cache-mips.cc', ], }], - ['v8_target_arch=="x64" or v8_target_arch=="mac" or OS=="mac"', { + ['v8_target_arch=="x64"', { 'sources': [ '../../src/x64/assembler-x64-inl.h', '../../src/x64/assembler-x64.cc', @@ -982,6 +985,9 @@ }, { 'toolsets': ['target'], }], + ['OS=="mac" and component=="shared_library"', { + 'xcode_settings': {'OTHER_LDFLAGS': ['-dynamiclib', '- all_load']}, + }], ], 'link_settings': { 'libraries': [ -- 1.7.9.1 On Mar 19, 7:38 pm, Jakob Kummerow <[email protected]> wrote: > To quotehttp://code.google.com/p/v8/wiki/BuildingWithGYP: > > "Notes: > > - trying to build x64 targets on Mac currently fails." > > We'd happily accept patches if you have the time to investigate and fix > this :-) > > You should be able to build 32bit binaries on Mac using GYP just fine. This > is probably also what the "native" target chooses (though I haven't > verified that). > > > > > > > > On Mon, Mar 19, 2012 at 19:39, fdmanana <[email protected]> wrote: > > Forgot to mention that this happens even with latest master, not just > > the 3.9.7 tag. > > > On Mar 19, 6:38 pm, fdmanana <[email protected]> wrote: > > > Hi, > > > > I've been trying to build V8 with GYP, but so far unsuccessful (scons > > > works perfectly btw). > > > > This is on Mac OS X Lion: > > > > $ uname -a > > > Darwin dorian-2.lan 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 > > > 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64 > > > > $ g++ --version > > > i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. > > > build 5658) (LLVM build 2335.15.00) > > > Copyright (C) 2007 Free Software Foundation, Inc. > > > This is free software; see the source for copying conditions. There > > > is NO > > > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR > > > PURPOSE. > > > > Explicitly passing the option library=shared makes it impossible to > > > build the x64 target, as it can be seen here: > > > >http://www.pastie.org/3629629 > > > > Not specifying library=shared option, and using the x64.release target > > > I get a bunch of compilation errors: > > > >http://friendpaste.com/34S2vQzwSBqmSdSdKQSDeD > > > > Finally using target native.release allows the build to succeed: > > > >http://friendpaste.com/1GlS5lEnxkqcMpclFptKAs > > > > Which results in 4 archive files inside out/native: > > > > -rw-r--r-- 1 fdmanana staff 957K Mar 19 18:26 libpreparser_lib.a > > > -rw-r--r-- 1 fdmanana staff 112M Mar 19 18:26 libv8_base.a > > > -rw-r--r-- 1 fdmanana staff 937K Mar 19 18:26 libv8_nosnapshot.a > > > -rw-r--r-- 1 fdmanana staff 1.2M Mar 19 18:26 libv8_snapshot.a > > > > However their object files have the wrong architecture (output when > > > compiling the sample hello world program): > > > > $ g++ -o hello hello.cpp -L/Users/fdmanana/git/hub/v8/out/native -I/ > > > Users/fdmanana/git/hub/v8/include -lv8_base -lv8_nosnapshot - > > > lpreparser_lib > > > ld: warning: ignoring file /Users/fdmanana/git/hub/v8/out/native/ > > > libv8_base.a, file was built for archive which is not the architecture > > > being linked (x86_64) > > > ld: warning: ignoring file /Users/fdmanana/git/hub/v8/out/native/ > > > libv8_nosnapshot.a, file was built for archive which is not the > > > architecture being linked (x86_64) > > > ld: warning: ignoring file /Users/fdmanana/git/hub/v8/out/native/ > > > libpreparser_lib.a, file was built for archive which is not the > > > architecture being linked (x86_64) > > > Undefined symbols for architecture x86_64: > > > "v8::HandleScope::HandleScope()", referenced from: > > > _main in ccHhUcyB.o > > > "v8::Context::New(v8::ExtensionConfiguration*, > > > v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Value>)", referenced > > > from: > > > _main in ccHhUcyB.o > > > "v8::String::New(char const*, int)", referenced from: > > > _main in ccHhUcyB.o > > > "v8::Script::Compile(v8::Handle<v8::String>, v8::ScriptOrigin*, > > > v8::ScriptData*, v8::Handle<v8::String>)", referenced from: > > > _main in ccHhUcyB.o > > > "v8::Script::Run()", referenced from: > > > _main in ccHhUcyB.o > > > "v8::String::AsciiValue::AsciiValue(v8::Handle<v8::Value>)", > > > referenced from: > > > _main in ccHhUcyB.o > > > "v8::String::AsciiValue::~AsciiValue()", referenced from: > > > _main in ccHhUcyB.o > > > "v8::HandleScope::~HandleScope()", referenced from: > > > _main in ccHhUcyB.o > > > "v8::Context::Enter()", referenced from: > > > v8::Context::Scope::Scope(v8::Handle<v8::Context>)in ccHhUcyB.o > > > "v8::V8::DisposeGlobal(v8::internal::Object**)", referenced from: > > > v8::Persistent<v8::Context>::Dispose() in ccHhUcyB.o > > > "v8::Context::Exit()", referenced from: > > > v8::Context::Scope::~Scope()in ccHhUcyB.o > > > ld: symbol(s) not found for architecture x86_64 > > > collect2: ld returned 1 exit status > > > > Are these known problems? Besides using the old scons way, is there > > > anything else I can do? > > > > Thanks. > > > -- > > v8-users mailing list > > [email protected] > >http://groups.google.com/group/v8-users -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
