Skip to content

Commit

Permalink
WIP: initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
Will committed Aug 28, 2023
0 parents commit 8c33e2b
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 0 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
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
(cd go/src && ./make.bash)
- uses: actions/upload-artifact@v3
with:
name: golang
path: go

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: actions/download-artifact@v3
with:
name: golang
path: /opt/
- run: |
ls -lR /opt
echo "PATH=/opt/go/bin:$PATH" >> $GITHUB_ENV
- run: go env
- run: make -C libkflow
env:
GOARCH: ${{ matrix.goarch }}
GOOS: ${{ matrix.goos }}
GOFLAGS: -mod=vendor
- uses: actions/upload-artifact@v3
with:
name: libkflow-${{ matrix.target }}.a
path: libkflow/libkflow.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
6 changes: 6 additions & 0 deletions .gitmodules
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
1 change: 1 addition & 0 deletions go
Submodule go added at 7dd10d
35 changes: 35 additions & 0 deletions go-runtime.patch
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)
1 change: 1 addition & 0 deletions libkflow
Submodule libkflow added at 0ed607

0 comments on commit 8c33e2b

Please sign in to comment.