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

feat(makefile): add CC switch on GOARCH #986

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

daveoy
Copy link

@daveoy daveoy commented Nov 14, 2024

This PR adds an ifdef to set the CC variable when GOARCH is arm64 and not default.

With the current Makefile as written, GOARCH=arm64 make build-binaries fails if building on amd64 systems (or in amd64 containers)

»  GOARCH=arm64 make build-binaries
CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build \
	-o bin/node-problem-detector \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16' \
	-tags "journald " \
	./cmd/nodeproblemdetector
# runtime/cgo
gcc_arm64.S: Assembler messages:
gcc_arm64.S:30: Error: no such instruction: `stp x29,x30,[sp,'
gcc_arm64.S:34: Error: too many memory references for `mov'
gcc_arm64.S:36: Error: no such instruction: `stp x19,x20,[sp,'
gcc_arm64.S:39: Error: no such instruction: `stp x21,x22,[sp,'
gcc_arm64.S:42: Error: no such instruction: `stp x23,x24,[sp,'
gcc_arm64.S:45: Error: no such instruction: `stp x25,x26,[sp,'
gcc_arm64.S:48: Error: no such instruction: `stp x27,x28,[sp,'
gcc_arm64.S:52: Error: too many memory references for `mov'
gcc_arm64.S:53: Error: too many memory references for `mov'
gcc_arm64.S:54: Error: too many memory references for `mov'
gcc_arm64.S:56: Error: no such instruction: `blr x20'
gcc_arm64.S:57: Error: no such instruction: `blr x19'
gcc_arm64.S:59: Error: no such instruction: `ldp x27,x28,[sp,'
gcc_arm64.S:62: Error: no such instruction: `ldp x25,x26,[sp,'
gcc_arm64.S:65: Error: no such instruction: `ldp x23,x24,[sp,'
gcc_arm64.S:68: Error: no such instruction: `ldp x21,x22,[sp,'
gcc_arm64.S:71: Error: no such instruction: `ldp x19,x20,[sp,'
gcc_arm64.S:74: Error: no such instruction: `ldp x29,x30,[sp],'
make: *** [Makefile:195: bin/node-problem-detector] Error 1

with the Makefile in this PR:

»  GOARCH=arm64 make build-binaries
CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc go build \
	-o bin/node-problem-detector \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	./cmd/nodeproblemdetector
CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc go build \
	-o bin/health-checker \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	cmd/healthchecker/health_checker.go
cd test && \
CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc go build \
	-o bin/problem-maker \
	-tags "journald " \
	./e2e/problemmaker/problem_maker.go
CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc go build \
	-o bin/log-counter \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	cmd/logcounter/log_counter.go
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 \
  CC=x86_64-linux-gnu-gcc go build \
	-o output/linux_amd64/bin/node-problem-detector \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	./cmd/nodeproblemdetector
touch output/linux_amd64/bin/node-problem-detector
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 \
  CC=x86_64-linux-gnu-gcc go build \
	-o output/linux_amd64/bin/health-checker \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	./cmd/healthchecker
touch output/linux_amd64/bin/health-checker
cd test && \
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 \
  CC=x86_64-linux-gnu-gcc go build \
	-o ../output/linux_amd64/test/bin/problem-maker \
	-tags "journald " \
	./e2e/problemmaker
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 \
  CC=x86_64-linux-gnu-gcc go build \
	-o output/linux_amd64/bin/log-counter \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	./cmd/logcounter
touch output/linux_amd64/bin/log-counter
GOOS=linux GOARCH=arm64 CGO_ENABLED=1 \
  CC=aarch64-linux-gnu-gcc go build \
	-o output/linux_arm64/bin/node-problem-detector \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	./cmd/nodeproblemdetector
touch output/linux_arm64/bin/node-problem-detector
GOOS=linux GOARCH=arm64 CGO_ENABLED=1 \
  CC=aarch64-linux-gnu-gcc go build \
	-o output/linux_arm64/bin/health-checker \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	./cmd/healthchecker
touch output/linux_arm64/bin/health-checker
cd test && \
GOOS=linux GOARCH=arm64 CGO_ENABLED=1 \
  CC=aarch64-linux-gnu-gcc go build \
	-o ../output/linux_arm64/test/bin/problem-maker \
	-tags "journald " \
	./e2e/problemmaker
GOOS=linux GOARCH=arm64 CGO_ENABLED=1 \
  CC=aarch64-linux-gnu-gcc go build \
	-o output/linux_arm64/bin/log-counter \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	./cmd/logcounter
touch output/linux_arm64/bin/log-counter
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build \
	-o output/windows_amd64/bin/node-problem-detector.exe \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "" \
	./cmd/nodeproblemdetector
touch output/windows_amd64/bin/node-problem-detector.exe
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build \
	-o output/windows_amd64/bin/health-checker.exe \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "" \
	./cmd/healthchecker
touch output/windows_amd64/bin/health-checker.exe
cd test && \
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build \
	-o ../output/windows_amd64/test/bin/problem-maker.exe \
	-tags "" \
	./e2e/problemmaker

amd64 build / GOARCH not set (using defaults):

»  make build-binaries
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=x86_64-linux-gnu-gcc go build \
	-o bin/node-problem-detector \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	./cmd/nodeproblemdetector
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=x86_64-linux-gnu-gcc go build \
	-o bin/health-checker \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	cmd/healthchecker/health_checker.go
cd test && \
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=x86_64-linux-gnu-gcc go build \
	-o bin/problem-maker \
	-tags "journald " \
	./e2e/problemmaker/problem_maker.go
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=x86_64-linux-gnu-gcc go build \
	-o bin/log-counter \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	cmd/logcounter/log_counter.go
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 \
  CC=x86_64-linux-gnu-gcc go build \
	-o output/linux_amd64/bin/node-problem-detector \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	./cmd/nodeproblemdetector
touch output/linux_amd64/bin/node-problem-detector
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 \
  CC=x86_64-linux-gnu-gcc go build \
	-o output/linux_amd64/bin/health-checker \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	./cmd/healthchecker
touch output/linux_amd64/bin/health-checker
cd test && \
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 \
  CC=x86_64-linux-gnu-gcc go build \
	-o ../output/linux_amd64/test/bin/problem-maker \
	-tags "journald " \
	./e2e/problemmaker
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 \
  CC=x86_64-linux-gnu-gcc go build \
	-o output/linux_amd64/bin/log-counter \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	./cmd/logcounter
touch output/linux_amd64/bin/log-counter
GOOS=linux GOARCH=arm64 CGO_ENABLED=1 \
  CC=aarch64-linux-gnu-gcc go build \
	-o output/linux_arm64/bin/node-problem-detector \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	./cmd/nodeproblemdetector
touch output/linux_arm64/bin/node-problem-detector
GOOS=linux GOARCH=arm64 CGO_ENABLED=1 \
  CC=aarch64-linux-gnu-gcc go build \
	-o output/linux_arm64/bin/health-checker \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	./cmd/healthchecker
touch output/linux_arm64/bin/health-checker
cd test && \
GOOS=linux GOARCH=arm64 CGO_ENABLED=1 \
  CC=aarch64-linux-gnu-gcc go build \
	-o ../output/linux_arm64/test/bin/problem-maker \
	-tags "journald " \
	./e2e/problemmaker
GOOS=linux GOARCH=arm64 CGO_ENABLED=1 \
  CC=aarch64-linux-gnu-gcc go build \
	-o output/linux_arm64/bin/log-counter \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "journald " \
	./cmd/logcounter
touch output/linux_arm64/bin/log-counter
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build \
	-o output/windows_amd64/bin/node-problem-detector.exe \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "" \
	./cmd/nodeproblemdetector
touch output/windows_amd64/bin/node-problem-detector.exe
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build \
	-o output/windows_amd64/bin/health-checker.exe \
	-ldflags '-X k8s.io/node-problem-detector/pkg/version.version=v0.8.16-dirty' \
	-tags "" \
	./cmd/healthchecker
touch output/windows_amd64/bin/health-checker.exe
cd test && \
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build \
	-o ../output/windows_amd64/test/bin/problem-maker.exe \
	-tags "" \
	./e2e/problemmaker

👍

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 14, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @daveoy!

It looks like this is your first PR to kubernetes/node-problem-detector 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/node-problem-detector has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @daveoy. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 14, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: daveoy
Once this PR has been reviewed and has the lgtm label, please assign sjenning for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 14, 2024
@mmiranda96
Copy link
Contributor

Thanks for your PR!
/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants