From 25771a1afe4dc3cbadde65c760242691124e9f3c Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 6 Jul 2020 13:42:11 +0300 Subject: [PATCH] compiler: remove -keepc option (it is now always on) --- Makefile | 4 ++-- cmd/v/help/build-c.txt | 4 ---- cmd/v/help/default.txt | 2 +- doc/docs.md | 3 +-- vlib/v/builder/cc.v | 3 --- vlib/v/builder/msvc.v | 7 ------- vlib/v/gen/live.v | 2 +- vlib/v/pref/pref.v | 3 +-- vlib/v/tests/valgrind/valgrind_test.v | 2 +- 9 files changed, 7 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index f578b4efa5..f80e2d23c7 100644 --- a/Makefile +++ b/Makefile @@ -115,10 +115,10 @@ $(VC)/.git/config: $(MAKE) fresh_vc selfcompile: - ./v -keepc -cg -o v cmd/v + ./v -cg -o v cmd/v selfcompile-static: - ./v -keepc -cg -cflags '--static' -o v-static cmd/v + ./v -cg -cflags '--static' -o v-static cmd/v modules: module_builtin module_strings module_strconv module_builtin: diff --git a/cmd/v/help/build-c.txt b/cmd/v/help/build-c.txt index 92b26b5656..897fbd7f68 100644 --- a/cmd/v/help/build-c.txt +++ b/cmd/v/help/build-c.txt @@ -34,10 +34,6 @@ These build flags are enabled on `build` and `run` as long as the backend is set -compress Strip the compiled executable to compress it. - -keepc - Specify that you want V to not delete the intermediate generated C source code. - Use with -cg for best debugging experience. - -freestanding Build the executable without dependency on libc. Supported only on `linux` targets currently. diff --git a/cmd/v/help/default.txt b/cmd/v/help/default.txt index 4a8824e497..b5bfbbc450 100644 --- a/cmd/v/help/default.txt +++ b/cmd/v/help/default.txt @@ -6,7 +6,7 @@ Usage: Examples: v hello.v Compile the file `hello.v` and output it as `hello` or `hello.exe`. v run hello.v Same as above but also run the produced executable immediately after compilation. - v -keepc -cg run hello.v Same as above, but make debugging easier (in case your program crashes). + v -cg run hello.v Same as above, but make debugging easier (in case your program crashes). v -o h.c hello.v Translate `hello.v` to `h.c`. Do not compile further. V supports the following commands: diff --git a/doc/docs.md b/doc/docs.md index ac1915ec64..7060906014 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -1739,10 +1739,9 @@ To cast a `voidptr` to a V reference, use `user := &User(user_void_ptr)`. To debug issues in the generated C code, you can pass these flags: - `-cg` - produces a less optimized executable with more debug information in it. -- `-keepc` - keep the generated C file, so your debugger can also use it. - `-showcc` - prints the C command that is used to build the program. -For the best debugging experience, you can pass all of them at the same time: `v -cg -keepc -showcc yourprogram.v` , then just run your debugger (gdb/lldb) or IDE on the produced executable `yourprogram`. +For the best debugging experience, you can pass all of them at the same time: `v -cg -showcc yourprogram.v` , then just run your debugger (gdb/lldb) or IDE on the produced executable `yourprogram`. If you just want to inspect the generated C code, without further compilation, you can also use the `-o` flag (e.g. `-o file.c`). This will make V produce the `file.c` then stop. diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index fc49d20689..389cc03fc5 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -482,9 +482,6 @@ fn (mut v Builder) cc() { println('linux cross compilation done. resulting binary: "$v.out_name"') } */ - if !v.pref.keep_c && v.out_name_c != 'v.c' { - os.rm(v.out_name_c) - } if v.pref.compress { $if windows { println('-compress does not work on Windows for now') diff --git a/vlib/v/builder/msvc.v b/vlib/v/builder/msvc.v index 84885f3cde..67418c800c 100644 --- a/vlib/v/builder/msvc.v +++ b/vlib/v/builder/msvc.v @@ -192,10 +192,6 @@ fn find_msvc() ?MsvcResult { pub fn (mut v Builder) cc_msvc() { r := find_msvc() or { - // TODO: code reuse - if !v.pref.keep_c && v.out_name_c != 'v.c' && v.out_name_c != 'v_macos.c' { - os.rm(v.out_name_c) - } verror('Cannot find MSVC on this OS') return } @@ -309,9 +305,6 @@ pub fn (mut v Builder) cc_msvc() { } // println(res) // println('C OUTPUT:') - if !v.pref.keep_c && v.out_name_c != 'v.c' && v.out_name_c != 'v_macos.c' { - os.rm(v.out_name_c) - } // Always remove the object file - it is completely unnecessary os.rm(out_name_obj) } diff --git a/vlib/v/gen/live.v b/vlib/v/gen/live.v index f1508c762f..aa5ee37279 100644 --- a/vlib/v/gen/live.v +++ b/vlib/v/gen/live.v @@ -82,7 +82,7 @@ fn (g &Gen) generate_hotcode_reloading_main_caller() { file := util.cescaped_path( g.pref.path ) msvc := if g.pref.ccompiler == 'msvc' { '-cc msvc' } else { '' } so_debug_flag := if g.pref.is_debug { '-cg' } else { '' } - vopts := '$msvc $so_debug_flag -keepc -sharedlive -shared' + vopts := '$msvc $so_debug_flag -sharedlive -shared' // g.writeln('\t\t// start background reloading thread') if g.pref.os == .windows { diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index 45f79c0d7e..e03c4230f4 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -69,7 +69,6 @@ pub mut: sanitize bool // use Clang's new "-fsanitize" option is_debug bool // false by default, turned on by -g or -cg, it tells v to pass -g to the C backend compiler. is_vlines bool // turned on by -g, false by default (it slows down .tmp.c generation slightly). - keep_c bool // -keepc , tell v to leave the generated .tmp.c alone (since by default v will delete them after c backend finishes) show_cc bool // -showcc, print cc command // NB: passing -cg instead of -g will set is_vlines to false and is_g to true, thus making v generate cleaner C files, // which are sometimes easier to debug / inspect manually than the .tmp.c files by plain -g (when/if v line number generation breaks). @@ -197,7 +196,7 @@ pub fn parse_args(args []string) (&Preferences, string) { res.use_cache = true } '-keepc' { - res.keep_c = true + eprintln('-keepc is deprecated. V always keeps the generated .tmp.c files now.') } '-parallel' { res.is_parallel = true diff --git a/vlib/v/tests/valgrind/valgrind_test.v b/vlib/v/tests/valgrind/valgrind_test.v index 9739110e36..fba91746eb 100644 --- a/vlib/v/tests/valgrind/valgrind_test.v +++ b/vlib/v/tests/valgrind/valgrind_test.v @@ -38,7 +38,7 @@ fn test_all() { full_test_path := os.real_path(test) println('x.v: $wrkdir/x.v') os.system('cp ${dir}/${test} $wrkdir/x.v') // cant run .vv file - compile_cmd := '$vexe -cflags "-w" -verbose=3 -autofree -keepc -cg $wrkdir/x.v' + compile_cmd := '$vexe -cflags "-w" -verbose=3 -autofree -cg $wrkdir/x.v' vprintln('compile cmd: $compile_cmd') res := os.exec(compile_cmd) or { bench.fail()