diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index 3624c2aba6..3ae44c8095 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -395,10 +395,15 @@ fn (mut v Builder) cc() { println('cc args=$args') println(a) } + // write args to response file + response_file := '${v.out_name_c}.rsp' + os.write_file(response_file, args.replace('\\', '\\\\')) or { + verror('Unable to write response file "$response_file"') + } start: todo() // TODO remove - cmd := '${ccompiler} $args' + cmd := '${ccompiler} @$response_file' // Run if v.pref.is_verbose || v.pref.show_cc { println('\n==========') diff --git a/vlib/v/builder/msvc.v b/vlib/v/builder/msvc.v index 56bbd21ae2..6f4bbfd588 100644 --- a/vlib/v/builder/msvc.v +++ b/vlib/v/builder/msvc.v @@ -199,6 +199,7 @@ pub fn (mut v Builder) cc_msvc() { } out_name_obj := os.real_path(v.out_name_c + '.obj') out_name_pdb := os.real_path(v.out_name_c + '.pdb') + out_name_cmd_line := os.real_path(v.out_name_c + '.rsp') // Default arguments // volatile:ms enables atomic volatile (gcc _Atomic) // -w: no warnings @@ -288,7 +289,11 @@ pub fn (mut v Builder) cc_msvc() { } a << lib_paths args := a.join(' ') - cmd := '"$r.full_cl_exe_path" $args' + // write args to a file so that we dont smash createprocess + 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' // It is hard to see it at first, but the quotes above ARE balanced :-| ... // Also the double quotes at the start ARE needed. if v.pref.is_verbose {