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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix cgo build failures with specific GCC flags #2097
Fix cgo build failures with specific GCC flags #2097
Changes from 2 commits
457e4e7
a2c8859
2da4b47
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is deprecated and is only used to build cgo code for a very narrow legacy case.
_cgo_context_data_impl
is probably the right place to add this flag (toc_compile_options
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've confirmed by A/B building with and without this line that this is the exact target that is causing the problem.
I'm building github.com/mattn/go-sqlite3
The build rule generated is:
I put it here since restricting it to the smallest scope seemed like a good idea rather than being more broad. I'm happy to do whatever you want though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that's strange. Is that on
master
or an older version of rules_go? I triedbazel build @com_github_mattn_go_sqlite3//:go_default_library
with rules_go and go-sqlite3 at master, butsetup_cgo_library_for_mode
wasn't called (checked by adding afail
in there).By any chance, do you have
objc = True
set in a rule somewhere?In any case please do add this to
_cgo_context_data_impl
. The legacy path should disappear at some point soon.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for you, I upgraded to the latest released rules_go (0.18.6), and I'm still seeing it. I'm using Gazelle 0.17.0. The only
objc = True
in our code base is in a test in rules_go.I removed the offending rule and gazelle added it back without changes. So I think it's not some legacy flag on the rule. I suspect Bazel is building the binary even if it is unused for completeness.
I used
-s
with bazel and changed some cgo code to add an unused variable warning and already found-Wno-unused-variable
in the command line used to build the cgo generated code, and in the command line used to build standalone c code. I'm reluctant to add it somewhere else since that would duplicate the flag.Let me know what you want to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, the
release-0.18
branch was cut before the new cgo stuff was merged, so this path will still be active there. It shouldn't be active atmaster
though (unlessobjc = True
).So I think this option should in both
_cgo_context_data_impl
andsetup_cgo_library_for_mode
. I'll backport the latter part torelease-0.18
after this is merged (the next minor release will likely be early July).Some time after
release-0.19
is cut, I'll remove the legacy path, which will un-duplicate this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your request got hard... I want to test master with the failing code before sending it out for review, but that's a fair amount of work. I'm tempted to just roll this part back and revisit when you cut a new release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up to you. I'm fine with this being left here, just be aware that the old path will disappear in a few weeks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just do that then. Merge this as is (assuming you have no more feedback), and then when we upgrade again, I'll take stock of how things look and send you any reviews needed to finish this.
Thanks Jay!