From df69d563c2aebb6b86f709ae86a61f4dbc1bf370 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 17 Jun 2022 09:02:49 -0700 Subject: [PATCH] Implement -print-file-name (and fix -print-search-dirs) (#17229) --- ChangeLog.md | 2 ++ emcc.py | 5 +++-- tests/test_other.py | 12 +++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 484c2e234b764..f6cacd60dc148 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -20,6 +20,8 @@ See docs/process.md for more on how version tagging works. 3.2.0 ----- +- emcc now accepts `-print-file-name` and reports the correct library paths in + `-print-search-dirs`. - `tools/file_packager` no longer generates (or requires) any "pre-js" code when running in `--embed-file` mode. Instead the embedded files are loaded at static constructor time. diff --git a/emcc.py b/emcc.py index 7f33484609eaf..f15092863cf09 100755 --- a/emcc.py +++ b/emcc.py @@ -1125,8 +1125,9 @@ def run(args): shared.check_sanity() - if '-print-search-dirs' in args: - return run_process([clang, '-print-search-dirs'], check=False).returncode + passthrough_flags = ['-print-search-dirs', '-print-libgcc-file-name'] + if any(a in args for a in passthrough_flags) or any(a.startswith('-print-file-name=') for a in args): + return run_process([clang] + args + get_cflags(args), check=False).returncode ## Process argument and setup the compiler state = EmccState(args) diff --git a/tests/test_other.py b/tests/test_other.py index fa3562fecbecc..ff4d993d1ca47 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -614,9 +614,15 @@ def test_emcc_cflags(self): self.assertContained('hello, world!', self.run_js('a.out.js')) def test_emcc_print_search_dirs(self): - result = self.run_process([EMCC, '-print-search-dirs'], stdout=PIPE, stderr=PIPE) - self.assertContained('programs: =', result.stdout) - self.assertContained('libraries: =', result.stdout) + output = self.run_process([EMCC, '-print-search-dirs'], stdout=PIPE).stdout + self.assertContained('programs: =', output) + self.assertContained('libraries: =', output) + self.assertContained(str(shared.Cache.get_lib_dir(absolute=True)), output) + + def test_emcc_print_file_name(self): + self.run_process([EMBUILDER, 'build', 'libc']) + output = self.run_process([EMCC, '-print-file-name=libc.a'], stdout=PIPE).stdout + self.assertContained(shared.Cache.get_lib_name('libc.a'), output) def test_emar_em_config_flag(self): # Test that the --em-config flag is accepted but not passed down do llvm-ar.