From b246ec86f3881ddc9eacbc8465fe7c2c1d54a06f Mon Sep 17 00:00:00 2001 From: Tian Yunhao Date: Mon, 15 Nov 2021 15:06:18 +0800 Subject: [PATCH] ldgen: override LC_ALL to C before running objdump MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using a Linux system configured with `zh_CN.UTF-8` as `$LANG`, and running raw cmake command to build the project (rather than using `idf.py build`), output of objdump will be Chinese (like `在归档文件 libesp_pm.a 中`), resulting in parsing error `pyparsing.ParseException: Expected "In archive" (at char 0), (line:1, col:1)` at entity.py line 129. This commit forces objdump to use raw locale setting (`C`), to ensure it always make English output that's able to be parsed. Closes https://github.com/espressif/esp-idf/pull/7903 --- tools/ldgen/ldgen.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/ldgen/ldgen.py b/tools/ldgen/ldgen.py index a0a8ca4b5b..1bdd5af26d 100755 --- a/tools/ldgen/ldgen.py +++ b/tools/ldgen/ldgen.py @@ -131,7 +131,9 @@ def main(): for library in libraries_file: library = library.strip() if library: - dump = StringIO(subprocess.check_output([objdump, '-h', library]).decode()) + new_env = os.environ.copy() + new_env['LC_ALL']='C' + dump = StringIO(subprocess.check_output([objdump, '-h', library], env=new_env).decode()) dump.name = library sections_infos.add_sections_info(dump)