Skip to content

Commit 18d9364

Browse files
authored
pref: avoid changing the backend with .js.v when -backend has already been used (fix #7840) (#24654)
1 parent 8c573cf commit 18d9364

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

‎vlib/v/pref/pref.v‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@ pub const supported_test_runners = ['normal', 'simple', 'tap', 'dump', 'teamcity
8787
@[heap; minify]
8888
pub struct Preferences {
8989
pub mut:
90-
os OS // the OS to compile for
91-
backend Backend
92-
build_mode BuildMode
93-
arch Arch
94-
output_mode OutputMode = .stdout
90+
os OS // the OS to compile for
91+
backend Backend
92+
backend_set_by_flag bool // true when the compiler receives `-b`/`-backend`
93+
build_mode BuildMode
94+
arch Arch
95+
output_mode OutputMode = .stdout
9596
// verbosity VerboseLevel
9697
is_verbose bool
9798
// nofmt bool // disable vfmt
@@ -919,6 +920,7 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
919920
res.output_cross_c = true
920921
}
921922
res.backend = b
923+
res.backend_set_by_flag = true
922924
i++
923925
}
924926
'-es5' {
@@ -1051,11 +1053,9 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
10511053
res.show_asserts = res.show_asserts || res.is_stats || os.getenv('VTEST_SHOW_ASSERTS') != ''
10521054

10531055
if res.os != .wasm32_emscripten {
1054-
if res.out_name.ends_with('.js') {
1055-
if !res.build_options.any(it.starts_with('-backend') || it.starts_with('b')) {
1056-
res.backend = .js_node
1057-
res.output_cross_c = true
1058-
}
1056+
if res.out_name.ends_with('.js') && !res.backend_set_by_flag {
1057+
res.backend = .js_node
1058+
res.output_cross_c = true
10591059
}
10601060
}
10611061

0 commit comments

Comments
 (0)