-
Notifications
You must be signed in to change notification settings - Fork 440
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
Advertise CcInfo provider on rules #2126
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e9139bf
Advertise CcInfo provider on rules
cameron-martin fba3a4c
Merge branch 'main' into advertise-cc-info
cameron-martin 1a979f1
Fix buildifier
cameron-martin e790730
Try linkstatic
cameron-martin b1762cf
Use dllexport to make foo visible
cameron-martin 479cb75
Merge branch 'main' into advertise-cc-info
cameron-martin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") | ||
load("@rules_rust//rust:defs.bzl", "rust_static_library") | ||
|
||
rust_static_library( | ||
name = "rust_lib", | ||
srcs = ["lib.rs"], | ||
edition = "2021", | ||
) | ||
|
||
cc_library( | ||
name = "c_lib", | ||
srcs = ["lib.c"], | ||
hdrs = ["lib.h"], | ||
deps = [":rust_lib"], | ||
) | ||
|
||
# Tests that cc_shared_library correctly traverses into | ||
# `rust_static_library` when linking. | ||
cc_shared_library( | ||
name = "shared", | ||
deps = [":c_lib"], | ||
) | ||
|
||
cc_test( | ||
name = "test", | ||
srcs = ["main.c"], | ||
dynamic_deps = [":shared"], | ||
linkstatic = True, | ||
deps = [":c_lib"], | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "lib.h" | ||
|
||
extern int32_t bar(); | ||
|
||
int32_t foo() { return bar(); } |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <stdint.h> | ||
|
||
#ifdef _WIN32 | ||
#define DllExport __declspec(dllexport) | ||
#else | ||
#define DllExport | ||
#endif | ||
|
||
DllExport int32_t foo(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[no_mangle] | ||
pub extern "C" fn bar() -> i32 { | ||
4 | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <assert.h> | ||
#include <stdint.h> | ||
|
||
#include "lib.h" | ||
|
||
int main(int argc, char** argv) { | ||
assert(foo() == 4); | ||
return 0; | ||
} |
Oops, something went wrong.
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 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.
Will this lead to the same issue as #2359 if
experimental_cc_shared_library
is not set?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.
Do you mean if people are querying it as an external repository, where the root workspace does not have this set?
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.
yeah
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 suppose it will, although in 7.0.0 this is enabled by default so it shouldn't be an issue with the latest version.
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.
@illicitonion given that the issue was referring to a cquery within the
rules_rust
repo, do you think this is an acceptable change? I do like theprocides
changes and love the test. I just don't wanna immediately regress something here.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 sent out #2398 which add tests for what I think we should be aiming to support (i.e.
bazel query ...
andbazel cquery ...
from inside therules_rust
repo) - if we have more things we want to support (e.g.bazel query @rules_rust//...
from a repo that depends onrules_rust
) , we should add tests to CI for them.This PR passes the tests I sent out, so I'm happy :)