minstall: make do_strip run with -Sx for macOS targets
This commit also adds some extra symbol noise to lib.c, in order to aid detection of the debug information with nm. Fixes #10943
This commit is contained in:
parent
21f86fa902
commit
7e5b0760ce
|
@ -27,7 +27,7 @@ import typing as T
|
|||
from . import build
|
||||
from . import environment
|
||||
from .backend.backends import InstallData
|
||||
from .mesonlib import MesonException, Popen_safe, RealPathAction, is_windows, setup_vsenv, pickle_load
|
||||
from .mesonlib import MesonException, Popen_safe, RealPathAction, is_windows, setup_vsenv, pickle_load, is_osx
|
||||
from .scripts import depfixer, destdir_join
|
||||
from .scripts.meson_exe import run_exe
|
||||
try:
|
||||
|
@ -566,7 +566,13 @@ class Installer:
|
|||
|
||||
def do_strip(self, strip_bin: T.List[str], fname: str, outname: str) -> None:
|
||||
self.log(f'Stripping target {fname!r}.')
|
||||
returncode, stdo, stde = self.Popen_safe(strip_bin + [outname])
|
||||
if is_osx():
|
||||
# macOS expects dynamic objects to be stripped with -x maximum.
|
||||
# To also strip the debug info, -S must be added.
|
||||
# See: https://www.unix.com/man-page/osx/1/strip/
|
||||
returncode, stdo, stde = self.Popen_safe(strip_bin + ['-S', '-x', outname])
|
||||
else:
|
||||
returncode, stdo, stde = self.Popen_safe(strip_bin + [outname])
|
||||
if returncode != 0:
|
||||
print('Could not strip file.\n')
|
||||
print(f'Stdout:\n{stdo}\n')
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
void func(void){}
|
||||
#include <stdio.h>
|
||||
|
||||
void func(void){ fprintf(stderr, "Test 1 2 3\n"); }
|
||||
|
|
|
@ -1773,25 +1773,41 @@ class LinuxlikeTests(BasePlatformTests):
|
|||
# If so, we can test that cmake works with "gcc -m32"
|
||||
self.do_one_test_with_nativefile('../cmake/1 basic', "['gcc', '-m32']")
|
||||
|
||||
@skipUnless(is_linux(), 'Test only applicable to Linux')
|
||||
@skipUnless(is_linux() or is_osx(), 'Test only applicable to Linux and macOS')
|
||||
def test_install_strip(self):
|
||||
testdir = os.path.join(self.unit_test_dir, '103 strip')
|
||||
self.init(testdir)
|
||||
self.build()
|
||||
|
||||
destdir = self.installdir + self.prefix
|
||||
lib = os.path.join(destdir, self.libdir, 'liba.so')
|
||||
if is_linux():
|
||||
lib = os.path.join(destdir, self.libdir, 'liba.so')
|
||||
else:
|
||||
lib = os.path.join(destdir, self.libdir, 'liba.dylib')
|
||||
install_cmd = self.meson_command + ['install', '--destdir', self.installdir]
|
||||
|
||||
# Check we have debug symbols by default
|
||||
self._run(install_cmd, workdir=self.builddir)
|
||||
stdout = self._run(['file', '-b', lib])
|
||||
self.assertIn('not stripped', stdout)
|
||||
if is_linux():
|
||||
# file can detect stripped libraries on linux
|
||||
stdout = self._run(['file', '-b', lib])
|
||||
self.assertIn('not stripped', stdout)
|
||||
else:
|
||||
# on macOS we need to query dsymutil instead.
|
||||
# Alternatively, check if __dyld_private is defined
|
||||
# in the output of nm liba.dylib, but that is not
|
||||
# 100% reliable, it needs linking to an external library
|
||||
stdout = self._run(['dsymutil', '--dump-debug-map', lib])
|
||||
self.assertIn('symbols:', stdout)
|
||||
|
||||
# Check debug symbols got removed with --strip
|
||||
self._run(install_cmd + ['--strip'], workdir=self.builddir)
|
||||
stdout = self._run(['file', '-b', lib])
|
||||
self.assertNotIn('not stripped', stdout)
|
||||
if is_linux():
|
||||
stdout = self._run(['file', '-b', lib])
|
||||
self.assertNotIn('not stripped', stdout)
|
||||
else:
|
||||
stdout = self._run(['dsymutil', '--dump-debug-map', lib])
|
||||
self.assertNotIn('symbols:', stdout)
|
||||
|
||||
def test_isystem_default_removal_with_symlink(self):
|
||||
env = get_fake_env()
|
||||
|
|
Loading…
Reference in New Issue