d: Add -fbuilding-libphobos-tests option
Currently, the druntime and phobos unittests are compiled as a separate
check program, then ran by the libphobos.unittest/unittest.exp script.
As PR d/89255 notes, this process lacks proper multilib handling.
As a first step, a new internal option that instructs the compiler to
put the reference to all unittest functions in another symbol has been
added. This will allow each module to be compiled separately as a
standalone program using dg-runtest without running into collisions in
the D runtime module registry.
gcc/d/ChangeLog:
2019-04-12 Iain Buclaw <ibuclaw@gdcproject.org>
* d-tree.h (DECL_IN_UNITTEST_CONDITION_P): Define.
* decl.cc (DeclVisitor): Add in_version_unittest_ field.
(DeclVisitor::visit(ConditionalDeclaration)): New override.
(DeclVisitor::visit(FuncDeclaration)): Set
DECL_IN_UNITTEST_CONDITION_P.
* lang.opt (-fbuilding-libphobos-tests): Add option.
* modules.cc (current_testing_module): New static variable.
(build_module_tree): Generate second moduleinfo symbol to hold
reference to unittests if flag_building_libphobos_tests.
(register_module_decl): Check DECL_IN_UNITTEST_CONDITION_P to decide
which moduleinfo the decl should be registered against.
From-SVN: r270301