Skip to content

Fix toolchain detection localization issues on GNU systems#163

Merged
adacore-bot merged 1 commit intoAdaCore:masterfrom
delta-lima7:master
Mar 31, 2026
Merged

Fix toolchain detection localization issues on GNU systems#163
adacore-bot merged 1 commit intoAdaCore:masterfrom
delta-lima7:master

Conversation

@delta-lima7
Copy link
Copy Markdown
Contributor

Greetings,

GCC provides localized version output with different formatting depending on the system locale. This behaviour breaks gprconfig on all GNU/Linux distributions on which GCC is compiled with gettext support when using a non-english locale.
In my case, gcc -v yields gcc-Version 15.2.1 20260209 (GCC), whereas the non-localized output should be gcc version 15.2.1 20260209 (GCC) (note the '-').
There have been attempts to add/change regexes in gprconfig_kb and AFAIK some distribution maintainers have created patches for the XML files, but rather than adding various bits and pieces to the knowledge base I think it makes more sense to generate a uniform version output in the first place. This would obviously accommodate for future changes in the gettext output as well.

This changeset defines the LC_MESSAGES variable to C before generating the version output and resets it afterwards, so that always the default version info is used for searching in the knowledge base.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 27, 2026

CLA assistant check
All committers have signed the CLA.

@Jicquel
Copy link
Copy Markdown
Contributor

Jicquel commented Mar 30, 2026

Hello @delta-lima7, thank you for your valuable contribution! Could you move it to https://github.com/AdaCore/gpr, more precisely here: https://github.com/AdaCore/gpr/blob/474cf73b627ac77c43961bf62e8289f96b727f31/src/lib/gpr2-kb.adb#L1733 ? Gprbuild's knowledge base is not used anymore, it has been replaced by the gpr2's version.

In your PR, could you also restore the environment variable when the command fails to spawn, in the exception handler ?

Thanks!

@delta-lima7
Copy link
Copy Markdown
Contributor Author

Hello Jicquel,

sure, but just to check – are changes in libgpr2 propagated to this repository? Because it seems to me most distributions (I checked at least Debian, Ubuntu, Fedora) use this repository to package gprbuild, -config, -ls, etc.

Paul

@Jicquel
Copy link
Copy Markdown
Contributor

Jicquel commented Mar 30, 2026

No, the changes are not propagated to this repository. Two PR can be opened in that case, they should be almost identical. Thank you for your insight :)

Compilers like GCC provide localized messages when the system is
configured with a non-english locale.  This change sets the LC_MESSAGES
variable to `C` so that always the default version info is used
for searching in the knowledge base.
delta-lima7 added a commit to delta-lima7/gpr that referenced this pull request Mar 30, 2026
Compilers like GCC provide localized messages when the system is
configured with a non-english locale.  This change sets the LC_MESSAGES
variable to `C` so that always the default version info is used
for searching in the knowledge base.

(Applies AdaCore/gprbuild#163)
@adacore-bot adacore-bot merged commit e2554e9 into AdaCore:master Mar 31, 2026
1 check passed
delta-lima7 added a commit to delta-lima7/gpr that referenced this pull request Mar 31, 2026
Compilers like GCC provide localized messages when the system is
configured with a non-english locale.  This change sets the LC_MESSAGES
variable to `C` so that always the default version info is used
for searching in the knowledge base.

(Applies AdaCore/gprbuild#163)
adacore-bot pushed a commit to AdaCore/gpr that referenced this pull request Mar 31, 2026
Compilers like GCC provide localized messages when the system is
configured with a non-english locale.  This change sets the LC_MESSAGES
variable to `C` so that always the default version info is used
for searching in the knowledge base.

(Applies AdaCore/gprbuild#163)
adacore-bot pushed a commit to AdaCore/gpr that referenced this pull request Mar 31, 2026
Compilers like GCC provide localized messages when the system is
configured with a non-english locale.  This change sets the LC_MESSAGES
variable to `C` so that always the default version info is used
for searching in the knowledge base.

(Applies AdaCore/gprbuild#163)

Issue: eng/gpr/gpr-issues#813

Github PR: #19

Merge request eng/gpr/gpr!806 from branch 'mr/jicquel/gpr-issues#813' into 'main'
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.

4 participants