Skip to content

Commit b85d691

Browse files
committed
Use FreeBSD VM for native builds instead of cross-compilation
- Removed freebsd-x64 from cross-compilation matrix - Added dedicated build-freebsd job using vmactions/freebsd-vm - Builds natively on actual FreeBSD using pkg and native toolchain - Updated test-freebsd workflow to use VM as well - Avoids all cross-compilation sysroot/libpcap issues
1 parent 972d4de commit b85d691

3 files changed

Lines changed: 64 additions & 40 deletions

File tree

.github/workflows/release.yml

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939
- linux-aarch64-gnu
4040
- linux-armv7-gnueabihf
4141
- linux-x64-gnu
42-
- freebsd-x64
4342
- macos-aarch64
4443
- macos-x64
4544
- windows-x64-msvc
@@ -55,9 +54,6 @@ jobs:
5554
cargo: cross
5655
- build: linux-x64-gnu
5756
target: x86_64-unknown-linux-gnu
58-
- build: freebsd-x64
59-
target: x86_64-unknown-freebsd
60-
cargo: cross
6157
- build: macos-aarch64
6258
os: macos-14
6359
target: aarch64-apple-darwin
@@ -145,10 +141,51 @@ jobs:
145141
path: ${{ env.ASSET }}
146142
if-no-files-found: error
147143

144+
build-freebsd:
145+
name: build-freebsd
146+
runs-on: ubuntu-latest
147+
steps:
148+
- name: Checkout repository
149+
uses: actions/checkout@v6
150+
151+
- name: Build on FreeBSD
152+
uses: vmactions/freebsd-vm@v1
153+
with:
154+
usesh: true
155+
prepare: |
156+
pkg install -y curl libpcap rust
157+
run: |
158+
# Build release binary (without eBPF - not available on FreeBSD)
159+
cargo build --verbose --release --no-default-features
160+
161+
# Create release archive
162+
mkdir -p "rustnet-${{ github.ref_name }}-x86_64-unknown-freebsd"
163+
cp target/release/rustnet "rustnet-${{ github.ref_name }}-x86_64-unknown-freebsd/"
164+
165+
# Copy assets if available
166+
if [ -d "assets" ]; then
167+
mkdir -p "rustnet-${{ github.ref_name }}-x86_64-unknown-freebsd/assets"
168+
cp -r assets/* "rustnet-${{ github.ref_name }}-x86_64-unknown-freebsd/assets/" || true
169+
fi
170+
171+
# Copy documentation
172+
cp README.md "rustnet-${{ github.ref_name }}-x86_64-unknown-freebsd/" || true
173+
cp LICENSE "rustnet-${{ github.ref_name }}-x86_64-unknown-freebsd/" || true
174+
175+
# Create tarball
176+
tar czf "rustnet-${{ github.ref_name }}-x86_64-unknown-freebsd.tar.gz" "rustnet-${{ github.ref_name }}-x86_64-unknown-freebsd"
177+
178+
- name: Upload FreeBSD artifact
179+
uses: actions/upload-artifact@v5
180+
with:
181+
name: build-x86_64-unknown-freebsd
182+
path: rustnet-${{ github.ref_name }}-x86_64-unknown-freebsd.tar.gz
183+
if-no-files-found: error
184+
148185
create-release:
149186
name: create-release
150187
runs-on: ubuntu-latest
151-
needs: build-release
188+
needs: [build-release, build-freebsd]
152189
steps:
153190
- name: Checkout repository
154191
uses: actions/checkout@v6

.github/workflows/test-freebsd.yml

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,34 @@ env:
1515
jobs:
1616
test-freebsd-build:
1717
name: Test FreeBSD x64 Build
18-
runs-on: ubuntu-22.04
18+
runs-on: ubuntu-latest
1919

2020
steps:
2121
- name: Checkout repository
2222
uses: actions/checkout@v6
2323

24-
- name: Install Linux dependencies
25-
run: |
26-
sudo apt-get update -y
27-
sudo apt-get install -y libpcap-dev pkg-config
28-
29-
- name: Install Rust
30-
uses: dtolnay/rust-toolchain@stable
24+
- name: Build and test on FreeBSD
25+
uses: vmactions/freebsd-vm@v1
3126
with:
32-
toolchain: stable
33-
targets: x86_64-unknown-freebsd
34-
35-
- name: Install cross
36-
run: cargo install cross@0.2.5
37-
38-
- name: Build for FreeBSD (without eBPF)
39-
env:
40-
RUSTFLAGS: "-C strip=symbols"
41-
run: |
42-
echo "Building for FreeBSD target without default features (no eBPF)"
43-
cross build --verbose --release --target x86_64-unknown-freebsd --no-default-features
44-
45-
- name: Verify binary was created
46-
run: |
47-
if [ -f "target/x86_64-unknown-freebsd/release/rustnet" ]; then
48-
echo "✅ FreeBSD binary successfully built"
49-
ls -lh target/x86_64-unknown-freebsd/release/rustnet
50-
else
51-
echo "❌ FreeBSD binary not found"
52-
exit 1
53-
fi
27+
usesh: true
28+
prepare: |
29+
pkg install -y curl libpcap rust
30+
run: |
31+
echo "Building for FreeBSD without default features (no eBPF)"
32+
cargo build --verbose --release --no-default-features
33+
34+
echo "Verifying binary was created"
35+
if [ -f "target/release/rustnet" ]; then
36+
echo "✅ FreeBSD binary successfully built"
37+
ls -lh target/release/rustnet
38+
else
39+
echo "❌ FreeBSD binary not found"
40+
exit 1
41+
fi
5442
5543
- name: Upload binary as artifact
5644
uses: actions/upload-artifact@v5
5745
with:
5846
name: rustnet-freebsd-x64
59-
path: target/x86_64-unknown-freebsd/release/rustnet
47+
path: target/release/rustnet
6048
if-no-files-found: error

Cross.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ pre-build = [
1515
]
1616

1717
[target.x86_64-unknown-freebsd]
18-
pre-build = [
19-
# FreeBSD uses pkg as package manager
20-
"pkg install -y libpcap",
21-
]
18+
# FreeBSD cross-compilation uses a Linux container with FreeBSD sysroot
19+
# The sysroot should already contain libpcap
20+
# No pre-build steps needed as we can't run FreeBSD package manager in Linux container
2221

0 commit comments

Comments
 (0)