Skip to content

m1n1.loadobjs: Run toolchain tools in the C locale - #32

Open
lanjak wants to merge 1 commit into
GravityLinux:mainfrom
lanjak:loadobjs-c-locale
Open

lanjak wants to merge 1 commit into
GravityLinux:mainfrom
lanjak:loadobjs-c-locale

Conversation

@lanjak

@lanjak lanjak commented Dec 3, 2026

Copy link
Copy Markdown

test_tool_output_lines and test_run_tool fail in GCC mode when the host uses a UTF-8 locale such as en_AU.UTF-8. nm sorts symbols that have the same address by locale collation, so the order does not agree with the expected output. CI passes because the runner uses the C collation order.

This change sets LC_ALL=C for the tools that tool_output_lines() and run_tool() run. The two tests now also run in an installed UTF-8 locale, so CI finds this problem even when the runner uses the C locale. If the host has no UTF-8 locale, pytest skips that case.

Tested on Arch Linux, GNU binutils 2.47, GCC 16.2 cross and clang 23: pytest on Python 3.9 and 3.13, in GCC and clang mode, with LC_ALL=C and LC_ALL=en_AU.UTF-8. Without the loadobjs.py change, the new UTF-8 cases fail in GCC mode. With it, all runs pass.

LLM disclosure: an LLM (Claude) found the cause, wrote the change and the test, and ran the tests. It had access only to this repository and toolchain output. No Apple binaries or other RE material were used. I reviewed the change.

nm sorts symbols that have the same address by the collation rules of
the locale. With a UTF-8 locale such as en_AU.UTF-8, GNU nm 2.47 gives
a different order than the expected output in test_loadobjs.py. Thus
test_tool_output_lines and test_run_tool fail in GCC mode.

Set LC_ALL=C for the tools that tool_output_lines() and run_tool()
run. Then the tool output does not change with the host locale, and
translated messages do not break the ASCII decode.

Run test_tool_output_lines and test_run_tool in the C locale and in an
installed UTF-8 locale. CI then finds this problem also when the runner
uses the C locale. If the host has no UTF-8 locale, pytest skips the
UTF-8 case.

Tested with pytest on Python 3.9 and 3.13, in GCC and clang mode, with
LC_ALL=C and with LC_ALL=en_AU.UTF-8. Without the change to loadobjs.py,
the UTF-8 cases fail in GCC mode.

Assisted-By: LLM
Signed-off-by: lanjak <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant