Skip to content

Commit 5da7b63

Browse files
authored
Implement --print-prog-name. NFC (#25547)
Also unify with `-print-resource-dir` since they both just exec clang. I would like to do the same with `-print-resource-dir` but sadly the clang defaults for search dirs don't match ours just yet. See #1610
1 parent 3ce72c0 commit 5da7b63

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

emcc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,6 @@ def run(args):
250250
print(f'libraries: ={cache.get_lib_dir(absolute=True)}')
251251
return 0
252252

253-
if '-print-resource-dir' in args:
254-
shared.check_call([clang] + args)
255-
return 0
256-
257253
if '-print-libgcc-file-name' in args or '--print-libgcc-file-name' in args:
258254
settings.limit_settings(None)
259255
compiler_rt = system_libs.Library.get_usable_variations()['libcompiler_rt']
@@ -292,6 +288,10 @@ def run(args):
292288

293289
phase_setup(options, state)
294290

291+
if '-print-resource-dir' in args or any(a.startswith('--print-prog-name') for a in args):
292+
shared.exec_process([clang] + compile.get_cflags(tuple(args)) + args)
293+
assert False, 'exec_process should not return'
294+
295295
if '--cflags' in args:
296296
# Just print the flags we pass to clang and exit. We need to do this after
297297
# phase_setup because the setup sets things like SUPPORT_LONGJMP.
@@ -513,7 +513,7 @@ def get_clang_command_asm():
513513
else:
514514
cmd = get_clang_command() + newargs
515515
shared.exec_process(cmd)
516-
assert False, 'exec_process does not return'
516+
assert False, 'exec_process should not return'
517517

518518
# In COMPILE_AND_LINK we need to compile source files too, but we also need to
519519
# filter out the link flags

test/test_other.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,14 @@ def test_print_resource_dir(self):
751751
llvm_root = os.path.normcase(os.path.dirname(config.LLVM_ROOT))
752752
self.assertContained(llvm_root, resource_dir)
753753

754+
@crossplatform
755+
def test_print_prog_name(self):
756+
output = self.run_process([EMCC, '--print-prog-name=clang'], stdout=PIPE).stdout
757+
expected = CLANG_CC
758+
if WINDOWS:
759+
expected = os.path.normpath(shared.unsuffixed(CLANG_CC))
760+
self.assertContained(expected, output)
761+
754762
@crossplatform
755763
@parameterized({
756764
'': [[]],

0 commit comments

Comments
 (0)