Skip to content

Commit df69d56

Browse files
authored
Implement -print-file-name (and fix -print-search-dirs) (#17229)
1 parent 016265c commit df69d56

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

ChangeLog.md

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.2.0
2222
-----
23+
- emcc now accepts `-print-file-name` and reports the correct library paths in
24+
`-print-search-dirs`.
2325
- `tools/file_packager` no longer generates (or requires) any "pre-js" code when
2426
running in `--embed-file` mode. Instead the embedded files are loaded at
2527
static constructor time.

emcc.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1125,8 +1125,9 @@ def run(args):
11251125

11261126
shared.check_sanity()
11271127

1128-
if '-print-search-dirs' in args:
1129-
return run_process([clang, '-print-search-dirs'], check=False).returncode
1128+
passthrough_flags = ['-print-search-dirs', '-print-libgcc-file-name']
1129+
if any(a in args for a in passthrough_flags) or any(a.startswith('-print-file-name=') for a in args):
1130+
return run_process([clang] + args + get_cflags(args), check=False).returncode
11301131

11311132
## Process argument and setup the compiler
11321133
state = EmccState(args)

tests/test_other.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,15 @@ def test_emcc_cflags(self):
614614
self.assertContained('hello, world!', self.run_js('a.out.js'))
615615

616616
def test_emcc_print_search_dirs(self):
617-
result = self.run_process([EMCC, '-print-search-dirs'], stdout=PIPE, stderr=PIPE)
618-
self.assertContained('programs: =', result.stdout)
619-
self.assertContained('libraries: =', result.stdout)
617+
output = self.run_process([EMCC, '-print-search-dirs'], stdout=PIPE).stdout
618+
self.assertContained('programs: =', output)
619+
self.assertContained('libraries: =', output)
620+
self.assertContained(str(shared.Cache.get_lib_dir(absolute=True)), output)
621+
622+
def test_emcc_print_file_name(self):
623+
self.run_process([EMBUILDER, 'build', 'libc'])
624+
output = self.run_process([EMCC, '-print-file-name=libc.a'], stdout=PIPE).stdout
625+
self.assertContained(shared.Cache.get_lib_name('libc.a'), output)
620626

621627
def test_emar_em_config_flag(self):
622628
# Test that the --em-config flag is accepted but not passed down do llvm-ar.

0 commit comments

Comments
 (0)