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

ci: Further tweaks to building NSS #1712

Merged
merged 29 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
af90bd0
ci: Further tweaks to building NSS
larseggert Mar 6, 2024
ea8f0a1
Caching the nss build directory does nothing other than increase the …
larseggert Mar 6, 2024
eaa5be6
Enable NSS debug symbols also for optimized build
larseggert Mar 6, 2024
ac9c04c
-e
larseggert Mar 6, 2024
2b468ac
CFLAGS
larseggert Mar 6, 2024
0b30d18
Don't set `-ggdb3` on Windows
larseggert Mar 6, 2024
93ab9c3
Turn off verbose build
larseggert Mar 6, 2024
37468a5
Debug why there is a debug build for NSS
larseggert Mar 6, 2024
2e726cd
Merge branch 'main' into ci-nss-v2
larseggert Mar 6, 2024
cbc4f89
Randomize port for transfer test. Build NSS based on cargo build prof…
larseggert Mar 6, 2024
60751b7
Assign PORT in bash
larseggert Mar 6, 2024
a88a7eb
Debug Windows
larseggert Mar 6, 2024
7689242
Not like that
larseggert Mar 6, 2024
01e7f19
Debug
larseggert Mar 6, 2024
d68724f
Again
larseggert Mar 6, 2024
ca71c4d
Try fp and NSS_TARGET
larseggert Mar 6, 2024
8568a57
Checkout with action
larseggert Mar 6, 2024
3af01a0
Always also build static libs
larseggert Mar 6, 2024
9610f0d
--static
larseggert Mar 6, 2024
0daa272
More
larseggert Mar 6, 2024
b6a1fad
Merge branch 'main' into ci-nss-v2
larseggert Mar 7, 2024
8e6a1b5
More
larseggert Mar 7, 2024
1b4eb3e
Release build
larseggert Mar 7, 2024
e013d37
export
larseggert Mar 7, 2024
ae92b90
Try
larseggert Mar 7, 2024
55a8ecc
No release build on Windows
larseggert Mar 7, 2024
799b7d5
No dynamic link on Windows
larseggert Mar 7, 2024
e1fc504
Doh
larseggert Mar 7, 2024
8f1e236
Finalize
larseggert Mar 7, 2024
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
50 changes: 42 additions & 8 deletions .github/actions/nss/action.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,53 @@
name: Fetch and build NSS

inputs:
type:
description: 'Whether to do a debug or release build of NSS'
required: true
default: 'Debug'

# This step might be removed if the distro included a recent enough
# version of NSS. Ubuntu 20.04 only has 3.49, which is far too old.
# (neqo-crypto/build.rs would also need to query pkg-config to get the
# right build flags rather than building NSS.)
#
# Also see https://github.com/mozilla/neqo/issues/1711

runs:
using: composite
steps:
- name: Fetch and build NSS
- name: Checkout NSPR
uses: actions/checkout@v4
with:
repository: 'nss-dev/nspr'
path: ${{ github.workspace }}/nspr

- name: Checkout NSS
uses: actions/checkout@v4
with:
repository: 'nss-dev/nss'
path: ${{ github.workspace }}/nss

- name: Build
shell: bash
run: |
git clone --depth=1 https://github.com/nss-dev/nspr "$NSPR_DIR"
git clone --depth=1 https://github.com/nss-dev/nss "$NSS_DIR"
$NSS_DIR/build.sh -g -Ddisable_tests=1 -o
# We want to do an optimized build for accurate CPU profiling, but
# we also want debug symbols for that, which the normal optimized NSS
# build process doesn't provide.
[ "${{ runner.os }}" != "Windows" ] && export CFLAGS=-ggdb3
if [ "${{ inputs.type }}" != "Debug" ]; then
export OPT="-o"
export NSS_TARGET=Release
else
export NSS_TARGET=Debug
fi
$NSS_DIR/build.sh -g -Ddisable_tests=1 $OPT --static
echo "NSS_TARGET=$NSS_TARGET" >> "$GITHUB_ENV"
export NSS_OUT="$NSS_DIR/../dist/$NSS_TARGET"
echo "LD_LIBRARY_PATH=$NSS_OUT/lib" >> "$GITHUB_ENV"
echo "DYLD_FALLBACK_LIBRARY_PATH=$NSS_OUT/lib" >> "$GITHUB_ENV"
echo "$NSS_OUT/lib" >> "$GITHUB_PATH"
echo "NSS_DIR=$NSS_DIR" >> "$GITHUB_ENV"
echo "NSPR_DIR=$NSPR_DIR" >> "$GITHUB_ENV"
echo "LD_LIBRARY_PATH=$NSS_DIR/../dist/Release/lib" >> "$GITHUB_ENV"
echo "DYLD_FALLBACK_LIBRARY_PATH=$NSS_DIR/../dist/Release/lib" >> "$GITHUB_ENV"
echo "$NSS_DIR/../dist/Release/lib" >> "$GITHUB_PATH"
env:
NSS_DIR: ${{ github.workspace }}/nss
NSPR_DIR: ${{ github.workspace }}/nspr
2 changes: 0 additions & 2 deletions .github/actions/rust/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Install Rust
description: Install Rust and sccache

