Skip to content

Conversation

@lordeji
Copy link

@lordeji lordeji commented Dec 27, 2025

TL;DR

PR #8604 was incomplete. It was indeed embedding the locales but they weren't used and get_locales_dir() implementation was still looking for a path which throw an error in setup_localization() which force to fallback to english, even if the locales were really embedded.


Implementation :

I mainly reformated setup_localization() and init_localization() to have implementations specific to debug and release.
From what I gathered from the codebase, in debug we look for the .ftl files (and eventually fallback to embedded english) and in release it seems that there was a sort of legacy version that was looking for a folder relative to the executable (which was the source of the error).
The debug implementations is mainly the same, the release implementations follows the same structure except that we get the localized text from get_embedded_locale().
The implementation comes from the preexisting function create_english_bundle_from_embedded() where I replaced the "en-US" identifier to a parameter one.


Testing :

For consistency, I tested on 5 packages for each configuration (cp, split, truncate, mv and ls).
I was also using the devcontainer provided.
I compiled :

cargo build -p <packages...>
cargo build --release -p <packages...>
cargo build
cargo build --release

With no error/warning and then ran :

export LANG=fr_FR.UTF-8
./target/debug/<packages...> --help
./target/debug/coreutils <packages...> --help
./target/release/<packages...> --help
./target/release/coreutils <packages...> --help

Which would print French help text for all the packages in all mode.
I then ran the tests :

cargo nextest run --all-features -p uucore --no-fail-fast

With result : 313 tests run: 312 passed, 1 failed, 2 skipped

The only failed test is uucore features::proc_info::tests::test_pid_entry but it also fails when testing in main. Maybe the error is related to the devcontainer.


Edits :

  • While looking at the workflows, I saw that the script for l10n_installation_test was not set properly. Locale should be set before building or the embedding won't be done.

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/cp/cp-mv-enotsup-xattr. tests/cp/cp-mv-enotsup-xattr is passing on 'main'. Maybe you have to rebase?
Note: The gnu test tests/csplit/csplit-io-err was skipped on 'main' but is now failing.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 27, 2025

CodSpeed Performance Report

Merging #9879 will degrade performance by 4.47%

Comparing lordeji:actually-use-embedded-locale (8b1d9f6) with main (3162c21)

Summary

⚡ 14 improvements
❌ 1 regression
✅ 112 untouched
⏩ 6 skipped1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Efficiency
wc_bytes_synthetic[500] 185.5 µs 168.5 µs +10.11%
split_bytes 509.6 µs 494.1 µs +3.14%
split_number_chunks 294.7 µs 276.9 µs +6.41%
shuf_lines[100000] 31.6 ms 26.9 ms +17.61%
shuf_repeat_sampling[50000] 5.1 ms 4.6 ms +10.42%
cksum_blake3 208.9 µs 192.8 µs +8.38%
sort_ascii_c_locale 21.5 ms 22.5 ms -4.47%
rm_single_file 119.1 ms 109.4 ms +8.82%
mv_force_overwrite 144.1 ms 127.1 ms +13.3%
mv_single_file 135.3 ms 127.1 ms +6.45%
b64_decode_ignore_garbage_synthetic 163.6 µs 149.1 µs +9.68%
b64_decode_synthetic 166.6 µs 151.6 µs +9.89%
b64_encode_synthetic 162 µs 147.5 µs +9.89%
factor_multiple_u64s[2] 211.7 ms 187.4 ms +12.99%
cp_large_file[16] 359.9 µs 346.1 µs +3.99%

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@oech3
Copy link
Contributor

oech3 commented Dec 28, 2025

Update makefile to not install locales in release because they're useless.

People installing from source does not require all locales, but distibutor still needs all locales.

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/cp/cp-mv-enotsup-xattr. tests/cp/cp-mv-enotsup-xattr is passing on 'main'. Maybe you have to rebase?
Note: The gnu test tests/csplit/csplit-io-err was skipped on 'main' but is now failing.

- Update setup_localization() to have implementation specific to debug or release.
- Update create_english_bundle_from_embedded() to not be specific to english.
- Update init_localization() to have implementations specific to debug or release.
- Delete get_locales_dir() release mode implementation because it was useless.
In "Test Make installation" step, set french locale
BEFORE building with make.
If not, the binary is build with no embedded french locale.
@lordeji lordeji force-pushed the actually-use-embedded-locale branch from 7b12e54 to 8b1d9f6 Compare December 28, 2025 12:52
@lordeji
Copy link
Author

lordeji commented Dec 28, 2025

@oech3 Sorry, didn't know this. Rebased without the GNUmakefile commit.

@oech3
Copy link
Contributor

oech3 commented Dec 28, 2025

Is non-embedded .ftl still supported at here?

@github-actions
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/tail/assert is no longer failing!

@lordeji
Copy link
Author

lordeji commented Dec 28, 2025

@oech3 Not in release mode.
I may have misinterpreted the code intention to only use embedded locales in release mode.
If needed, i can fix the original get_locales_dir() function that was throwing an error in release and then add fallback to .ftl files.

@oech3
Copy link
Contributor

oech3 commented Dec 28, 2025 via email

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.

2 participants