diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2019-10-18 14:05:03 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2019-10-18 14:05:03 +0200 |
commit | 0d6f835ffb582296d24a8d1dd479e2703e075ee3 (patch) | |
tree | 214f9ceb5699438497c8e0dcf047c167cfaf6132 /libbuild2/cc/link-rule.cxx | |
parent | a566a3acc84386e4738711d27a250f63e59cbb6b (diff) |
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"
Diffstat (limited to 'libbuild2/cc/link-rule.cxx')
-rw-r--r-- | libbuild2/cc/link-rule.cxx | 20 |
1 files changed, 12 insertions, 8 deletions
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<const char*> 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"); |