From 529c3a0a9f62196f8a29bcedb77e09567f3167b7 Mon Sep 17 00:00:00 2001 From: "iposva@chromium.org" Date: Thu, 18 Jun 2009 00:22:52 +0000 Subject: [PATCH] Make some small Mac-specific modifications to V8 to make it work on MacOS X 10.4 rather than just 10.5 and up. 1: Set the right compile flags and predefines to get backward compatible Unix system calls. 2: Explicitly weak import the functions in execinfo.h and check at runtime to see if that library loaded before calling backtrace(). Original change submitted by maf@google.com and reviewed at http://codereview.chromium.org/126241. Review URL: http://codereview.chromium.org/132002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2213 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- SConstruct | 8 ++++---- src/platform-macos.cc | 23 +++++++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/SConstruct b/SConstruct index 3b14eea..0baf71b 100644 --- a/SConstruct +++ b/SConstruct @@ -125,7 +125,7 @@ LIBRARY_FLAGS = { } }, 'os:macos': { - 'CCFLAGS': ['-ansi'], + 'CCFLAGS': ['-ansi', '-mmacosx-version-min=10.4'], }, 'os:freebsd': { 'CPPPATH' : ['/usr/local/include'], @@ -641,7 +641,7 @@ def GetVersionComponents(): def GetVersion(): version_components = GetVersionComponents() - + if version_components[len(version_components) - 1] == '0': version_components.pop() return '.'.join(version_components) @@ -649,10 +649,10 @@ def GetVersion(): def GetSpecificSONAME(): SONAME_PATTERN = re.compile(r"#define\s+SONAME\s+\"(.*)\"") - + source = open(join(root_dir, 'src', 'version.cc')).read() match = SONAME_PATTERN.search(source) - + if match: return match.group(1).strip() else: diff --git a/src/platform-macos.cc b/src/platform-macos.cc index 3e0e284..5a0eae2 100644 --- a/src/platform-macos.cc +++ b/src/platform-macos.cc @@ -35,10 +35,6 @@ #include -#ifdef MAC_OS_X_VERSION_10_5 -# include // backtrace, backtrace_symbols -#endif - #include #include #include @@ -58,6 +54,17 @@ #include "platform.h" +// Manually define these here as weak imports, rather than including execinfo.h. +// This lets us launch on 10.4 which does not have these calls. +extern "C" { + extern int backtrace(void**, int) __attribute__((weak_import)); + extern char** backtrace_symbols(void* const*, int) + __attribute__((weak_import)); + extern void backtrace_symbols_fd(void* const*, int, int) + __attribute__((weak_import)); +} + + namespace v8 { namespace internal { @@ -214,9 +221,10 @@ int OS::ActivationFrameAlignment() { int OS::StackWalk(Vector frames) { -#ifndef MAC_OS_X_VERSION_10_5 - return 0; -#else + // If weak link to execinfo lib has failed, ie because we are on 10.4, abort. + if (backtrace == NULL) + return 0; + int frames_size = frames.length(); void** addresses = NewArray(frames_size); int frames_count = backtrace(addresses, frames_size); @@ -244,7 +252,6 @@ int OS::StackWalk(Vector frames) { free(symbols); return frames_count; -#endif } -- 2.7.4