Skip to content

Commit

Permalink
Implement -print-file-name (and fix -print-search-dirs) (#17229)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 authored Jun 17, 2022
1 parent 016265c commit df69d56
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 9 additions & 3 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit df69d56

Please sign in to comment.