Message ID | f306f43f375bc9b9c98e85260587442e5d9ef0ba.1652094958.git.git@grubix.eu (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | detect-compiler: make detection independent of locale | expand |
Michael J Gruber <git@grubix.eu> writes: > `detect-compiler` has accumulated a few compiler dependent workarounds > lately for the more and more ubiquitious gcc12. This is intended to make > CI set-ups work across tool-chain updates, but also help those > developers who build with `DEVELOPER=1`. > > Alas, `detect-compiler` uses the locale dependent output of `$(CC) -v` > to parse for the version string, which fails unless it literally > contains ` version`. > > Use `LANG=C $(CC) -v` instead to grep for stable output. I think this patch is a bit insufficient. $ LC_ALL=ja_JP.utf8 LANG=C gcc -v 2>&1 | head -n 1 組み込み spec を使用しています。 $ LC_ALL=C LANG=ja_JP.utf8 gcc -v 2>&1 | head -n 1 Using built-in specs. In theory overriding LC_ALL alone may be sufficient these days where everybody seems to know about LC_*, but just out of habit, I would recommend forcing both, i.e. > get_version_line() { > - $CC -v 2>&1 | grep ' version ' > + LANG=C $CC -v 2>&1 | grep ' version ' this on top of the posted patch, which is what I'll squash in when queuing this patch (no need to resend if you agree with the above and unless you have other changes and improvements). Thanks. diff --git i/detect-compiler w/detect-compiler index 473f3bd4fe..50087f5670 100755 --- i/detect-compiler +++ w/detect-compiler @@ -9,7 +9,7 @@ CC="$*" # # FreeBSD clang version 3.4.1 (tags/RELEASE...) get_version_line() { - LANG=C $CC -v 2>&1 | grep ' version ' + LANG=C LC_ALL=C $CC -v 2>&1 | grep ' version ' } get_family() {
On May 9, 2022 11:52 AM, Junio C Hamano wrote: >Michael J Gruber <git@grubix.eu> writes: > >> `detect-compiler` has accumulated a few compiler dependent workarounds >> lately for the more and more ubiquitious gcc12. This is intended to >> make CI set-ups work across tool-chain updates, but also help those >> developers who build with `DEVELOPER=1`. >> >> Alas, `detect-compiler` uses the locale dependent output of `$(CC) -v` >> to parse for the version string, which fails unless it literally >> contains ` version`. >> >> Use `LANG=C $(CC) -v` instead to grep for stable output. > >I think this patch is a bit insufficient. > > $ LC_ALL=ja_JP.utf8 LANG=C gcc -v 2>&1 | head -n 1 > 組み込み spec を使用しています。 > $ LC_ALL=C LANG=ja_JP.utf8 gcc -v 2>&1 | head -n 1 > Using built-in specs. > >In theory overriding LC_ALL alone may be sufficient these days where everybody >seems to know about LC_*, but just out of habit, I would recommend forcing >both, i.e. > >> get_version_line() { >> - $CC -v 2>&1 | grep ' version ' >> + LANG=C $CC -v 2>&1 | grep ' version ' > >this on top of the posted patch, which is what I'll squash in when queuing this >patch (no need to resend if you agree with the above and unless you have other >changes and improvements). > >Thanks. > >diff --git i/detect-compiler w/detect-compiler index 473f3bd4fe..50087f5670 >100755 >--- i/detect-compiler >+++ w/detect-compiler >@@ -9,7 +9,7 @@ CC="$*" > # > # FreeBSD clang version 3.4.1 (tags/RELEASE...) > get_version_line() { >- LANG=C $CC -v 2>&1 | grep ' version ' >+ LANG=C LC_ALL=C $CC -v 2>&1 | grep ' version ' > } > > get_family() { Just a small transfer of experience from a different project - if we transition or expand LOCALE functions into C at some point. Be aware that the locale_t series in C is not supported universally, despite being in POSIX going back a few years. We found, at least on the OpenSSL project, that using locale_t caused compile breakages on a variety of platforms, including some older but active Linux variants. Just raising awareness as I'm working this issue there. Sincerely, Randall
diff --git a/detect-compiler b/detect-compiler index 11d60da5b7..473f3bd4fe 100755 --- a/detect-compiler +++ b/detect-compiler @@ -9,7 +9,7 @@ CC="$*" # # FreeBSD clang version 3.4.1 (tags/RELEASE...) get_version_line() { - $CC -v 2>&1 | grep ' version ' + LANG=C $CC -v 2>&1 | grep ' version ' } get_family() {
`detect-compiler` has accumulated a few compiler dependent workarounds lately for the more and more ubiquitious gcc12. This is intended to make CI set-ups work across tool-chain updates, but also help those developers who build with `DEVELOPER=1`. Alas, `detect-compiler` uses the locale dependent output of `$(CC) -v` to parse for the version string, which fails unless it literally contains ` version`. Use `LANG=C $(CC) -v` instead to grep for stable output. Signed-off-by: Michael J Gruber <git@grubix.eu> --- Sorry for not checking the ML before sending the previous patches. I know now that the dir.c warning is a false psoitive and http.c's use of stack variables and globals is a mess ;) To my excuse: Over here, the problem with the warnings was made worse because `DEVELOPER=1` turned them into errors for reasons fixed by this patch ... detect-compiler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)