diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..03082b1 --- /dev/null +++ b/.clang-format @@ -0,0 +1,8 @@ +--- +BasedOnStyle: Google + +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +ColumnLimit: 120 +IndentWidth: 4 +SortIncludes: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fc88247 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,36 @@ +name: release + +on: + pull_request: + push: + +# on: +# push: +# branches: +# - main + +jobs: + release: + runs-on: ubuntu-22.04 + permissions: + id-token: write + contents: read + + steps: + - uses: actions/checkout@main + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + + - name: Set up nix dev env + run: nix develop --command echo 0 + + - name: Build statically linked lightswitch with glibc + run: | + nix develop + RUSTFLAGS="-C target-feature=+crt-static" cargo build --release --target x86_64-unknown-linux-gnu + + - name: Upload binary + uses: actions/upload-artifact@main + with: + name: lightswitchs + path: target/x86_64-unknown-linux-gnu/release/lightswitch \ No newline at end of file diff --git a/build.rs b/build.rs index a43402d..c04a673 100644 --- a/build.rs +++ b/build.rs @@ -11,12 +11,8 @@ const PROFILER_BPF_SOURCE: &str = "./src/bpf/profiler.bpf.c"; const PROFILER_SKELETON: &str = "./src/bpf/profiler_skel.rs"; fn main() { - // This is necessary but not sure why, this should be passed elsewhere - println!("cargo:rustc-link-lib=zstd"); - // Inform cargo of when to re build println!("cargo:rerun-if-changed={PROFILER_BPF_HEADER}"); - println!("cargo:rerun-if-changed={PROFILER_BPF_HEADER}"); println!("cargo:rerun-if-changed={PROFILER_BPF_SOURCE}"); let bindings = bindgen::Builder::default() diff --git a/flake.nix b/flake.nix index 4fd2f5d..0561136 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,9 @@ pkgs = import nixpkgs { inherit system overlays; }; - zstd-static = (pkgs.zstd.override { static = true; }); + elfutils-without-zstd = pkgs.elfutils.overrideAttrs (attrs: { + configureFlags = attrs.configureFlags ++ [ "--without-zstd" ]; + }); in with pkgs; { @@ -42,18 +44,17 @@ # Native deps glibc glibc.static - elfutils + elfutils-without-zstd zlib.static zlib.dev openssl - zstd-static # Other tools cargo-edit # ocamlPackages.magic-trace ]; LIBCLANG_PATH = lib.makeLibraryPath [ llvmPackages_16.libclang ]; - LD_LIBRARY_PATH = lib.makeLibraryPath [ zstd-static zlib.static elfutils ]; + LD_LIBRARY_PATH = lib.makeLibraryPath [ zlib.static elfutils-without-zstd ]; }; } );