Disallow duplicate cxx library names#94
Draft
cormacrelf wants to merge 2 commits intofacebookincubator:mainfrom
Draft
Disallow duplicate cxx library names#94cormacrelf wants to merge 2 commits intofacebookincubator:mainfrom
cormacrelf wants to merge 2 commits intofacebookincubator:mainfrom
Conversation
This renders back to what it was parsed from, roughly.
dtolnay
reviewed
Jan 11, 2026
dtolnay
left a comment
There was a problem hiding this comment.
Would it be feasible and a better user experience to collapse multiple identically named cxx_library into one Buck target using platform for the attributes that diverge?
It would still be necessary to check that one platform does not depend on multiple of the libraries, but this solves the ability to reuse a cxx library name across multiple version-specific fixups, and now also across distinct platforms.
cxx_library(
name = "bzip2-sys-0.1.13+1.0.8-bzip2",
headers = [
":bzip2-sys-0.1.13+1.0.8.crate[bzip2-1.0.8/bzlib.h]",
":bzip2-sys-0.1.13+1.0.8.crate[bzip2-1.0.8/bzlib_private.h]",
],
platform = {
"custom_config=abc": dict(
preprocessor_flags = [
"-D_FILE_OFFSET_BITS=64",
"-DBZ_NO_STDIO",
"-DABC",
],
srcs = [":bzip2-sys-0.1.13+1.0.8.crate[bzip2-1.0.8/huffman.c]"],
),
"custom_config=def": dict(
preprocessor_flags = [
"-D_FILE_OFFSET_BITS=64",
"-DBZ_NO_STDIO",
"-DDEF",
],
srcs = [":bzip2-sys-0.1.13+1.0.8.crate[bzip2-1.0.8/blocksort.c]"],
),
},
visibility = [],
)
Contributor
Author
|
Yes, that would be nicest. What I described at the end (one last-write-winner per platform, error if incompatible dupes cross platform) would be a step in that direction, and would be less work for now, I think. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
There is a trap for fixups like this with two cxx_library targets of the same name:
This produces a single cxx_library
Which is used by both platforms linux-abc and linux-def. Note that both fixup entries have the same
name = "bzip2"and therefore target name, so there can be only one actually emitted. If the user tries this they'll typically find windows flags all over their build unconditionally, because the last write wins alphabetically by platform name and windows starts with "w".Reindeer's behaviour in this case is to silently clobber the
abcone. I would have expected an error or warning. I specified two different cxx_libraries and ended up with just one, which was a bad outcome.What users should do instead
Which allows reindeer to select a different cxx_library for each platform.
This PR: detect when users use duplicate names
This PR adds an error for any time we are emitting a cxx library or prebuilt cxx library more than once with the same target name. The example above produces an error with this PR:
Unresolved questions
How to allow versioning use case for silent clobbering
For example the
ringfixups from Meta under this PR produce this error:This PR could possibly be adjusted to allow clobbering within any one reindeer platform's fixup evaluations, so that this kind of versioning shenanigans can still work. The goal would be more specific, instead detecting multiple platforms producing conflicting (
!=) versions of the same cxx_library and clobbering each other.