Reviewers: iposva,

Description:
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().


Please review this at http://codereview.chromium.org/126241

SVN Base: http://v8.googlecode.com/svn/trunk/

Affected files:
   M     SConstruct
   M     src/platform-macos.cc


Index: src/platform-macos.cc
===================================================================
--- src/platform-macos.cc       (revision 2055)
+++ src/platform-macos.cc       (working copy)
@@ -35,10 +35,6 @@

  #include <AvailabilityMacros.h>

-#ifdef MAC_OS_X_VERSION_10_5
-# include <execinfo.h>  // backtrace, backtrace_symbols
-#endif
-
  #include <pthread.h>
  #include <semaphore.h>
  #include <signal.h>
@@ -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::StackWalk(Vector<StackFrame> 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<void*>(frames_size);
    int frames_count = backtrace(addresses, frames_size);
@@ -244,7 +252,6 @@
    free(symbols);

    return frames_count;
-#endif
  }


Index: SConstruct
===================================================================
--- SConstruct  (revision 2055)
+++ SConstruct  (working copy)
@@ -125,7 +125,9 @@
        }
      },
      'os:macos': {
-      'CCFLAGS':      ['-ansi'],
+      'CCFLAGS':      ['-ansi', '-mmacosx-version-min=10.4'],
+      'CPPDEFINES':    
[['MAC_OS_X_VERSION_MIN_REQUIRED', 'MAC_OS_X_VERSION_10_4'],
+                      ['OS_MACOSX', 'OS_MACOSX']]
      },
      'os:freebsd': {
        'CCFLAGS':      ['-ansi'],
@@ -638,7 +640,7 @@

  def GetVersion():
    version_components = GetVersionComponents()
-
+
    if version_components[len(version_components) - 1] == '0':
      version_components.pop()
    return '.'.join(version_components)
@@ -646,10 +648,10 @@

  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:



--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to