From c14c32412531e461b16d88c777d25347095e2a90 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 29 Nov 2021 05:00:20 +0300 Subject: [PATCH] pref: .o build mode --- vlib/v/gen/c/cmain.v | 4 ++++ vlib/v/pref/pref.v | 3 +++ 2 files changed, 7 insertions(+) diff --git a/vlib/v/gen/c/cmain.v b/vlib/v/gen/c/cmain.v index 3e4925a69e..30c57303ea 100644 --- a/vlib/v/gen/c/cmain.v +++ b/vlib/v/gen/c/cmain.v @@ -10,6 +10,10 @@ pub fn (mut g Gen) gen_c_main() { if g.pref.is_liveshared { return } + if g.pref.is_o { + // no main in .o files + return + } g.out.writeln('') main_fn_start_pos := g.out.len diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index ebd7f824ae..80c2977573 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -107,6 +107,7 @@ pub mut: is_livemain bool // main program that contains live/hot code is_liveshared bool // a shared library, that will be used in a -live main program is_shared bool // an ordinary shared library, -shared, no matter if it is live or not + is_o bool // building an .o file is_prof bool // benchmark every function profile_file string // the profile results will be stored inside profile_file profile_no_inline bool // when true, [inline] functions would not be profiled @@ -556,6 +557,8 @@ pub fn parse_args(known_external_commands []string, args []string) (&Preferences if res.out_name.ends_with('.js') { res.backend = .js_node res.output_cross_c = true + } else if res.out_name.ends_with('.o') { + res.is_o = true } if !os.is_abs_path(res.out_name) { res.out_name = os.join_path(os.getwd(), res.out_name)