Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -export_dynamic flag for AppleDynamicLinker #13291

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mesonbuild/linkers/linkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,9 @@ def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str,
def get_thinlto_cache_args(self, path: str) -> T.List[str]:
return ["-Wl,-cache_path_lto," + path]

def export_dynamic_args(self, env: 'Environment') -> T.List[str]:
return self._apply_prefix('-export_dynamic')


class LLVMLD64DynamicLinker(AppleDynamicLinker):

Expand Down
12 changes: 12 additions & 0 deletions unittests/darwintests.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ def test_apple_bitcode_modules(self):
self.build()
self.run_tests()

def test_apple_lto_export_dynamic(self):
'''
Tests that -Wl,-export_dynamic is correctly added, when export_dynamic: true is set.
On macOS, this is relevant for LTO builds only.
'''
testdir = os.path.join(self.common_test_dir, '148 shared module resolving symbol in executable')
# Ensure that it builds even with LTO enabled
env = {'CFLAGS': '-flto'}
self.init(testdir, override_envvars=env)
self.build()
self.run_tests()

def _get_darwin_versions(self, fname):
fname = os.path.join(self.builddir, fname)
out = subprocess.check_output(['otool', '-L', fname], universal_newlines=True)
Expand Down
Loading