We analyse the possible ways of gluing twisted products of circles with asymptotically cylindrical Calabi-Yau manifolds to produce manifolds with holonomy G_2, thus generalising the twisted connected sum construction of Kovalev and Corti, Haskins, Nordstrom, Pacini. We then express the extended nu-invariant of Crowley, Goette, and Nordstrom in terms of fixpoint and gluing contributions, which include different types of (generalised) Dedekind sums. Surprisingly, the calculations involve some non-trivial number-theoretical arguments connected with special values of the Dedekind eta-function and the theory of complex multiplication. One consequence of our computations is that there exist compact G_2-manifolds that are not G_2-nullbordant.