Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoC: complete XGo based build solution with HSM support #277

Closed
wants to merge 1 commit into from

Conversation

vkhoroz
Copy link
Member

@vkhoroz vkhoroz commented Sep 26, 2023

This PoC utilizes a Bash script which allowed me to focus on the implementation rather than the fancy Makefile syntax.
It is a full solution in one commit, so that you can easily compare it to the #269.

Signed-off-by: Volodymyr Khoroz [email protected]

@vkhoroz
Copy link
Member Author

vkhoroz commented Sep 26, 2023

A way to go forward is this:

  • Andre will verify that it works well with [WIP] feat: add HSM support to Golang PKI code #270 when enabling on Windows/Linux/maybe Darwin (whichever platforms available).
  • Once/if it works well - Andre disables the HSM support and merges that PR.
  • Then I work on this PR to break down into individual nice commits, and add the missing pieces for the CI.
  • When all pieces are captured into a nice puzzle - we do a final review of the clean PR.
  • Before the merge we need to split the regression testing effort based on our platforms and time availability.

@mike-sul
Copy link
Contributor

mike-sul commented Sep 27, 2023

Maybe we should just extend the existing Makefile with new targets(s) that invoke the script, and the script just builds the non-static HSM targets.
I mean leave Makefile for the existing/current target building as it is now, just extend it with the HSM specific one.

@mike-sul
Copy link
Contributor

When I run make fioctl-linux-amd64 I get

CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64 \
	go build -buildmode=pie -ldflags "-X=github.com/foundriesio/fioctl/subcommands/version.Commit=v0.34-2-g8a8948c" -o bin/fioctl-linux-amd64 main.go

With the new build system when I run make fioctl-linux-amd64 I get

Bulding for linux-amd64
INFO: Starting xgo/dev
flag provided but not defined: -image
Usage of /work/go/bin/xgo:
  -branch string
    	Version control branch to build
  -buildmode string
    	Indicates which kind of object file to build (default "default")
  -buildvcs string
    	Whether to stamp binaries with version control information
  -deps string
    	CGO dependencies (configure/make based archives)
  -depsargs string
    	CGO dependency configure arguments
  -dest string
    	Destination folder to put binaries in (empty = current)
  -docker-image string
    	Use custom docker image instead of official distribution
  -docker-repo string
    	Use custom docker repo instead of official distribution
  -go string
    	Go release to use for cross compilation (default "latest")
  -goproxy string
    	Set a Global Proxy for Go Modules
  -ldflags string
    	Arguments to pass on each go tool link invocation
  -out string
    	Prefix to use for output naming (empty = package name)
  -pkg string
    	Sub-package to build if not root import
  -race
    	Enable data race detection (supported only on amd64)
  -remote string
    	Version control remote repository to build
  -tags string
    	List of build tags to consider satisfied during the build
  -targets string
    	Comma separated targets to build for (default "*/*")
  -trimpath
    	Remove all file system paths from the resulting executable
  -v	Print the names of packages as they are compiled
  -x	Print the command as executing the builds
make: *** [Makefile:39: fioctl-linux-amd64] Error 2

@vkhoroz
Copy link
Member Author

vkhoroz commented Sep 27, 2023

@mike-sul probably you tried to build using #269 earlier.
In this PR I used a different flavor of xgo which allows to better customize the docker arguments.

Please, run make install-builder and retry.

@mike-sul
Copy link
Contributor

@mike-sul probably you tried to build using #269 earlier.
In this PR I used a different flavor of xgo which allows to better customize the docker arguments.

On branch vkhoroz-xgo-toolchain-with-bash
Your branch is up to date with 'origin/vkhoroz-xgo-toolchain-with-bash'.

@vkhoroz
Copy link
Member Author

vkhoroz commented Sep 28, 2023

Tabling this as we agreed to implement the HSM support in a way which does not require cross-compilation using CGo: #278

If we do need the CGo based compilation, we might revisit this.

@vkhoroz vkhoroz closed this Sep 28, 2023
@vkhoroz vkhoroz deleted the vkhoroz-xgo-toolchain-with-bash branch September 28, 2023 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants