From 0d6f835ffb582296d24a8d1dd479e2703e075ee3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 18 Oct 2019 14:05:03 +0200 Subject: Add ability to specify "compiler mode" options as part of config.{c,cxx} Such options are (normally) not overridden by buildfiles and are passed last (after cc.coptions and {c,cxx}.coptions) in the resulting command lines. They are also cross-hinted between config.c and config.cxx. For example: $ b config.cxx="g++ -m64" --- libbuild2/cc/link-rule.cxx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'libbuild2/cc/link-rule.cxx') diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx index f10bd42..16a4ce7 100644 --- a/libbuild2/cc/link-rule.cxx +++ b/libbuild2/cc/link-rule.cxx @@ -2237,12 +2237,11 @@ namespace build2 } else { - if (tsys == "win32-msvc") - { - // We are using link.exe directly so don't pass the compiler - // options. - } - else + // Are we using the compiler or the linker (e.g., link.exe) directly? + // + bool ldc (tsys != "win32-msvc"); + + if (ldc) { append_options (args, t, c_coptions); append_options (args, t, x_coptions); @@ -2364,6 +2363,9 @@ namespace build2 sargs.push_back ("-Wl,-rpath-link," + p.string ()); } } + + if (ldc) + append_options (args, cmode); } // All the options should now be in. Hash them and compare with the db. @@ -2560,8 +2562,10 @@ namespace build2 // See the runtime selection code in the compile rule for details // on what's going on here. // - if (!find_options ({"-nostdlib", "-nostartfiles"}, t, c_coptions) && - !find_options ({"-nostdlib", "-nostartfiles"}, t, x_coptions)) + initializer_list os {"-nostdlib", "-nostartfiles"}; + if (!find_options (os, cmode) && + !find_options (os, t, c_coptions) && + !find_options (os, t, x_coptions)) { args.push_back ("/DEFAULTLIB:msvcrt"); args.push_back ("/DEFAULTLIB:oldnames"); -- cgit v1.1