Remove reliance on static initializers for registration #359
Labels
No labels
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/store
bug
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
imported
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
RFD
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
ux
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#359
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A few places in Lix rely on static initializers to register various ops or backends. This is generally a bad idea: static initializers have undefined execution ordering which can vary across builds or even sometimes across runs, they break inter-module dependency analysis which can lead to really weird behavior with static .a builds, they break a whole bunch of static analysis / unused code detection, etc.
They also happen to be global and impossible to be made not-global, which could impair plans for a better liblix.
Let's instead switch to explicit registration of those ops / backends / ... as part of an "init" function/method. This will keep them as global for now - this proposed change is neutral on that dimension. The old
Register*
structs used for static initializer registration will be kept in the short term as__attribute__((deprecated))
for plugin compatibility, but this might be revisited if we decide not to care about plugin source compatibility.Known places to update:
cl/1905
)cl/1385
)plugin-files
setting documentationThe beginning for
RegisterPrimOp
removal is at https://gerrit.lix.systems/c/lix/+/1342Of the cases I've listed, I think
GlobalConfig::Register
will likely be the thorniest. It's being used across shared libraries, which means it's really not trivial to invert the dependency without introducing loops. Most likely it will need a fairly major refactor of the initialization API for all the sub libs in Lix.The other ones seem self contained to a single shared module so they should be easier.
cl/1385
should take care ofRegisterStoreImplementation
This issue was mentioned on Gerrit on the following CLs:
RegisterLegacyCommand
")Removed
RegisterLegacyCommand
in https://gerrit.lix.systems/c/lix/+/1905