v.pref, v.builder: support `-no-rsp` (pass C options directly to the C compiler backend, without writing response files)
parent
7494d7f6c7
commit
f7cbcc241a
|
@ -228,6 +228,15 @@ see also `v help build`.
|
||||||
Write all C flags into `file.txt`, one flag per line.
|
Write all C flags into `file.txt`, one flag per line.
|
||||||
If `file.txt` is `-`, then write the flags to stdout, one flag per line.
|
If `file.txt` is `-`, then write the flags to stdout, one flag per line.
|
||||||
|
|
||||||
|
-no-rsp
|
||||||
|
By default, V passes all C compiler options to the backend C compiler
|
||||||
|
in so called "response files" (https://gcc.gnu.org/wiki/Response_Files).
|
||||||
|
This works in most cases, since it works around command line length
|
||||||
|
limitations on older systems (and windows), but some C compilers
|
||||||
|
(older versions of tcc for example) do not support them at all. When
|
||||||
|
you use -no-rsp, V will pass the C compiler options directly to the C
|
||||||
|
compiler, on the command line, without writing an .rsp file first.
|
||||||
|
|
||||||
-assert aborts
|
-assert aborts
|
||||||
Call abort() after an assertion failure. Debuggers usually
|
Call abort() after an assertion failure. Debuggers usually
|
||||||
install signal handlers for SIGABRT, so your program will stop and you
|
install signal handlers for SIGABRT, so your program will stop and you
|
||||||
|
|
|
@ -148,14 +148,11 @@ fn (mut v Builder) rebuild_cached_module(vexe string, imp_path string) string {
|
||||||
|
|
||||||
fn (mut v Builder) show_cc(cmd string, response_file string, response_file_content string) {
|
fn (mut v Builder) show_cc(cmd string, response_file string, response_file_content string) {
|
||||||
if v.pref.is_verbose || v.pref.show_cc {
|
if v.pref.is_verbose || v.pref.show_cc {
|
||||||
println('')
|
|
||||||
println('=====================')
|
|
||||||
println('> C compiler cmd: $cmd')
|
println('> C compiler cmd: $cmd')
|
||||||
if v.pref.show_cc {
|
if v.pref.show_cc && !v.pref.no_rsp {
|
||||||
println('> C compiler response file $response_file:')
|
println('> C compiler response file "$response_file":')
|
||||||
println(response_file_content)
|
println(response_file_content)
|
||||||
}
|
}
|
||||||
println('=====================')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,15 +607,22 @@ fn (mut v Builder) cc() {
|
||||||
all_args := v.all_args(v.ccoptions)
|
all_args := v.all_args(v.ccoptions)
|
||||||
v.dump_c_options(all_args)
|
v.dump_c_options(all_args)
|
||||||
str_args := all_args.join(' ')
|
str_args := all_args.join(' ')
|
||||||
// write args to response file
|
mut cmd := '$ccompiler $str_args'
|
||||||
response_file := '${v.out_name_c}.rsp'
|
mut response_file := ''
|
||||||
response_file_content := str_args.replace('\\', '\\\\')
|
mut response_file_content := str_args
|
||||||
os.write_file(response_file, response_file_content) or {
|
if !v.pref.no_rsp {
|
||||||
verror('Unable to write response file "$response_file"')
|
response_file = '${v.out_name_c}.rsp'
|
||||||
|
response_file_content = str_args.replace('\\', '\\\\')
|
||||||
|
cmd = '$ccompiler "@$response_file"'
|
||||||
|
os.write_file(response_file, response_file_content) or {
|
||||||
|
verror('Unable to write to C response file "$response_file"')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !v.ccoptions.debug_mode {
|
if !v.ccoptions.debug_mode {
|
||||||
v.pref.cleanup_files << v.out_name_c
|
v.pref.cleanup_files << v.out_name_c
|
||||||
v.pref.cleanup_files << response_file
|
if !v.pref.no_rsp {
|
||||||
|
v.pref.cleanup_files << response_file
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$if windows {
|
$if windows {
|
||||||
if v.ccoptions.is_cc_tcc {
|
if v.ccoptions.is_cc_tcc {
|
||||||
|
@ -628,7 +632,6 @@ fn (mut v Builder) cc() {
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
os.chdir(vdir)
|
os.chdir(vdir)
|
||||||
cmd := '$ccompiler "@$response_file"'
|
|
||||||
tried_compilation_commands << cmd
|
tried_compilation_commands << cmd
|
||||||
v.show_cc(cmd, response_file, response_file_content)
|
v.show_cc(cmd, response_file, response_file_content)
|
||||||
// Run
|
// Run
|
||||||
|
|
|
@ -172,6 +172,7 @@ pub mut:
|
||||||
warns_are_errors bool // -W, like C's "-Werror", treat *every* warning is an error
|
warns_are_errors bool // -W, like C's "-Werror", treat *every* warning is an error
|
||||||
fatal_errors bool // unconditionally exit after the first error with exit(1)
|
fatal_errors bool // unconditionally exit after the first error with exit(1)
|
||||||
reuse_tmpc bool // do not use random names for .tmp.c and .tmp.c.rsp files, and do not remove them
|
reuse_tmpc bool // do not use random names for .tmp.c and .tmp.c.rsp files, and do not remove them
|
||||||
|
no_rsp bool // when true, pass C backend options directly on the CLI (do not use `.rsp` files for them, some older C compilers do not support them)
|
||||||
use_color ColorOutput // whether the warnings/errors should use ANSI color escapes.
|
use_color ColorOutput // whether the warnings/errors should use ANSI color escapes.
|
||||||
is_parallel bool
|
is_parallel bool
|
||||||
error_limit int
|
error_limit int
|
||||||
|
@ -474,6 +475,9 @@ pub fn parse_args(known_external_commands []string, args []string) (&Preferences
|
||||||
'-W' {
|
'-W' {
|
||||||
res.warns_are_errors = true
|
res.warns_are_errors = true
|
||||||
}
|
}
|
||||||
|
'-no-rsp' {
|
||||||
|
res.no_rsp = true
|
||||||
|
}
|
||||||
'-keepc' {
|
'-keepc' {
|
||||||
res.reuse_tmpc = true
|
res.reuse_tmpc = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue