Skip to content

Commit

Permalink
feat: Allow to include symbols in binaries during package (#1974)
Browse files Browse the repository at this point in the history
#### Summary

Without the symbols it's hard to validate we're generating FIPS
compliant binaries (see
cloudquery/cloudquery-issues#2586 and
https://github.com/cloudquery/cloudquery/pull/19676/files#diff-3613eb0da60aba72ff182962b6ae3a738e42369d8bed0407cba78ba7cc72f052R101).

---

Use the following steps to ensure your PR is ready to be reviewed

- [ ] Read the [contribution guidelines](../blob/main/CONTRIBUTING.md)
🧑‍🎓
- [ ] Run `go fmt` to format your code 🖊
- [ ] Lint your changes via `golangci-lint run` 🚨 (install golangci-lint
[here](https://golangci-lint.run/usage/install/#local-installation))
- [ ] Update or add tests 🧪
- [ ] Ensure the status checks below are successful ✅
  • Loading branch information
erezrokah authored Nov 22, 2024
1 parent 7076899 commit aa3b3e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 5 additions & 4 deletions plugin/plugin_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ const (
)

type BuildTarget struct {
OS string `json:"os"`
Arch string `json:"arch"`
CGO bool `json:"cgo"`
Env []string `json:"env"`
OS string `json:"os"`
Arch string `json:"arch"`
CGO bool `json:"cgo"`
Env []string `json:"env"`
IncludeSymbols bool `json:"include_symbols"`
}

func (t BuildTarget) EnvVariables() []string {
Expand Down
6 changes: 5 additions & 1 deletion serve/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ func (s *PluginServe) build(pluginDirectory string, target plugin.BuildTarget, d
if err != nil {
return nil, err
}
ldFlags := fmt.Sprintf("-s -w -X %[1]s/plugin.Version=%[2]s -X %[1]s/resources/plugin.Version=%[2]s", importPath, pluginVersion)
stripSymbols := "-s "
if target.IncludeSymbols {
stripSymbols = ""
}
ldFlags := fmt.Sprintf("%[1]s -w -X %[2]s/plugin.Version=%[3]s -X %[2]s/resources/plugin.Version=%[2]s", stripSymbols, importPath, pluginVersion)
args := []string{"build", "-o", pluginPath}
args = append(args, "-buildmode=exe")
args = append(args, "-ldflags", ldFlags)
Expand Down

0 comments on commit aa3b3e4

Please sign in to comment.