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/bin/init.hxx | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libbuild2/bin/init.hxx') diff --git a/libbuild2/bin/init.hxx b/libbuild2/bin/init.hxx index 6b0db27..4eb0f10 100644 --- a/libbuild2/bin/init.hxx +++ b/libbuild2/bin/init.hxx @@ -25,14 +25,20 @@ namespace build2 // rules. // `bin.ar.config` -- loads bin.config and registers/sets more variables. // `bin.ar` -- loads bin and bin.ar.config. + // // `bin.ld.config` -- loads bin.config and registers/sets more variables. // `bin.ld` -- loads bin and bin.ld.config and registers more // target types for msvc. + // // `bin.rc.config` -- loads bin.config and registers/sets more variables. // `bin.rc` -- loads bin and bin.rc.config. + // // `bin.nm.config` -- loads bin.config and registers/sets more variables. // `bin.nm` -- loads bin and bin.nm.config. // + // `bin.def` -- loads bin, bin.nm.config unless using MSVC link.exe, + // and registers the .def file generation rule. + // extern "C" LIBBUILD2_BIN_SYMEXPORT const module_functions* build2_bin_load (); } -- cgit v1.1