diff options
author | maruel@chromium.org <maruel@chromium.org> | 2014-11-05 20:00:28 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org> | 2014-11-05 20:00:28 +0000 |
commit | 487c0b6ae8b44932e45347211bca0e8387718436 (patch) | |
tree | 25a4380a068212b79efba1d8dc79a4d36ba3c98d | |
parent | f491c0b3aae953a32bea57aa7f4181aaa60e2c3e (diff) | |
download | gyp-487c0b6ae8b44932e45347211bca0e8387718436.tar.gz |
Set ZERO_AR_DATE=1 when running libtool.
Ref: http://www.opensource.apple.com/source/cctools/cctools-809/misc/libtool.c
Adhoc testing with base_unittests reduced non-deterministic bytes from ~2347 to
~174. It's definitely the lowest hanging fruit, which will permit us to focus on
the remaining bytes.
R=thakis@chromium.org
BUG=chromium:330262
Review URL: https://codereview.chromium.org/699083004
git-svn-id: http://gyp.googlecode.com/svn/trunk@1998 78cadc50-ecff-11dd-a971-7dbc132099af
-rwxr-xr-x | pylib/gyp/mac_tool.py | 16 | ||||
-rw-r--r-- | test/mac/gyptest-libtool-zero.py | 26 | ||||
-rw-r--r-- | test/mac/libtool-zero/mylib.c | 7 | ||||
-rw-r--r-- | test/mac/libtool-zero/test.gyp | 15 |
4 files changed, 63 insertions, 1 deletions
diff --git a/pylib/gyp/mac_tool.py b/pylib/gyp/mac_tool.py index e5d8a2b8..a25754c7 100755 --- a/pylib/gyp/mac_tool.py +++ b/pylib/gyp/mac_tool.py @@ -223,11 +223,25 @@ class MacTool(object): r'^.*libtool: warning for library: ' + r'.* the table of contents is empty ' + r'\(no object file members in the library define global symbols\)$') - libtoolout = subprocess.Popen(cmd_list, stderr=subprocess.PIPE) + env = os.environ.copy() + # Ref: + # http://www.opensource.apple.com/source/cctools/cctools-809/misc/libtool.c + # The problem with this flag is that it resets the file mtime on the file to + # epoch=0, e.g. 1970-1-1 or 1969-12-31 depending on daylight saving. + env['ZERO_AR_DATE'] = '1' + libtoolout = subprocess.Popen(cmd_list, stderr=subprocess.PIPE, env=env) _, err = libtoolout.communicate() for line in err.splitlines(): if not libtool_re.match(line) and not libtool_re5.match(line): print >>sys.stderr, line + # Unconditionally touch any file .a file on the command line if present if + # succeeded. A bit hacky. + if not libtoolout.returncode: + archives = [ + cmd for cmd in cmd_list if cmd.endswith('.a') and os.path.isfile(cmd) + ] + if len(archives) == 1: + os.utime(archives[0], None) return libtoolout.returncode def ExecPackageFramework(self, framework, version): diff --git a/test/mac/gyptest-libtool-zero.py b/test/mac/gyptest-libtool-zero.py new file mode 100644 index 00000000..ae5b7e63 --- /dev/null +++ b/test/mac/gyptest-libtool-zero.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +# Copyright (c) 2014 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Verifies libraries have proper mtime. +""" + +import TestGyp + +import sys + +if sys.platform == 'darwin': + test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) + + CHDIR = 'libtool-zero' + + test.run_gyp('test.gyp', chdir=CHDIR) + + test.build('test.gyp', 'mylib', chdir=CHDIR) + + test.up_to_date('test.gyp', 'mylib', chdir=CHDIR) + + test.pass_test() diff --git a/test/mac/libtool-zero/mylib.c b/test/mac/libtool-zero/mylib.c new file mode 100644 index 00000000..b26d61bd --- /dev/null +++ b/test/mac/libtool-zero/mylib.c @@ -0,0 +1,7 @@ +// Copyright (c) 2014 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +int my_foo(int x) { + return x + 1; +} diff --git a/test/mac/libtool-zero/test.gyp b/test/mac/libtool-zero/test.gyp new file mode 100644 index 00000000..2f2c3f1c --- /dev/null +++ b/test/mac/libtool-zero/test.gyp @@ -0,0 +1,15 @@ +# Copyright (c) 2014 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'targets': [ + { + 'target_name': 'mylib', + 'type': 'static_library', + 'sources': [ + 'mylib.c', + ], + }, + ], +} |