cc: use @response files to avoid command line length limits (#5750)

pull/5756/head
Emily Hudson 2020-07-08 13:50:17 +01:00 committed by GitHub
parent 1d24fecc1b
commit 3b0dfd9ae1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -395,10 +395,15 @@ fn (mut v Builder) cc() {
println('cc args=$args') println('cc args=$args')
println(a) 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: start:
todo() todo()
// TODO remove // TODO remove
cmd := '${ccompiler} $args' cmd := '${ccompiler} @$response_file'
// Run // Run
if v.pref.is_verbose || v.pref.show_cc { if v.pref.is_verbose || v.pref.show_cc {
println('\n==========') println('\n==========')

View File

@ -199,6 +199,7 @@ pub fn (mut v Builder) cc_msvc() {
} }
out_name_obj := os.real_path(v.out_name_c + '.obj') out_name_obj := os.real_path(v.out_name_c + '.obj')
out_name_pdb := os.real_path(v.out_name_c + '.pdb') 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 // Default arguments
// volatile:ms enables atomic volatile (gcc _Atomic) // volatile:ms enables atomic volatile (gcc _Atomic)
// -w: no warnings // -w: no warnings
@ -288,7 +289,11 @@ pub fn (mut v Builder) cc_msvc() {
} }
a << lib_paths a << lib_paths
args := a.join(' ') 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 :-| ... // It is hard to see it at first, but the quotes above ARE balanced :-| ...
// Also the double quotes at the start ARE needed. // Also the double quotes at the start ARE needed.
if v.pref.is_verbose { if v.pref.is_verbose {