Skip to content

Commit

Permalink
v.builder: fix building with -cc msvc and non ASCII characters in p…
Browse files Browse the repository at this point in the history
…aths on windows 11 (#22410)
  • Loading branch information
spytheman authored Oct 4, 2024
1 parent dc6a958 commit 209c30f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion vlib/builtin/utf8.v
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ pub fn utf8_str_visible_length(s string) int {
pub fn string_to_ansi_not_null_terminated(_str string) []u8 {
wstr := _str.to_wide()
mut ansi := wide_to_ansi(wstr)
ansi.pop() // remove tailing zero
if ansi.len > 0 {
unsafe { ansi.len-- } // remove tailing zero
}
return ansi
}
4 changes: 2 additions & 2 deletions vlib/v/builder/msvc_windows.v
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ pub fn (mut v Builder) cc_msvc() {
a << env_ldflags
}
v.dump_c_options(a)
args := a.join(' ')
args := '\xEF\xBB\xBF' + a.join(' ')
// write args to a file so that we dont smash createprocess
os.write_file_array(out_name_cmd_line, string_to_ansi_not_null_terminated(args)) or {
os.write_file(out_name_cmd_line, args) or {
verror('Unable to write response file to "${out_name_cmd_line}"')
}
cmd := '"${r.full_cl_exe_path}" "@${out_name_cmd_line}"'
Expand Down

0 comments on commit 209c30f

Please sign in to comment.