From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../gyptest-solibs-avoid-relinking.py | 48 ++++++++++++++++++++++ .../gyp/test/ninja/solibs_avoid_relinking/main.cc | 5 +++ .../gyp/test/ninja/solibs_avoid_relinking/solib.cc | 8 ++++ .../solibs_avoid_relinking.gyp | 38 +++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100755 third_party/python/gyp/test/ninja/solibs_avoid_relinking/gyptest-solibs-avoid-relinking.py create mode 100644 third_party/python/gyp/test/ninja/solibs_avoid_relinking/main.cc create mode 100644 third_party/python/gyp/test/ninja/solibs_avoid_relinking/solib.cc create mode 100644 third_party/python/gyp/test/ninja/solibs_avoid_relinking/solibs_avoid_relinking.gyp (limited to 'third_party/python/gyp/test/ninja/solibs_avoid_relinking') diff --git a/third_party/python/gyp/test/ninja/solibs_avoid_relinking/gyptest-solibs-avoid-relinking.py b/third_party/python/gyp/test/ninja/solibs_avoid_relinking/gyptest-solibs-avoid-relinking.py new file mode 100755 index 0000000000..fd4470ac23 --- /dev/null +++ b/third_party/python/gyp/test/ninja/solibs_avoid_relinking/gyptest-solibs-avoid-relinking.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python + +# Copyright (c) 2012 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. + +""" +Verify that relinking a solib doesn't relink a dependent executable if the +solib's public API hasn't changed. +""" + +from __future__ import print_function + +import os +import sys +import TestCommon +import TestGyp + +# NOTE(fischman): This test will not work with other generators because the +# API-hash-based-mtime-preservation optimization is only implemented in +# ninja.py. It could be extended to the make.py generator as well pretty +# easily, probably. +# (also, it tests ninja-specific out paths, which would have to be generalized +# if this was extended to other generators). +test = TestGyp.TestGyp(formats=['ninja']) + +if not os.environ.get('ProgramFiles(x86)'): + # TODO(scottmg) + print('Skipping test on x86, http://crbug.com/365833') + test.pass_test() + +test.run_gyp('solibs_avoid_relinking.gyp') + +# Build the executable, grab its timestamp, touch the solib's source, rebuild +# executable, ensure timestamp hasn't changed. +test.build('solibs_avoid_relinking.gyp', 'b') +test.built_file_must_exist('b' + TestCommon.exe_suffix) +pre_stat = os.stat(test.built_file_path('b' + TestCommon.exe_suffix)) +os.utime(os.path.join(test.workdir, 'solib.cc'), + (pre_stat.st_atime, pre_stat.st_mtime + 100)) +test.sleep() +test.build('solibs_avoid_relinking.gyp', 'b') +post_stat = os.stat(test.built_file_path('b' + TestCommon.exe_suffix)) + +if pre_stat.st_mtime != post_stat.st_mtime: + test.fail_test() +else: + test.pass_test() diff --git a/third_party/python/gyp/test/ninja/solibs_avoid_relinking/main.cc b/third_party/python/gyp/test/ninja/solibs_avoid_relinking/main.cc new file mode 100644 index 0000000000..2cd74d3c77 --- /dev/null +++ b/third_party/python/gyp/test/ninja/solibs_avoid_relinking/main.cc @@ -0,0 +1,5 @@ +extern int foo(); + +int main() { + return foo(); +} diff --git a/third_party/python/gyp/test/ninja/solibs_avoid_relinking/solib.cc b/third_party/python/gyp/test/ninja/solibs_avoid_relinking/solib.cc new file mode 100644 index 0000000000..0856cd4e00 --- /dev/null +++ b/third_party/python/gyp/test/ninja/solibs_avoid_relinking/solib.cc @@ -0,0 +1,8 @@ +#ifdef _MSC_VER +__declspec(dllexport) +#else +__attribute__((visibility("default"))) +#endif +int foo() { + return 42; +} diff --git a/third_party/python/gyp/test/ninja/solibs_avoid_relinking/solibs_avoid_relinking.gyp b/third_party/python/gyp/test/ninja/solibs_avoid_relinking/solibs_avoid_relinking.gyp new file mode 100644 index 0000000000..e816351d68 --- /dev/null +++ b/third_party/python/gyp/test/ninja/solibs_avoid_relinking/solibs_avoid_relinking.gyp @@ -0,0 +1,38 @@ +# Copyright (c) 2012 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': 'a', + 'type': 'shared_library', + 'sources': [ 'solib.cc' ], + # Incremental linking enabled so that .lib timestamp is maintained when + # exports are unchanged. + 'msvs_settings': { + 'VCLinkerTool': { + 'LinkIncremental': '2', + } + }, + }, + { + 'target_name': 'b', + 'type': 'executable', + 'sources': [ 'main.cc' ], + 'dependencies': [ 'a' ], + 'msvs_settings': { + 'VCLinkerTool': { + 'LinkIncremental': '2', + } + }, + }, + ], + 'conditions': [ + ['OS=="linux"', { + 'target_defaults': { + 'cflags': ['-fPIC'], + }, + }], + ], +} -- cgit v1.2.3