Skip to content

Commit 55b1236

Browse files
committed
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)
1 parent ee6eed3 commit 55b1236

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

vlib/log/common.v

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub enum LogTarget {
2020
}
2121

2222
// tag_to_console returns the tag for log level `l` as a colored string.
23+
@[noinline]
2324
fn tag_to_console(l Level, short_tag bool) string {
2425
if short_tag {
2526
return match l {
@@ -43,6 +44,7 @@ fn tag_to_console(l Level, short_tag bool) string {
4344
}
4445

4546
// tag_to_file returns the tag for log level `l` as a string.
47+
@[noinline]
4648
fn tag_to_file(l Level, short_tag bool) string {
4749
if short_tag {
4850
return match l {
@@ -67,6 +69,7 @@ fn tag_to_file(l Level, short_tag bool) string {
6769

6870
// level_from_tag returns the log level from the given string.
6971
// It returns `none` when it does not find a match.
72+
@[noinline]
7073
pub fn level_from_tag(tag string) ?Level {
7174
return match tag {
7275
'DISABLED', ' ' { Level.disabled }
@@ -81,6 +84,7 @@ pub fn level_from_tag(tag string) ?Level {
8184

8285
// target_from_label returns the log target from the given string.
8386
// It returns `none` when it does not find a match.
87+
@[noinline]
8488
pub fn target_from_label(label string) ?LogTarget {
8589
return match label {
8690
'console' { LogTarget.console }

0 commit comments

Comments
 (0)