From 5253363cc221d1935d9046dc9a4fae7218355c61 Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Thu, 5 Jan 2012 12:17:08 +0000 Subject: [PATCH] Add netbsd support to gyp build. Review URL: http://codereview.chromium.org/9071004 Patch from Matthew Sporleder . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10341 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- build/common.gypi | 15 +++++++++++---- build/standalone.gypi | 24 +++++++++++++++--------- src/d8-posix.cc | 3 ++- src/d8.gyp | 4 ++-- src/platform-openbsd.cc | 21 +++++++++++++++++---- tools/gyp/v8.gyp | 13 ++++++++++++- 6 files changed, 59 insertions(+), 21 deletions(-) diff --git a/build/common.gypi b/build/common.gypi index 9129d0170c..7aab91356a 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -1,4 +1,4 @@ -# Copyright 2011 the V8 project authors. All rights reserved. +# Copyright 2012 the V8 project authors. All rights reserved. # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: @@ -215,7 +215,8 @@ }, }, }], - ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', { + ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \ + or OS=="netbsd"', { 'conditions': [ [ 'target_arch=="ia32"', { 'cflags': [ '-m32' ], @@ -259,7 +260,10 @@ ['OS=="freebsd" or OS=="openbsd"', { 'cflags': [ '-I/usr/local/include' ], }], - ['OS=="linux" or OS=="freebsd" or OS=="openbsd"', { + ['OS=="netbsd"', { + 'cflags': [ '-I/usr/pkg/include' ], + }], + ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', { 'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter', '-Wnon-virtual-dtor' ], }], @@ -267,7 +271,7 @@ }, 'Release': { 'conditions': [ - ['OS=="linux" or OS=="freebsd" or OS=="openbsd"', { + ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', { 'cflags!': [ '-O2', '-Os', @@ -290,6 +294,9 @@ ['OS=="freebsd" or OS=="openbsd"', { 'cflags': [ '-I/usr/local/include' ], }], + ['OS=="netbsd"', { + 'cflags': [ '-I/usr/pkg/include' ], + }], ['OS=="mac"', { 'xcode_settings': { 'GCC_OPTIMIZATION_LEVEL': '3', # -O3 diff --git a/build/standalone.gypi b/build/standalone.gypi index 4297f5c84a..86f6d46092 100644 --- a/build/standalone.gypi +++ b/build/standalone.gypi @@ -1,4 +1,4 @@ -# Copyright 2011 the V8 project authors. All rights reserved. +# Copyright 2012 the V8 project authors. All rights reserved. # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: @@ -37,13 +37,16 @@ 'variables': { 'variables': { 'conditions': [ - [ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', { - # This handles the Linux platforms we generally deal with. Anything - # else gets passed through, which probably won't work very well; such - # hosts should pass an explicit target_arch to gyp. + ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', { + # This handles the Linux platforms we generally deal with. + # Anything else gets passed through, which probably won't work + # very well; such hosts should pass an explicit target_arch + # to gyp. 'host_arch%': - ' GetStdout(int child_fd, // We're disabling usage of waitid in Mac OS X because it doens't work for us: // a parent process hangs on waiting while a child process is already a zombie. // See http://code.google.com/p/v8/issues/detail?id=401. -#if defined(WNOWAIT) && !defined(ANDROID) && !defined(__APPLE__) +#if defined(WNOWAIT) && !defined(ANDROID) && !defined(__APPLE__) \ + && !defined(__NetBSD__) #if !defined(__FreeBSD__) #define HAS_WAITID 1 #endif diff --git a/src/d8.gyp b/src/d8.gyp index bdc23a20e9..a096af35b8 100644 --- a/src/d8.gyp +++ b/src/d8.gyp @@ -64,8 +64,8 @@ 'libraries': [ '-lreadline', ], 'sources': [ 'd8-readline.cc' ], }], - [ '(OS=="linux" or OS=="mac" or OS=="freebsd" \ - or OS=="openbsd" or OS=="solaris" or OS=="android")', { + ['(OS=="linux" or OS=="mac" or OS=="freebsd" or OS=="netbsd" \ + or OS=="openbsd" or OS=="solaris" or OS=="android")', { 'sources': [ 'd8-posix.cc', ] }], [ 'OS=="win"', { diff --git a/src/platform-openbsd.cc b/src/platform-openbsd.cc index b3f4924eee..772d08b587 100644 --- a/src/platform-openbsd.cc +++ b/src/platform-openbsd.cc @@ -25,8 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Platform specific code for OpenBSD goes here. For the POSIX comaptible parts -// the implementation is in platform-posix.cc. +// Platform specific code for OpenBSD and NetBSD goes here. For the POSIX +// comaptible parts the implementation is in platform-posix.cc. #include #include @@ -742,8 +742,20 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { if (sample == NULL) sample = &sample_obj; // Extracting the sample from the context is extremely machine dependent. - ucontext_t* ucontext = reinterpret_cast(context); sample->state = isolate->current_vm_state(); + ucontext_t* ucontext = reinterpret_cast(context); +#ifdef __NetBSD__ + mcontext_t& mcontext = ucontext->uc_mcontext; +#if V8_HOST_ARCH_IA32 + sample->pc = reinterpret_cast
(mcontext.__gregs[_REG_EIP]); + sample->sp = reinterpret_cast
(mcontext.__gregs[_REG_ESP]); + sample->fp = reinterpret_cast
(mcontext.__gregs[_REG_EBP]); +#elif V8_HOST_ARCH_X64 + sample->pc = reinterpret_cast
(mcontext.__gregs[_REG_RIP]); + sample->sp = reinterpret_cast
(mcontext.__gregs[_REG_RSP]); + sample->fp = reinterpret_cast
(mcontext.__gregs[_REG_RBP]); +#endif // V8_HOST_ARCH +#else // OpenBSD #if V8_HOST_ARCH_IA32 sample->pc = reinterpret_cast
(ucontext->sc_eip); sample->sp = reinterpret_cast
(ucontext->sc_esp); @@ -752,7 +764,8 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { sample->pc = reinterpret_cast
(ucontext->sc_rip); sample->sp = reinterpret_cast
(ucontext->sc_rsp); sample->fp = reinterpret_cast
(ucontext->sc_rbp); -#endif +#endif // V8_HOST_ARCH +#endif // __NetBSD__ sampler->SampleStack(sample); sampler->Tick(sample); } diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp index 66a26b5ed5..57e2cbdf83 100644 --- a/tools/gyp/v8.gyp +++ b/tools/gyp/v8.gyp @@ -1,4 +1,4 @@ -# Copyright 2011 the V8 project authors. All rights reserved. +# Copyright 2012 the V8 project authors. All rights reserved. # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: @@ -684,6 +684,17 @@ ], } ], + ['OS=="netbsd"', { + 'link_settings': { + 'libraries': [ + '-L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lexecinfo', + ]}, + 'sources': [ + '../../src/platform-openbsd.cc', + '../../src/platform-posix.cc' + ], + } + ], ['OS=="solaris"', { 'sources': [ '../../src/platform-solaris.cc',