浏览代码

Enable unwinding in userspace

Unwinding gives us more information, so we shouldn't disable it
globally. It is already disabled for BPF targets via the target configs
in rustc itself.

This complicates the clippy invocation somewhat, so put it in a shell
script for developer as well as CI use.
Tamir Duberstein 4 月之前
父节点
当前提交
fd00b39f09
共有 5 个文件被更改,包括 21 次插入24 次删除
  1. 8 5
      .github/workflows/ci.yml
  2. 0 6
      Cargo.toml
  3. 12 0
      clippy.sh
  4. 0 12
      test/integration-ebpf/.cargo/config.toml
  5. 1 1
      xtask/src/run.rs

+ 8 - 5
.github/workflows/ci.yml

@@ -46,7 +46,7 @@ jobs:
         run: cargo fmt --all -- --check
         run: cargo fmt --all -- --check
 
 
       - name: Run clippy
       - name: Run clippy
-        run: cargo hack clippy --all-targets --feature-powerset --workspace -- --deny warnings
+        run: ./clippy.sh
 
 
       - run: cargo xtask public-api
       - run: cargo xtask public-api
         if: github.event_name == 'pull_request'
         if: github.event_name == 'pull_request'
@@ -165,10 +165,12 @@ jobs:
           CARGO_CFG_BPF_TARGET_ARCH: ${{ matrix.bpf_target_arch }}
           CARGO_CFG_BPF_TARGET_ARCH: ${{ matrix.bpf_target_arch }}
         run: |
         run: |
           set -euxo pipefail
           set -euxo pipefail
-          cargo hack build --package aya-ebpf --package aya-log-ebpf \
-            --feature-powerset \
+          cargo hack build \
             --target ${{ matrix.target }} \
             --target ${{ matrix.target }} \
-            -Z build-std=core
+            -Z build-std=core \
+            --package aya-ebpf \
+            --package aya-log-ebpf \
+            --feature-powerset
 
 
       - name: Test
       - name: Test
         env:
         env:
@@ -176,7 +178,8 @@ jobs:
           RUST_BACKTRACE: full
           RUST_BACKTRACE: full
         run: |
         run: |
           set -euxo pipefail
           set -euxo pipefail
-          cargo hack test --doc \
+          cargo hack test \
+            --doc \
             --package aya-ebpf \
             --package aya-ebpf \
             --package aya-log-ebpf \
             --package aya-log-ebpf \
             --feature-powerset
             --feature-powerset

+ 0 - 6
Cargo.toml

@@ -96,12 +96,6 @@ tokio = { version = "1.24.0", default-features = false }
 which = { version = "7.0.0", default-features = false }
 which = { version = "7.0.0", default-features = false }
 xdpilone = { version = "1.0.5", default-features = false }
 xdpilone = { version = "1.0.5", default-features = false }
 
 
-[profile.dev]
-panic = "abort"
-
-[profile.release]
-panic = "abort"
-
 [profile.release.package.integration-ebpf]
 [profile.release.package.integration-ebpf]
 debug = 2
 debug = 2
 codegen-units = 1
 codegen-units = 1

+ 12 - 0
clippy.sh

@@ -0,0 +1,12 @@
+#!/usr/bin/env sh
+
+# `-C panic=abort` because "unwinding panics are not supported without std";
+# integration-ebpf contains `#[no_std]` binaries.
+#
+# `-Zpanic_abort_tests` because "building tests with panic=abort is not supported without
+# `-Zpanic_abort_tests`"; Cargo does this automatically when panic=abort is set via profile
+# but we want to preserve unwinding at runtime - here we are just running clippy so we don't
+# care about unwinding behavior.
+#
+# `+nightly` because "the option `Z` is only accepted on the nightly compiler".
+exec cargo +nightly hack clippy "$@" --all-targets --feature-powerset --workspace -- --deny warnings -C panic=abort -Zpanic_abort_tests

+ 0 - 12
test/integration-ebpf/.cargo/config.toml

@@ -1,12 +0,0 @@
-# We have this so that one doesn't need to manually pass
-# --target=bpfel-unknown-none -Z build-std=core when running cargo
-# check/build/doc etc.
-#
-# NB: this file gets loaded only if you run cargo from this directory, it's
-# ignored if you run from the workspace root. See
-# https://doc.rust-lang.org/cargo/reference/config.html#hierarchical-structure
-[build]
-target = ["bpfeb-unknown-none", "bpfel-unknown-none"]
-
-[unstable]
-build-std = ["core"]

+ 1 - 1
xtask/src/run.rs

@@ -54,7 +54,7 @@ pub fn build<F>(target: Option<&str>, f: F) -> Result<Vec<(String, PathBuf)>>
 where
 where
     F: FnOnce(&mut Command) -> &mut Command,
     F: FnOnce(&mut Command) -> &mut Command,
 {
 {
-    // Always use rust-lld and -Zbuild-std in case we're cross-compiling.
+    // Always use rust-lld in case we're cross-compiling.
     let mut cmd = Command::new("cargo");
     let mut cmd = Command::new("cargo");
     cmd.args(["build", "--message-format=json"]);
     cmd.args(["build", "--message-format=json"]);
     if let Some(target) = target {
     if let Some(target) = target {