Skip to content
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

Use default-members in Cargo workspace #58

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
[alias]
xtask = "run --package xtask --"
xtask = "run --package xtask --"

# this should migrate to cargo per-target profiles when it is implemented

[target.bpfel-unknown-none]
rustflags = [
"-C", "panic=abort",
"-C", "lto=yes",
"-C", "embed-bitcode=yes",
"-C", "debuginfo=2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not turn this on now. It’ll make building slower for no reason

"-C", "opt-level=3",
"-C", "codegen-units=1",
"-C", "debug-assertions=no",
"-C", "overflow-checks=no",
"-C", "incremental=no",
]

[target.bpfeb-unknown-none]
rustflags = [
"-C", "panic=abort",
"-C", "lto=yes",
"-C", "embed-bitcode=yes",
"-C", "debuginfo=2",
"-C", "opt-level=3",
"-C", "codegen-units=1",
"-C", "debug-assertions=no",
"-C", "overflow-checks=no",
"-C", "incremental=no",
]
3 changes: 2 additions & 1 deletion .vim/coc-settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"rust-analyzer.linkedProjects": ["Cargo.toml", "{{project-name}}-ebpf/Cargo.toml"]
"rust-analyzer.checkOnSave.allTargets": false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to set this to false?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it suppresses a really annoying "cannot find module for test" message in RA - which happens because it's attempting to analyze the bpf crates as x86_64. There isn't a way (yet) to say these crates are only supported on these subset of targets as far as RA is concerned.

"rust-analyzer.checkOnSave.command": "clippy"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this not the default?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2022-09-10 at 15 54 49

}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"rust-analyzer.linkedProjects": ["Cargo.toml", "{{project-name}}-ebpf/Cargo.toml"]
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.checkOnSave.command": "clippy"
}
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[workspace]
members = ["{{project-name}}", "{{project-name}}-common", "xtask"]
members = ["{{project-name}}", "{{project-name}}-ebpf", "{{project-name}}-common", "xtask"]
default-members = ["{{project-name}}", "{{project-name}}-common", "xtask"]
2 changes: 1 addition & 1 deletion xtask/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn run(opts: Options) -> Result<(), anyhow::Error> {
args.append(&mut run_args);

// spawn the command
let err = Command::new(args.get(0).expect("No first argument"))
let err = Command::new(args.first().expect("No first argument"))
.args(args.iter().skip(1))
.exec();

Expand Down
21 changes: 1 addition & 20 deletions {{project-name}}-ebpf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,4 @@ aya-log-ebpf = { git = "https://github.com/aya-rs/aya", branch = "main" }

[[bin]]
name = "{{ project-name }}"
path = "src/main.rs"

[profile.dev]
opt-level = 3
debug = false
debug-assertions = false
overflow-checks = false
lto = true
panic = "abort"
incremental = false
codegen-units = 1
rpath = false

[profile.release]
lto = true
panic = "abort"
codegen-units = 1

[workspace]
members = []
path = "src/main.rs"