log: use @[noinline] for level_from_tag/1 and target_from_label/1 to avoid triggering panics for programs using log, compiled with -prod and -cc gcc>10 (fix #24874)

This commit is contained in:
Delyan Angelov 2025-07-10 14:43:13 +03:00
parent ee6eed3c22
commit 55b1236421
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -20,6 +20,7 @@ pub enum LogTarget {
} }
// tag_to_console returns the tag for log level `l` as a colored string. // tag_to_console returns the tag for log level `l` as a colored string.
@[noinline]
fn tag_to_console(l Level, short_tag bool) string { fn tag_to_console(l Level, short_tag bool) string {
if short_tag { if short_tag {
return match l { return match l {
@ -43,6 +44,7 @@ fn tag_to_console(l Level, short_tag bool) string {
} }
// tag_to_file returns the tag for log level `l` as a string. // tag_to_file returns the tag for log level `l` as a string.
@[noinline]
fn tag_to_file(l Level, short_tag bool) string { fn tag_to_file(l Level, short_tag bool) string {
if short_tag { if short_tag {
return match l { return match l {
@ -67,6 +69,7 @@ fn tag_to_file(l Level, short_tag bool) string {
// level_from_tag returns the log level from the given string. // level_from_tag returns the log level from the given string.
// It returns `none` when it does not find a match. // It returns `none` when it does not find a match.
@[noinline]
pub fn level_from_tag(tag string) ?Level { pub fn level_from_tag(tag string) ?Level {
return match tag { return match tag {
'DISABLED', ' ' { Level.disabled } 'DISABLED', ' ' { Level.disabled }
@ -81,6 +84,7 @@ pub fn level_from_tag(tag string) ?Level {
// target_from_label returns the log target from the given string. // target_from_label returns the log target from the given string.
// It returns `none` when it does not find a match. // It returns `none` when it does not find a match.
@[noinline]
pub fn target_from_label(label string) ?LogTarget { pub fn target_from_label(label string) ?LogTarget {
return match label { return match label {
'console' { LogTarget.console } 'console' { LogTarget.console }