[libcxx-commits] [libcxx] [libc++] Refactor iostream.cpp (PR #121116)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jan 15 07:28:57 PST 2025
https://github.com/ldionne commented:
Let's assume the following ground truth: The `init_priority` attribute controls the order of initialization across TUs (including through static archives), but not across final linked images (dylibs, `so`s). We can revisit if that's not the case.
I'm also going to assume that essentially no one calls `ios_base::Init::Init()` explicitly, people just assume that the streams are already initialized. I'm not certain that's a reasonable assumption, that should be validated.
But if both assumptions hold, then I think this patch would be OK, since people are already relying on `libc++.dylib`'s globals being initialized before their own `dylib`, and we're not changing that.
However, on platforms like macOS where `init_priority` is essentially ignored by the linker, people who link statically against `libc++.a` previously had a way to ensure the initialization of streams by calling `Init()`, and this patch would break that.
I've run out of time to think about potential solutions right now, but we can pick this up again at another time to brainstorm on potential solutions. I am just not certain that the current approach will work, I think it may break legitimate (but arguably rare) programs.
https://github.com/llvm/llvm-project/pull/121116
More information about the libcxx-commits
mailing list