Skip to content
Snippets Groups Projects
Commit 9543af05 authored by maf@google.com's avatar maf@google.com
Browse files

Changes needed for MacOS X 10.4 support.

Add "support_macosx_10_4" option to common.gypi that causes it to change deployment target, and define a new preprocessor symbol on the Mac build.  Setting this flag to true is harmless on non Mac builds and has no effect.
Make various changes to source files where they modify their behavior in the presence of the new preprocessor symbol to become 10.4 compatible.
Review URL: http://codereview.chromium.org/201122

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26285 0039d316-1c4b-4281-b951-d872f2087c98
parent a52225ef
No related branches found
No related tags found
No related merge requests found
// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// A file you can include instead of <execinfo.h> if your project might have
// been compiled with our SUPPORT_MACOSX_10_4 flag defined.
// If SUPPORT_MACOSX_10_4 is not defined it just includes execinfo.h as normal,
// otherwise it defines the symbols itself as weak linked imports, which enables
// launching on 10.4 where they are not defined.
#ifndef BASE_COMPAT_EXECINFO_H
#define BASE_COMPAT_EXECINFO_H
#ifdef SUPPORT_MACOSX_10_4
// 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));
}
#else
#include <execinfo.h>
#endif
#endif // BASE_COMPAT_EXECINFO_H
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "base/debug_util.h" #include "base/debug_util.h"
#include <errno.h> #include <errno.h>
#include <execinfo.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <sys/stat.h> #include <sys/stat.h>
...@@ -15,6 +14,7 @@ ...@@ -15,6 +14,7 @@
#include <unistd.h> #include <unistd.h>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/compat_execinfo.h"
#include "base/eintr_wrapper.h" #include "base/eintr_wrapper.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/scoped_ptr.h" #include "base/scoped_ptr.h"
...@@ -116,31 +116,39 @@ void DebugUtil::BreakDebugger() { ...@@ -116,31 +116,39 @@ void DebugUtil::BreakDebugger() {
} }
StackTrace::StackTrace() { StackTrace::StackTrace() {
// Though the backtrace API man page does not list any possible negative if (backtrace == NULL) {
// return values, we take no chance. count_ = 0;
count_ = std::max(backtrace(trace_, arraysize(trace_)), 0); } else {
// Though the backtrace API man page does not list any possible negative
// return values, we take no chance.
count_ = std::max(backtrace(trace_, arraysize(trace_)), 0);
}
} }
void StackTrace::PrintBacktrace() { void StackTrace::PrintBacktrace() {
fflush(stderr); if (backtrace_symbols_fd != NULL) {
backtrace_symbols_fd(trace_, count_, STDERR_FILENO); fflush(stderr);
backtrace_symbols_fd(trace_, count_, STDERR_FILENO);
}
} }
void StackTrace::OutputToStream(std::ostream* os) { void StackTrace::OutputToStream(std::ostream* os) {
scoped_ptr_malloc<char*> trace_symbols(backtrace_symbols(trace_, count_)); if (backtrace_symbols != NULL) {
scoped_ptr_malloc<char*> trace_symbols(backtrace_symbols(trace_, count_));
// If we can't retrieve the symbols, print an error and just dump the raw
// addresses. // If we can't retrieve the symbols, print an error and just dump the raw
if (trace_symbols.get() == NULL) { // addresses.
(*os) << "Unable get symbols for backtrace (" << strerror(errno) if (trace_symbols.get() == NULL) {
<< "). Dumping raw addresses in trace:\n"; (*os) << "Unable get symbols for backtrace (" << strerror(errno)
for (int i = 0; i < count_; ++i) { << "). Dumping raw addresses in trace:\n";
(*os) << "\t" << trace_[i] << "\n"; for (int i = 0; i < count_; ++i) {
} (*os) << "\t" << trace_[i] << "\n";
} else { }
(*os) << "Backtrace:\n"; } else {
for (int i = 0; i < count_; ++i) { (*os) << "Backtrace:\n";
(*os) << "\t" << trace_symbols.get()[i] << "\n"; for (int i = 0; i < count_; ++i) {
(*os) << "\t" << trace_symbols.get()[i] << "\n";
}
} }
} }
} }
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "base/time.h" #include "base/time.h"
#include "unicode/coll.h" #include "unicode/coll.h"
namespace { namespace {
class LocaleAwareComparator { class LocaleAwareComparator {
...@@ -82,7 +83,7 @@ class LocaleAwareComparator { ...@@ -82,7 +83,7 @@ class LocaleAwareComparator {
namespace file_util { namespace file_util {
#if defined(OS_FREEBSD) #if defined(OS_FREEBSD) || defined(SUPPORT_MACOSX_10_4)
typedef struct stat stat_wrapper_t; typedef struct stat stat_wrapper_t;
static int CallStat(const char *path, stat_wrapper_t *sb) { static int CallStat(const char *path, stat_wrapper_t *sb) {
return stat(path, sb); return stat(path, sb);
......
...@@ -52,6 +52,16 @@ ...@@ -52,6 +52,16 @@
# Linux-Mac cross compiler distcc farm. # Linux-Mac cross compiler distcc farm.
'chromium_mac_pch%': 1, 'chromium_mac_pch%': 1,
# We normally expect MacOS X 10.5 at runtime in the product generated.
# Set to 1 to enable MacOS X 10.4 support where possible.
# Harmless to set on other platforms, as it has no effect.
# This is designed so that products such as O3D can use some Chrome source
# without losing 10.4 support.
# Look for support_macosx_10_4 later in the file to see where it turns on
# compile flags, defines SUPPORT_MACOSX_10_4 in the C preprocessor,
# and changes the Xcode deployment target setting.
'support_macosx_10_4%': 0,
# Set to 1 to enable code coverage. In addition to build changes # Set to 1 to enable code coverage. In addition to build changes
# (e.g. extra CFLAGS), also creates a new target in the src/chrome # (e.g. extra CFLAGS), also creates a new target in the src/chrome
# project file called "coverage". # project file called "coverage".
...@@ -611,7 +621,17 @@ ...@@ -611,7 +621,17 @@
'WARNING_CFLAGS': ['-Wall', '-Wendif-labels'], 'WARNING_CFLAGS': ['-Wall', '-Wendif-labels'],
'conditions': [ 'conditions': [
['chromium_mac_pch', {'GCC_PRECOMPILE_PREFIX_HEADER': 'YES'}, ['chromium_mac_pch', {'GCC_PRECOMPILE_PREFIX_HEADER': 'YES'},
{'GCC_PRECOMPILE_PREFIX_HEADER': 'NO'}], {'GCC_PRECOMPILE_PREFIX_HEADER': 'NO'}
],
['support_macosx_10_4',
{
'OTHER_CFLAGS': ['-D', 'SUPPORT_MACOSX_10_4',],
'MACOSX_DEPLOYMENT_TARGET': '10.4', # mmacosx-version-min=10.4
},
{
'MACOSX_DEPLOYMENT_TARGET': '10.5', # mmacosx-version-min=10.5
}
],
], ],
}, },
'target_conditions': [ 'target_conditions': [
......
...@@ -145,6 +145,7 @@ hooks = [ ...@@ -145,6 +145,7 @@ hooks = [
{ {
# A change to a .gyp, .gypi, or to GYP itself shound run the generator. # A change to a .gyp, .gypi, or to GYP itself shound run the generator.
"pattern": "\\.gypi?$|[/\\\\]src[/\\\\]tools[/\\\\]gyp[/\\\\]|MANIFEST$", "pattern": "\\.gypi?$|[/\\\\]src[/\\\\]tools[/\\\\]gyp[/\\\\]|MANIFEST$",
"action": ["python", "tools/gyp/gyp", "o3d/build/all.gyp", "--depth", "."], "action": ["python", "tools/gyp/gyp", "o3d/build/all.gyp", "--depth", ".",
"-D", "support_macosx_10_4=1"],
}, },
] ]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment