From c6eed5f9dd7299ff15300b69bed2f0190ba19d20 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 5 Jun 2023 14:50:34 -0700 Subject: [PATCH] Add EMCC_LOGGING=0 to disable all logging This can be useful when running tests that want to check the stderr of emscripten. This was suggested as an aternative to #19085 and should fix #18607 but maybe isn't quite right to solve #18622. Fixes: #19085 --- ChangeLog.md | 3 +++ test/test_other.py | 5 ++--- tools/shared.py | 9 +++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 09d09407c5ba..479356b6d1fe 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works. 3.1.41 (in development) ----------------------- +- The log message that emcc will sometime print (for example when auto-building + system libraries) can now be completely supressed by running with + `EMCC_LOGGING=0`. - A new setting (`CHECK_NULL_WRITES`) was added to disabled the checking of address zero that is normally done when `STACK_OVERFLOW_CHECK` is enabled. (#19487) diff --git a/test/test_other.py b/test/test_other.py index c26f5beb98bb..65a53cafee5e 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -7118,6 +7118,7 @@ def test_realpath_2(self): Resolved: "/" => "/" ''', self.run_js('a.out.js')) + @with_env_modify({'EMCC_LOGGING': '0'}) # this test assumes no emcc output def test_no_warnings(self): # build once before to make sure system libs etc. exist self.run_process([EMXX, test_file('hello_libcxx.cpp')]) @@ -11281,10 +11282,8 @@ def test_bitcode_input(self): self.run_process([EMCC, '-c', '-o', 'main.o', 'main.bc']) self.assertTrue(building.is_wasm('main.o')) + @with_env_modify({'EMCC_LOGGING': '0'}) # this test assumes no emcc output def test_nostdlib(self): - # First ensure all the system libs are built - self.run_process([EMCC, test_file('unistd/close.c')]) - err = 'symbol exported via --export not found: __errno_location' self.assertContained(err, self.expect_fail([EMCC, test_file('unistd/close.c'), '-nostdlib'])) self.assertContained(err, self.expect_fail([EMCC, test_file('unistd/close.c'), '-nodefaultlibs'])) diff --git a/tools/shared.py b/tools/shared.py index 9ed8cdb70cb3..d717e5633856 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -29,9 +29,14 @@ # Configure logging before importing any other local modules so even # log message during import are shown as expected. DEBUG = int(os.environ.get('EMCC_DEBUG', '0')) +EMCC_LOGGING = int(os.environ.get('EMCC_LOGGING', '1')) +log_level = logging.ERROR +if DEBUG: + log_level = logging.DEBUG +elif EMCC_LOGGING: + log_level = logging.INFO # can add %(asctime)s to see timestamps -logging.basicConfig(format='%(name)s:%(levelname)s: %(message)s', - level=logging.DEBUG if DEBUG else logging.INFO) +logging.basicConfig(format='%(name)s:%(levelname)s: %(message)s', level=log_level) colored_logger.enable() from .utils import path_from_root, exit_with_error, safe_ensure_dirs, WINDOWS