From 9042e6cb1b87acfa7c1700b82614437a291b5092 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Sun, 10 Sep 2023 21:08:02 -0700 Subject: [PATCH] ENH Print helpful error if ccache was linked against too new glibc (#4127) Resolves pyodide#4126. If someone builds emsdk outside of the docker image and then attempts to use it inside, there will be an error. This detects it and tells people to clean emsdk. --- Makefile | 5 +++++ tools/check_ccache.py | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tools/check_ccache.py diff --git a/Makefile b/Makefile index 12f38ce9c..1d0e650dc 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ CXX=em++ all: check \ + check-emcc \ dist/pyodide.asm.js \ dist/pyodide.js \ dist/pyodide.d.ts \ @@ -269,6 +270,10 @@ check: ./tools/dependency-check.sh +check-emcc: emsdk/emsdk/.complete + python3 tools/check_ccache.py + + debug : EXTRA_CFLAGS+=" -D DEBUG_F" \ make diff --git a/tools/check_ccache.py b/tools/check_ccache.py new file mode 100644 index 000000000..4cc4c732c --- /dev/null +++ b/tools/check_ccache.py @@ -0,0 +1,24 @@ +import re +import subprocess +import sys + + +def main(): + result = subprocess.run(["emcc", "--version"], capture_output=True, encoding="utf8") + if result.returncode == 0: + return 0 + if re.search("GLIBC.*not found.*ccache", result.stderr): + print( + "Emscripten ccache was linked against an incompatible version of glibc.\n" + "Run `make -C emsdk clean` and try again.\n" + "If this error persists, please open an issue to ask for help." + ) + else: + print("Something is wrong but I'm not sure what.") + print("Info:") + print(result) + return 1 + + +if __name__ == "__main__": + sys.exit(main())