lib: generate symbol lists for shared objects #17909
Draft
+4,806
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
The abigail ABI checker is very good, but is hard to use locally, not least because it's output is very dependent on the version used. It's great for CI to catch unexpected changes, less good when you're doing things that are actively trying to make changes and you want to see what the results are.
This PR adds a lighter alternative: produce the list of symbols visible in the shared objects for the linker to use. This won't cover every possible ABI break, but will at least show when a symbol is added or removed. And, it can be run easily; it only needs the common
nmutility and any changes are immediately visible viagit diff.Description
It's very simple. Run
make syms. Once the '.so' file is generated, it runsnm -DUjto get the list of exported symbols, sorts them, and writes them to files in the lib dirs. If they've changed, git will notice, and they can be inspected and either the errant thing fixed, or the changes committed.I haven't hooked it up as part of any standard build yet though, because it seems a bit too variable. For example, presence of
strlcpyandstrlcatvaries depending on the target libc, and there are obvious differences between platforms. It might need to get smarter, eg understand differences based on config or platform, but I don't want to get into the weeds. I'm aiming for a simple early warning, not a whole complex replacement for checkabi.I wrote this to support a side project to clean up all our library exports (we currently expose symbols from transitive internal dependencies, which is a lot of cruft that shouldn't be part of our ABI). So this might be better left until I've finished that cleanup. Or, maybe its better to just merge the code but not the outputs yet. Discuss!
How Has This Been Tested?
It is its own thing, so no testing outside it.
After a completed build, run it:
or verbosely:
So I make a change for some reason. Maybe I don't want to be able to increment 8-bit values anymore.
make syms, and then the diff shows:(as you see, we export too much, but that's another PR another day).
Types of changes
Checklist:
Signed-off-by.