ldgen: override LC_ALL to C before running objdump

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
This commit is contained in:
Tian Yunhao
2021-11-15 15:06:18 +08:00
committed by Simon Chupin
parent 4a011f3183
commit b246ec86f3

View File

@@ -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)