From bd9ca1e55dc1396da73c4699ccc021dc1f604fe6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 15 Jun 2020 08:12:41 +0200 Subject: Diagnose building of module or ad hoc C++ recipe using static build system --- libbuild2/module.cxx | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'libbuild2/module.cxx') diff --git a/libbuild2/module.cxx b/libbuild2/module.cxx index 4c663a3..d45ceed 100644 --- a/libbuild2/module.cxx +++ b/libbuild2/module.cxx @@ -3,7 +3,7 @@ #include -#ifndef BUILD2_BOOTSTRAP +#if !defined(BUILD2_BOOTSTRAP) && !defined(LIBBUILD2_STATIC_BUILD) # ifndef _WIN32 # include # else @@ -181,6 +181,7 @@ namespace build2 // Note: also used by ad hoc recipes thus not static. // +#if !defined(BUILD2_BOOTSTRAP) && !defined(LIBBUILD2_STATIC_BUILD) pair load_module_library (const path& lib, const string& sym, string& err) { @@ -190,8 +191,6 @@ namespace build2 void* h (nullptr); void* s (nullptr); -#ifndef BUILD2_BOOTSTRAP - #ifndef _WIN32 // Use RTLD_NOW instead of RTLD_LAZY to both speed things up (we are going // to use this module now) and to detect any symbol mismatches. @@ -218,17 +217,27 @@ namespace build2 err = win32::last_error_msg (); #endif -#endif // BUILD2_BOOTSTRAP - return make_pair (h, s); } +#else + pair + load_module_library (const path&, const string&, string&) + { + return pair (nullptr, nullptr); + } +#endif static module_load_function* - import_module (scope& bs, - const string& mod, - const location& loc, - bool boot, - bool opt) + import_module ( +#if defined(BUILD2_BOOTSTRAP) || defined(LIBBUILD2_STATIC_BUILD) + scope&, +#else + scope& bs, +#endif + const string& mod, + const location& loc, + bool boot, + bool opt) { tracer trace ("import_module"); @@ -256,13 +265,20 @@ namespace build2 module_load_function* r (nullptr); - // No dynamic loading of build system modules during bootstrap. + // No dynamic loading of build system modules during bootstrap or if + // statically-linked.. // -#ifdef BUILD2_BOOTSTRAP +#if defined(BUILD2_BOOTSTRAP) || defined(LIBBUILD2_STATIC_BUILD) if (!opt) + { fail (loc) << "unknown build system module " << mod << +#ifdef BUILD2_BOOTSTRAP info << "running bootstrap build system"; #else + info << "running statically-linked build system"; +#endif + } +#else context& ctx (bs.ctx); // See if we can import a target for this module. @@ -458,7 +474,7 @@ namespace build2 else l5 ([&]{trace << "unable to load " << lib << ": " << err;}); -#endif // BUILD2_BOOTSTRAP +#endif // BUILD2_BOOTSTRAP || LIBBUILD2_STATIC_BUILD return r; } -- cgit v1.1