From 0a52676ff3de5b302eb4fa85ed8440ae14281318 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 30 Jun 2021 13:01:16 +0200 Subject: Move symbol exporting .def file rule to bin.def module, add support for MinGW The bin.def module is automatically loaded by the c and cxx modules for the *-win32-msvc target architecture. This allows automatically exporting all symbols for all Windows targets using the following setup (showing for cxx in this example): lib{foo}: libul{foo}: {hxx cxx}{**} ... lib{foo}: def{foo}: include = ($cxx.target.system == 'win32-msvc') def{foo}: libul{foo} if ($cxx.target.system == 'mingw32') cxx.loptions += -Wl,--export-all-symbols That is, we use the .def file generation for MSVC and the built-in support (--export-all-symbols) for MinGW. But it is also possible to use the .def file generation for MinGW. In this case we need to explicitly load the bin.def module (which should be done after loading c or cxx) and using the following setup: using bin.def # In root.build. lib{foo}: libul{foo}: {hxx cxx}{**} ... lib{foo}: def{foo}: include = ($cxx.target.class == 'windows') def{foo}: libul{foo} --- libbuild2/cc/init.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libbuild2/cc/init.cxx') diff --git a/libbuild2/cc/init.cxx b/libbuild2/cc/init.cxx index eae6d6d..f201d79 100644 --- a/libbuild2/cc/init.cxx +++ b/libbuild2/cc/init.cxx @@ -340,15 +340,17 @@ namespace build2 } } - // Load bin.*.config for bin.* modules we may need (see core_init() - // below). + // Load bin.* modules we may need (see core_init() below). // const string& tsys (cast (rs["cc.target.system"])); load_module (rs, rs, "bin.ar.config", loc); if (tsys == "win32-msvc") + { load_module (rs, rs, "bin.ld.config", loc); + load_module (rs, rs, "bin.def", loc); + } if (tsys == "mingw32") load_module (rs, rs, "bin.rc.config", loc); -- cgit v1.1