inputs:
version:
Expand Down Expand Up @@ -38,4 +37,3 @@ runs:
uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
cache-directories: "${{ github.workspace }}/dist"
8 changes: 4 additions & 4 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
TOOLCHAIN: nightly
RUSTFLAGS: -C link-arg=-fuse-ld=lld -C link-arg=-Wl,--no-rosegment
PERF_CMD: record -o perf.data -F997 --call-graph lbr -g
RUSTFLAGS: -C link-arg=-fuse-ld=lld -C link-arg=-Wl,--no-rosegment, -Cforce-frame-pointers=yes
PERF_CMD: record -o perf.data -F997 --call-graph fp -g

jobs:
bench:
Expand All @@ -34,6 +34,8 @@ jobs:

- name: Fetch and build NSS and NSPR
uses: ./.github/actions/nss
with:
type: Release

- name: Build
run: |
Expand Down Expand Up @@ -81,8 +83,6 @@ jobs:
taskset -c 0 nice -n -20 \
cargo +$TOOLCHAIN flamegraph -v -c "$PERF_CMD" \
--bin neqo-server -- --db ../test-fixture/db $HOST:4433 || true; } &
# Give the server time to start.
sleep 3
mkdir client; \
cd client; \
time taskset -c 1 nice -n -20 \
Expand Down
15 changes: 6 additions & 9 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
type: release
env:
BUILD_TYPE: ${{ matrix.type == 'release' && '--release' || '' }}
BUILD_DIR: ${{ matrix.type == 'release' && 'release' || 'debug' }}
runs-on: ${{ matrix.os }}
defaults:
run:
Expand Down Expand Up @@ -98,10 +99,6 @@ jobs:
# See https://github.com/ilammy/msvc-dev-cmd#name-conflicts-with-shell-bash
rm /usr/bin/link.exe

# This step might be removed if the distro included a recent enough
# version of NSS. Ubuntu 20.04 only has 3.49, which is far too old.
# (neqo-crypto/build.rs would also need to query pkg-config to get the
# right build flags rather than building NSS.)
- name: Fetch and build NSS and NSPR
uses: ./.github/actions/nss

Expand All @@ -111,16 +108,16 @@ jobs:
- name: Run tests and determine coverage
run: |
cargo +${{ matrix.rust-toolchain }} llvm-cov nextest $BUILD_TYPE --all-targets --features ci --no-fail-fast --lcov --output-path lcov.info
cargo +${{ matrix.rust-toolchain }} bench --features bench --no-run
find $NSS_DIR/../dist
cargo +${{ matrix.rust-toolchain }} bench --features bench --no-run || find $NSS_DIR/../dist


- name: Run client/server transfer
run: |
cargo +${{ matrix.rust-toolchain }} build $BUILD_TYPE --bin neqo-client --bin neqo-server
cargo +${{ matrix.rust-toolchain }} run $BUILD_TYPE --bin neqo-server -- $HOST:4433 &
target/$BUILD_DIR/neqo-server $HOST:4433 &
PID=$!
# Give the server time to start.
sleep 3
cargo +${{ matrix.rust-toolchain }} run $BUILD_TYPE --bin neqo-client -- --output-dir . https://$HOST:4433/$SIZE
target/$BUILD_DIR/neqo-client --output-dir . https://$HOST:4433/$SIZE
kill $PID
[ "$(wc -c <"$SIZE")" -eq "$SIZE" ] || exit 1
env:
Expand Down
12 changes: 6 additions & 6 deletions neqo-crypto/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ struct Bindings {
}

fn is_debug() -> bool {
env::var("DEBUG")
.map(|d| d.parse::<bool>().unwrap_or(false))
.unwrap_or(false)
// Check the build profile and not whether debug symbols are enabled (i.e.,
// `env::var("DEBUG")`), because we enable those for benchmarking/profiling and still want
// to build NSS in release mode.
env::var("PROFILE").unwrap_or_default() == "debug"
}

// bindgen needs access to libclang.
Expand Down Expand Up @@ -147,10 +148,9 @@ fn build_nss(dir: PathBuf) {
let mut build_nss = vec![
String::from("./build.sh"),
String::from("-Ddisable_tests=1"),
String::from("--static"),
];
if is_debug() {
build_nss.push(String::from("--static"));
} else {
if !is_debug() {
build_nss.push(String::from("-o"));
}
if let Ok(d) = env::var("NSS_JOBS") {
Expand Down
Loading