Skip to content

Commit f95f2cc

Browse files
authored
Add deprecation warning for EMMAKEN_CFLAGS (emscripten-core#15685)
Also, move processing of EMMAKEN_CFLAGS up to the same place where we process EMCC_FLAGS to its obvious they are equivalent. See emscripten-core#15684
1 parent 88b3f6d commit f95f2cc

6 files changed

Lines changed: 26 additions & 19 deletions

File tree

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.0.1
2222
-----
23+
- Deprecate `EMMAKEN_CFLAGS` is favor of `EMCC_CFLAGS`.
2324

2425
3.0.0 - 11/22/2021
2526
------------------

docs/emcc.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,11 @@ Environment variables
606606

607607
*emcc* is affected by several environment variables, as listed below:
608608

609-
* "EMMAKEN_CFLAGS" [compile+link]
609+
* "EMMAKEN_CFLAGS" [compile+link] Deprecated. Use "EMCC_CFLAGS"
610+
instead.
610611

611-
* "EMMAKEN_COMPILER" [compile+link] Deprecated. Avoid using.
612+
* "EMMAKEN_COMPILER" [compile+link] Deprecated. Use "EM_LLVM_ROOT"
613+
and/or "EM_COMPIELR_WRAPPER" instead.
612614

613615
* "EMMAKEN_JUST_CONFIGURE" [other]
614616

emcc.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -964,13 +964,14 @@ def run(args):
964964
# Additional compiler flags that we treat as if they were passed to us on the
965965
# commandline
966966
EMCC_CFLAGS = os.environ.get('EMCC_CFLAGS')
967-
if DEBUG:
968-
cmd = shared.shlex_join(args)
969-
if EMCC_CFLAGS:
970-
cmd += ' + ' + EMCC_CFLAGS
971-
logger.warning(f'invocation: {cmd} (in {os.getcwd()})')
972967
if EMCC_CFLAGS:
973968
args.extend(shlex.split(EMCC_CFLAGS))
969+
EMMAKEN_CFLAGS = os.environ.get('EMMAKEN_CFLAGS')
970+
if EMMAKEN_CFLAGS:
971+
args += shlex.split(EMMAKEN_CFLAGS)
972+
973+
if DEBUG:
974+
logger.warning(f'invocation: {shared.shlex_join(args)} (in {os.getcwd()})')
974975

975976
# Strip args[0] (program name)
976977
args = args[1:]
@@ -1003,7 +1004,6 @@ def run(args):
10031004
return 0
10041005

10051006
if '--version' in args:
1006-
10071007
print(version_string())
10081008
print('''\
10091009
Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt)
@@ -1051,16 +1051,15 @@ def run(args):
10511051
if '-print-search-dirs' in args:
10521052
return run_process([clang, '-print-search-dirs'], check=False).returncode
10531053

1054-
EMMAKEN_CFLAGS = os.environ.get('EMMAKEN_CFLAGS')
1055-
if EMMAKEN_CFLAGS:
1056-
args += shlex.split(EMMAKEN_CFLAGS)
1054+
## Process argument and setup the compiler
1055+
state = EmccState(args)
1056+
options, newargs, settings_map = phase_parse_arguments(state)
10571057

10581058
if 'EMMAKEN_NO_SDK' in os.environ:
10591059
diagnostics.warning('deprecated', 'We hope to deprecated EMMAKEN_NO_SDK. See https://github.com/emscripten-core/emscripten/issues/14050 if use use this feature.')
10601060

1061-
## Process argument and setup the compiler
1062-
state = EmccState(args)
1063-
options, newargs, settings_map = phase_parse_arguments(state)
1061+
if 'EMMAKEN_CFLAGS' in os.environ:
1062+
diagnostics.warning('deprecated', '`EMMAKEN_CFLAGS` is deprecated, please use `EMCC_CFLAGS` instead. See https://github.com/emscripten-core/emscripten/issues/15684')
10641063

10651064
# For internal consistency, ensure we don't attempt or read or write any link time
10661065
# settings until we reach the linking phase.

site/source/docs/tools_reference/emcc.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,8 @@ Environment variables
524524
=====================
525525
*emcc* is affected by several environment variables, as listed below:
526526

527-
- ``EMMAKEN_CFLAGS`` [compile+link]
528-
- ``EMMAKEN_COMPILER`` [compile+link] Deprecated. Avoid using.
527+
- ``EMMAKEN_CFLAGS`` [compile+link] Deprecated. Use ``EMCC_CFLAGS`` instead.
528+
- ``EMMAKEN_COMPILER`` [compile+link] Deprecated. Use ``EM_LLVM_ROOT`` and/or ``EM_COMPIELR_WRAPPER`` instead.
529529
- ``EMMAKEN_JUST_CONFIGURE`` [other]
530530
- ``EMCC_AUTODEBUG`` [compile+link]
531531
- ``EMCC_CFLAGS`` [compile+link]

tests/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6394,7 +6394,7 @@ def do_test():
63946394
# In ASan mode we need a large initial memory (or else wasm-ld fails).
63956395
# The OpenJPEG CMake will build several executables (which we need parts
63966396
# of in our testing, see above), so we must enable the flag for them all.
6397-
with env_modify({'EMMAKEN_CFLAGS': '-sINITIAL_MEMORY=300MB'}):
6397+
with env_modify({'EMCC_CFLAGS': '-sINITIAL_MEMORY=300MB'}):
63986398
do_test_openjpeg()
63996399
else:
64006400
do_test_openjpeg()

tests/test_other.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10348,6 +10348,11 @@ def test_emmaken_compiler(self):
1034810348
stderr = self.run_process([EMCC, '-c', test_file('core/test_hello_world.c')], stderr=PIPE).stderr
1034910349
self.assertContained('warning: `EMMAKEN_COMPILER` is deprecated', stderr)
1035010350

10351+
@with_env_modify({'EMMAKEN_CFLAGS': '-O2'})
10352+
def test_emmaken_cflags(self):
10353+
stderr = self.run_process([EMCC, '-c', test_file('core/test_hello_world.c')], stderr=PIPE).stderr
10354+
self.assertContained('warning: `EMMAKEN_CFLAGS` is deprecated', stderr)
10355+
1035110356
@no_windows('relies on a shell script')
1035210357
def test_compiler_wrapper(self):
1035310358
create_file('wrapper.sh', '''\
@@ -10624,10 +10629,10 @@ def test_gen_struct_info(self):
1062410629
self.assertFileContents(test_file('reference_struct_info.json'), read_file('out.json'))
1062510630

1062610631
def test_gen_struct_info_env(self):
10627-
# gen_struct_info.py builds C code in a very particlar way. We don't want EMMAKEN_CFLAGS to
10632+
# gen_struct_info.py builds C code in a very particlar way. We don't want EMCC_CFLAGS to
1062810633
# be injected which could cause it to fail.
1062910634
# For example -O2 causes printf -> iprintf which will fail with undefined symbol iprintf.
10630-
with env_modify({'EMMAKEN_CFLAGS': '-O2 BAD_ARG'}):
10635+
with env_modify({'EMCC_CFLAGS': '-O2 BAD_ARG'}):
1063110636
self.run_process([PYTHON, path_from_root('tools/gen_struct_info.py'), '-o', 'out.json'])
1063210637

1063310638
def test_relocatable_limited_exports(self):

0 commit comments

Comments
 (0)