Skip to content

Conversation

@dorzel
Copy link
Member

@dorzel dorzel commented Nov 3, 2025

Description

I noticed when cross-building for ppc64le that make was erroring while trying to pass GO_BUILD_FLAGS as positional arguments. Cross-builds were also failing with CGO due to unknown ASM instructions while translating the assembly.

Also set GO_BUILD_BINDIR in the build step so one can run cross-builds first, without having already run make build. (It was assuming v1/bin/oc-mirror existed regardless of the value of GO_BUILD_BINDIR).

Github / Jira issue:

None

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code Improvements (Refactoring, Performance, CI upgrades, etc)
  • Internal repo assets (diagrams / docs on github repo)
  • This change requires a documentation update on openshift docs

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

make clean
make tidy
make cross-build
make build

Expected Outcome

Please describe the outcome expected from the tests.

cross-builds properly build and populate /bin without errors.

@openshift-ci openshift-ci bot requested review from aguidirh and r4f4 November 3, 2025 18:02
Copy link
Contributor

@aguidirh aguidirh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dorzel,

Thanks for the PR. I tested make cross-build and it worked fine as expected.

I added only one concern I have to the PR.

Makefile Outdated

cross-build-linux-amd64:
+@GOOS=linux GOARCH=amd64 $(MAKE) "$(GO_BUILD_FLAGS)" --no-print-directory build GO_BUILD_BINDIR=$(GO_BUILD_BINDIR)/linux-amd64
+@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(MAKE) --no-print-directory build GO_BUILD_BINDIR=$(GO_BUILD_BINDIR)/linux-amd64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dorzel,

My only concern about disabling CGO is the FIPS.

For RHEL9 we build a FIPS compliance binary which requires CGO_ENABLED=1.

What do you think about it @r4f4?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aguidirh Ah I see, if it is an issue I can try to modify this to work with CGO enabled as well.

@dorzel dorzel changed the title Fixes for cross-build errors CLID-476: Fixes for cross-build errors Nov 4, 2025
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Nov 4, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Nov 4, 2025

@dorzel: This pull request references CLID-476 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set.

In response to this:

Description

I noticed when cross-building for ppc64le that make was erroring while trying to pass GO_BUILD_FLAGS as positional arguments. Cross-builds were also failing with CGO due to unknown ASM instructions while translating the assembly.

Also set GO_BUILD_BINDIR in the build step so one can run cross-builds first, without having already run make build. (It was assuming v1/bin/oc-mirror existed regardless of the value of GO_BUILD_BINDIR).

Github / Jira issue:

None

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code Improvements (Refactoring, Performance, CI upgrades, etc)
  • Internal repo assets (diagrams / docs on github repo)
  • This change requires a documentation update on openshift docs

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

make clean
make tidy
make cross-build
make build

Expected Outcome

Please describe the outcome expected from the tests.

cross-builds properly build and populate /bin without errors.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@dorzel
Copy link
Member Author

dorzel commented Nov 4, 2025

/jira refresh

@openshift-ci-robot
Copy link

openshift-ci-robot commented Nov 4, 2025

@dorzel: This pull request references CLID-476 which is a valid jira issue.

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@dorzel
Copy link
Member Author

dorzel commented Nov 17, 2025

Ok, I think the latest changes solve it nicely. The conditional assignment allows for:

  • preserving all default CGO behavior (due to not exporting the variable)
  • defaulting cross-build targets to CGO_ENABLED=0 (makefile is not "broken" by default for standard users)
  • overrides for CGO_ENABLED passed via CLI are favored for all targets

@dorzel
Copy link
Member Author

dorzel commented Nov 17, 2025

/retest

@dorzel
Copy link
Member Author

dorzel commented Nov 17, 2025

/test v1-e2e

@dorzel
Copy link
Member Author

dorzel commented Nov 18, 2025

/retest

@openshift-ci
Copy link

openshift-ci bot commented Nov 18, 2025

@dorzel: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Copy link
Contributor

@aguidirh aguidirh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dorzel for taking into account the suggestions.

I ran some tests and it worked as expected on my side.

I will approve and let LGTM to @r4f4.

GO_BUILD_PACKAGES := ./cmd/oc-mirror
GO_PACKAGE = github.com/openshift/oc-mirror/v2

# Default to CGO_ENABLED=0 for cross-builds, but allow override from command line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it would be nice to add in the comment the reason why it is needed to disable CGO for cross-builds.

@openshift-ci
Copy link

openshift-ci bot commented Nov 20, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aguidirh, dorzel

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants