From f352dbb8308ddeab5fa47a5d18883f854192ec53 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 22 May 2020 11:34:19 +0200 Subject: Make template definition available in all translation units where used We were trying to be clever but GCC 10's IPA-SRA optimization didn't like it. --- libbuild2/cc/common.txx | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 libbuild2/cc/common.txx (limited to 'libbuild2/cc/common.txx') diff --git a/libbuild2/cc/common.txx b/libbuild2/cc/common.txx new file mode 100644 index 0000000..bfbc52c --- /dev/null +++ b/libbuild2/cc/common.txx @@ -0,0 +1,35 @@ +// file : libbuild2/cc/common.txx -*- C++ -*- +// license : MIT; see accompanying LICENSE file + +namespace build2 +{ + namespace cc + { + // Insert a target "tagging" it with the specified process path and + // verifying that it already exists if requested. Return the lock. + // + template + ulock common:: + insert_library (context& ctx, + T*& r, + string name, + dir_path dir, + const process_path& out, + optional ext, + bool exist, + tracer& trace) + { + auto p (ctx.targets.insert_locked (T::static_type, + move (dir), + path_cast (out.effect), + name, + move (ext), + true, // Implied. + trace)); + + assert (!exist || !p.second.owns_lock ()); + r = &p.first.template as (); + return move (p.second); + } + } +} -- cgit v1.1