Understanding LLVM type creation with DIBuilder

Hi, I have a working project that uses LLVM as a backend. I want to add debug information, using DIBuilder. This gets complex for structs, for example.
The code to handle LLVM structs is:

    // Create the Struct here
    stype->llvm_type = StructType::create(TheContext, struct_members, stype->decl->varname);

    std::vector<Type *> struct_members;
    // loop over all the members, they could have a pointer to the struct but we created it earlier

    for (auto decl : stype->struct_scope.decls) {
        generateCode(decl->specified_type);
        struct_members.push_back(decl->specified_type->llvm_type);
    }
    // And now, set body
    llvm_stype->setBody(struct_members);

This breaks somewhat when trying to do the same with DIBuilder. To create a struct in DIBuilder:

    auto& Layout = TheModule->getDataLayout();
    auto composite_type = DBuilder->createStructType(stype->scope->debug_scope, stype->decl->varname,
        getOrCreateDFile(stype), stype->line_num, Layout.getTypeSizeInBits(stype->llvm_type),
        Layout.getABITypeAlign(stype->llvm_type).value(), DINode::FlagZero, nullptr, DINodeArray());        

Ideally then, to create the struct is only possible after the llvm type is created. I would want to create the struct at the same type the llvm StructType is created, and recurse creating the DITypes too.
This breaks on the SizeInBits, which could differ on each TargetMachine. And the struct needs to be created first since DIBuilder createMember needs the struct for the scope parameter.

How come LLVM and DIBuilder do so very similar things but in quite different ways?

Thank you,