-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Will
committed
Aug 28, 2023
0 parents
commit 181719f
Showing
8 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu -x | ||
|
||
RELEASE=https://github.com/kentik/musl-xcc/releases/download/$VERSION/ | ||
ARCHIVE=xcc-$TARGET.tar.gz | ||
|
||
curl -sL $RELEASE/$ARCHIVE | tar -xzf - -C / | ||
|
||
echo "CC=/opt/xcc/bin/$TARGET-gcc" >> $GITHUB_ENV | ||
echo "CXX=/opt/xcc/bin/$TARGET-g++" >> $GITHUB_ENV | ||
echo "AR=/opt/xcc/bin/$TARGET-ar" >> $GITHUB_ENV | ||
echo "LD=/opt/xcc/bin/$TARGET-ld" >> $GITHUB_ENV | ||
echo "RANLIB=/opt/xcc/bin/$TARGET-ranlib" >> $GITHUB_ENV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: package | ||
|
||
inputs: | ||
target: | ||
required: true | ||
version: | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- run: $GITHUB_ACTION_PATH/action.sh | ||
shell: bash | ||
env: | ||
TARGET: ${{ inputs.target }} | ||
VERSION: ${{ inputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: "*" | ||
|
||
jobs: | ||
golang: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.17.13" | ||
- run: patch -d go -p1 < go-runtime.patch | ||
- run: bash ./make.bash | ||
working-directory: go/src | ||
- run: tar -czf golang.tar.gz go | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: golang.tar.gz | ||
path: golang.tar.gz | ||
|
||
build: | ||
strategy: | ||
matrix: | ||
include: | ||
- target: aarch64-linux-musl | ||
goarch: arm64 | ||
goos: linux | ||
- target: armv7-linux-musleabihf | ||
goarch: arm | ||
goos: linux | ||
- target: x86_64-linux-musl | ||
goarch: amd64 | ||
goos: linux | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
submodules: true | ||
- uses: ./.github/actions/setup-xcc | ||
with: | ||
target: ${{ matrix.target }} | ||
version: f9cb5162 | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: golang.tar.gz | ||
- run: tar -xzf golang.tar.gz -C /opt | ||
- run: | | ||
ls -lR /opt/go | ||
echo "PATH=/opt/go/bin:$PATH" >> $GITHUB_ENV | ||
- run: go env | ||
- run: patch -d libkflow -p1 < libkflow.patch | ||
- run: make -C libkflow | ||
env: | ||
GOARCH: ${{ matrix.goarch }} | ||
GOOS: ${{ matrix.goos }} | ||
GOFLAGS: -mod=vendor | ||
CGO_ENABLED: 1 | ||
- run: mv libkflow/out/$OUTPUT/libkflow.a libkflow-$TARGET.a | ||
env: | ||
TARGET: ${{ matrix.target }} | ||
OUTPUT: ${{ matrix.goos }}-${{ matrix.goarch }} | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: libkflow-${{ matrix.target }}.a | ||
path: libkflow-${{ matrix.target }}.a | ||
needs: golang | ||
|
||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
path: artifacts | ||
- uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const version = context.sha.substring(0, 8); | ||
github.rest.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `refs/tags/${version}`, | ||
sha: context.sha | ||
}); | ||
core.setOutput('version', version); | ||
id: create-tag | ||
- uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: ${{ steps.create-tag.outputs.version }} | ||
files: artifacts/**/* | ||
needs: build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "go"] | ||
path = go | ||
url = https://github.com/golang/go | ||
[submodule "libkflow"] | ||
path = libkflow | ||
url = https://github.com/kentik/libkflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go | ||
index a04c995c00..f8017a2983 100644 | ||
--- a/src/runtime/os_linux.go | ||
+++ b/src/runtime/os_linux.go | ||
@@ -212,7 +212,7 @@ func sysargs(argc int32, argv **byte) { | ||
|
||
// now argv+n is auxv | ||
auxv := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*sys.PtrSize)) | ||
- if sysauxv(auxv[:]) != 0 { | ||
+ if argv != nil && sysauxv(auxv[:]) != 0 { | ||
return | ||
} | ||
// In some situations we don't get a loader-provided | ||
diff --git a/src/runtime/runtime1.go b/src/runtime/runtime1.go | ||
index a0769bbb67..ae481808c5 100644 | ||
--- a/src/runtime/runtime1.go | ||
+++ b/src/runtime/runtime1.go | ||
@@ -54,10 +54,17 @@ var ( | ||
// nosplit for use in linux startup sysargs | ||
//go:nosplit | ||
func argv_index(argv **byte, i int32) *byte { | ||
+ if argv == nil { | ||
+ return nil | ||
+ } | ||
return *(**byte)(add(unsafe.Pointer(argv), uintptr(i)*sys.PtrSize)) | ||
} | ||
|
||
func args(c int32, v **byte) { | ||
+ if c > 65535 || c < 0 { | ||
+ c = 0 | ||
+ v = nil | ||
+ } | ||
argc = c | ||
argv = v | ||
sysargs(c, v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/cmd/libkflow/main.go b/cmd/libkflow/main.go | ||
index 02d0649..b1ad71a 100644 | ||
--- a/cmd/libkflow/main.go | ||
+++ b/cmd/libkflow/main.go | ||
@@ -198,7 +198,7 @@ func kflowSendDNS(q KflowDomainQuery, a *KflowDomainAnswer, n C.size_t) C.int { | ||
} | ||
|
||
answers := make([]api.DNSResourceRecord, n) | ||
- for i, a := range (*[1 << 30]KflowDomainAnswer)(unsafe.Pointer(a))[:n:n] { | ||
+ for i, a := range (*[1 << 16]KflowDomainAnswer)(unsafe.Pointer(a))[:n:n] { | ||
answers[i] = api.DNSResourceRecord{ | ||
IP: net.IP(bytes(a.ip)), | ||
TTL: uint32(a.ttl), |