d: Add -fbuilding-libphobos-tests option

Programming / Compilers / GCC - ibuclaw [138bc75d-0d04-0410-961f-82ee72b054a4] - 12 April 2019 06:25 EDT

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

- 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.

fc11fa1709f d: Add -fbuilding-libphobos-tests option
gcc/d/ChangeLog | 14 ++++++++++
gcc/d/d-tree.h | 7 ++++-
gcc/d/decl.cc | 25 ++++++++++++++++++
gcc/d/lang.opt | 4 +++
gcc/d/modules.cc | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
5 files changed, 122 insertions(+), 8 deletions(-)

Upstream: gcc.gnu.org


  • Share