Skip to content

Commit

Permalink
Add support for using PGO flag
Browse files Browse the repository at this point in the history
  • Loading branch information
der-eismann committed Feb 3, 2023
1 parent d30e78d commit 61467ca
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '1.19'
go-version: '1.20'
- name: Checkout code
uses: actions/checkout@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions cmd/buildutil/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ type TargetInfo struct {
Outfile string
System SystemInfo
CGO bool
PGO string
}

func CollectBuildInformation(ctx context.Context, p BuildParameters) (BuildInfo, error) {
Expand Down Expand Up @@ -311,6 +312,7 @@ func CollectBuildInformation(ctx context.Context, p BuildParameters) (BuildInfo,
Name: path.Base(pkg.PkgPath),
System: targetSystem,
CGO: p.CGO,
PGO: p.PGO,
}

if pkg.PkgPath == info.Go.Module {
Expand Down
5 changes: 5 additions & 0 deletions cmd/buildutil/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type BuildParameters struct {
GoCommand string

CGO bool
PGO string
}

type Runner struct {
Expand Down Expand Up @@ -81,6 +82,9 @@ func (r *Runner) Bind(cmd *cobra.Command) error {
cmd.PersistentFlags().BoolVar(
&r.Parameters.CGO, "cgo", false,
"Enable CGO.")
cmd.PersistentFlags().StringVar(
&r.Parameters.PGO, "pgo", "off",
"Sets input for PGO option.")
cmd.PersistentFlags().StringVar(
&r.Parameters.GoCommand, "go-command", "go",
"Which Go command to use.")
Expand Down Expand Up @@ -214,6 +218,7 @@ func (r *Runner) RunBuild(ctx context.Context, cmd *cobra.Command, args []string
call(ctx, r.Parameters.GoCommand, "build",
"-o", r.dist(target.Outfile),
"-ldflags", "-s -w "+strings.Join(ldFlags, " "),
"-pgo", target.PGO,
target.Package)

r.Inst.ReadSize(target.Outfile)
Expand Down
2 changes: 1 addition & 1 deletion examples/full/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine as builder
FROM golang:1.20-alpine as builder

RUN apk add --no-cache git openssl

Expand Down
2 changes: 1 addition & 1 deletion examples/full/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/rebuy-de/rebuy-go-sdk/v4/examples/full

go 1.19
go 1.20

replace github.com/rebuy-de/rebuy-go-sdk/v4 => ../..

Expand Down
2 changes: 1 addition & 1 deletion examples/minimal/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine as builder
FROM golang:1.20-alpine as builder

RUN apk add --no-cache git openssl

Expand Down
2 changes: 1 addition & 1 deletion examples/minimal/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/rebuy-de/rebuy-go-sdk/v4/examples/minimal

go 1.19
go 1.20

replace github.com/rebuy-de/rebuy-go-sdk/v4 => ../..

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/rebuy-de/rebuy-go-sdk/v4

go 1.19
go 1.20

require (
github.com/afiskon/promtail-client v0.0.0-20190305142237-506f3f921e9c
Expand Down

0 comments on commit 61467ca

Please sign in to comment.