Daniel P. Berrangé <berrange@redhat.com> writes:
On Wed, Feb 18, 2026 at 10:22:27AM +0100, Markus Armbruster wrote:
Daniel P. Berrangé <berrange@redhat.com> writes:
Functions marked with __attribute__((__constructor__)) will be invoked in linker order. In theory this is well defined, but in practice, it is hard to determine what this order will be with the layers of indirection through meson, ninja and the static libraries QEMU builds.
Notably, the order currently appears different between Linux and Windows (as tested with Wine on Linux). This can cause problems when certain QEMU constructors have a dependancy on other QEMU constructors.
To address this define a QEMU_CONSTRUCTOR_EARLY constant which provides a priority value that will run before other default constructors. This is to be used for QEMU constructors that are themselves self-contained, but may be relied upon by other constructors.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
I'm no fan of doing non-trivial work in constructors. We discussed possible alternatives in review of v5. This is an opinion, not a demand. And Paolo's opinion counts a lot more here.
I think that it is worth exploring the alternative idea, but not as part of this series which is already getting way longer than I would like. This constructor usage is trivially removed later if we get there.
Fair!