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

Add go ldflags using LDFLAGS at the time of compilation #265

Closed
wants to merge 1 commit into from

Conversation

bnrjee
Copy link

@bnrjee bnrjee commented Oct 16, 2020

What type of PR is this?
/kind bug

What this PR does / why we need it:
This PR allows adding ldflags while running make. We are trying build a binary without debug info. With this change we will be able to pass -s flag as an argument to Makefile.

Which issue(s) this PR fixes:

Fixes #264

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Add go ldflags using LDFLAGS at the time of compilation.

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 16, 2020
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Oct 16, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: bnrjee
To complete the pull request process, please assign saad-ali after the PR has been reviewed.
You can assign the PR to them by writing /assign @saad-ali in a comment when ready.

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 requested review from msau42 and pohly October 16, 2020 17:26
@k8s-ci-robot
Copy link
Contributor

Welcome @bnrjee!

It looks like this is your first PR to kubernetes-csi/external-attacher 🎉. 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-csi/external-attacher 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 @bnrjee. Thanks for your PR.

I'm waiting for a kubernetes-csi 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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 16, 2020
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Oct 16, 2020
@bnrjee
Copy link
Author

bnrjee commented Oct 16, 2020

Tests performed,
1>Made sure that the build is without debug info and repeatable.
2>Made sure that the default behavior has not been altered.

[root@ip-172-31-13-77 external-attacher]# make BUILD_PLATFORMS="linux amd64" LDFLAGS="-s -w -buildid='' -X main.version=`git describe --long --tags --match='v*' --dirty 2>/dev/null || git rev-list -n1 HEAD` -extldflags "-static"" 
./release-tools/verify-go-version.sh "go"
mkdir -p bin
echo 'linux amd64' | tr ';' '\n' | while read -r os arch suffix; do \
	if ! (set -x; CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build  -a -ldflags '-s -w -buildid='' -X main.version=v3.0.0-15-ge463682c -extldflags -static' -o "./bin/csi-attacher$suffix" ./cmd/csi-attacher); then \
		echo "Building csi-attacher for GOOS=$os GOARCH=$arch failed, see error(s) above."; \
		exit 1; \
	fi; \
done
+ CGO_ENABLED=0
+ GOOS=linux
+ GOARCH=amd64
+ go build -a -ldflags '-s -w -buildid= -X main.version=v3.0.0-15-ge463682c -extldflags -static' -o ./bin/csi-attacher ./cmd/csi-attacher
[root@ip-172-31-13-77 external-attacher]# file bin/csi-attacher 
bin/csi-attacher: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped
[root@ip-172-31-13-77 external-attacher]# sha256sum bin/csi-attacher 
4ebcbec9aa0e99deec70e0c8970ed505f373bcbe0bdecbbbf0d70eaf44b4a927  bin/csi-attacher
[root@ip-172-31-13-77 external-attacher]# make clean
rm -rf bin
[root@ip-172-31-13-77 external-attacher]# make BUILD_PLATFORMS="linux amd64" LDFLAGS="-s -w -buildid='' -X main.version=`git describe --long --tags --match='v*' --dirty 2>/dev/null || git rev-list -n1 HEAD` -extldflags "-static"" 
./release-tools/verify-go-version.sh "go"
mkdir -p bin
echo 'linux amd64' | tr ';' '\n' | while read -r os arch suffix; do \
	if ! (set -x; CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build  -a -ldflags '-s -w -buildid='' -X main.version=v3.0.0-15-ge463682c -extldflags -static' -o "./bin/csi-attacher$suffix" ./cmd/csi-attacher); then \
		echo "Building csi-attacher for GOOS=$os GOARCH=$arch failed, see error(s) above."; \
		exit 1; \
	fi; \
done
+ CGO_ENABLED=0
+ GOOS=linux
+ GOARCH=amd64
+ go build -a -ldflags '-s -w -buildid= -X main.version=v3.0.0-15-ge463682c -extldflags -static' -o ./bin/csi-attacher ./cmd/csi-attacher
[root@ip-172-31-13-77 external-attacher]# sha256sum bin/csi-attacher 
4ebcbec9aa0e99deec70e0c8970ed505f373bcbe0bdecbbbf0d70eaf44b4a927  bin/csi-attacher
[root@ip-172-31-13-77 external-attacher]# file bin/csi-attacher 
bin/csi-attacher: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped
[root@ip-172-31-13-77 external-attacher]# make clean
rm -rf bin
[root@ip-172-31-13-77 external-attacher]# make BUILD_PLATFORMS="linux amd64" 
./release-tools/verify-go-version.sh "go"
mkdir -p bin
echo 'linux amd64' | tr ';' '\n' | while read -r os arch suffix; do \
	if ! (set -x; CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build  -a -ldflags '-X main.version=v3.0.0-15-ge463682c -extldflags "-static" ' -o "./bin/csi-attacher$suffix" ./cmd/csi-attacher); then \
		echo "Building csi-attacher for GOOS=$os GOARCH=$arch failed, see error(s) above."; \
		exit 1; \
	fi; \
done
+ CGO_ENABLED=0
+ GOOS=linux
+ GOARCH=amd64
+ go build -a -ldflags '-X main.version=v3.0.0-15-ge463682c -extldflags "-static" ' -o ./bin/csi-attacher ./cmd/csi-attacher
[root@ip-172-31-13-77 external-attacher]# sha256sum bin/csi-attacher 
17802dd2b847967cb1b4224de370885a4d5f889088340c5c4de76d2badf5c56f  bin/csi-attacher
[root@ip-172-31-13-77 external-attacher]# file bin/csi-attacher 
bin/csi-attacher: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped
[root@ip-172-31-13-77 external-attacher]# 

release-tools/build.make Outdated Show resolved Hide resolved
release-tools/build.make Outdated Show resolved Hide resolved
@jsafrane
Copy link
Contributor

@bnrjee, please submit a PR against https://github.com/kubernetes-csi/csi-release-tools, content of release-tools/ is copied from there. And it will fix all other CSI repos too.

@bnrjee
Copy link
Author

bnrjee commented Oct 19, 2020

@bnrjee, please submit a PR against https://github.com/kubernetes-csi/csi-release-tools, content of release-tools/ is copied from there. And it will fix all other CSI repos too.

I have created this PR
kubernetes-csi/csi-release-tools#108

@bnrjee bnrjee closed this Oct 19, 2020
@bnrjee bnrjee reopened this Oct 19, 2020
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 27, 2020
@k8s-ci-robot
Copy link
Contributor

@bnrjee: PR needs rebase.

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/test-infra repository.

@pohly
Copy link
Contributor

pohly commented Oct 27, 2020

/close

Merged via csi-release-tools.

@k8s-ci-robot
Copy link
Contributor

@pohly: Closed this PR.

In response to this:

/close

Merged via csi-release-tools.

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/test-infra repository.

avorima added a commit to avorima/external-attacher that referenced this pull request Dec 5, 2024
Commit summary:
Squashed 'release-tools/' changes from 227577e0..734c2b95

[734c2b95](kubernetes-csi/csi-release-tools@734c2b95) Merge [pull request kubernetes-csi#265](kubernetes-csi/csi-release-tools#265) from Rakshith-R/consider-main-branch
[f95c855b](kubernetes-csi/csi-release-tools@f95c855b) Merge [pull request kubernetes-csi#262](kubernetes-csi/csi-release-tools#262) from huww98/golang-toolchain
[3c8d966f](kubernetes-csi/csi-release-tools@3c8d966f) Treat main branch as equivalent to master branch
[e31de525](kubernetes-csi/csi-release-tools@e31de525) Merge [pull request kubernetes-csi#261](kubernetes-csi/csi-release-tools#261) from huww98/golang
[fd153a9e](kubernetes-csi/csi-release-tools@fd153a9e) Bump golang to 1.23.1
[a8b3d050](kubernetes-csi/csi-release-tools@a8b3d050) pull-test.sh: fix "git subtree pull" errors
[6b05f0fc](kubernetes-csi/csi-release-tools@6b05f0fc) use new GOTOOLCHAIN env to manage go version

git-subtree-dir: release-tools
git-subtree-split: 734c2b950c4b31f64b63052c64ffa5929d1c9b97
Signed-off-by: Mario Valderrama <mario.valderrama@ionos.com>
TerryHowe added a commit to TerryHowe/external-attacher that referenced this pull request Dec 9, 2024
98f23071 Merge pull request kubernetes-csi#260 from TerryHowe/update-csi-driver-version
e9d8712d Merge pull request kubernetes-csi#259 from stmcginnis/deprecated-kind-kube-root
faf79ff6 Remove --kube-root deprecated kind argument
734c2b95 Merge pull request kubernetes-csi#265 from Rakshith-R/consider-main-branch
f95c855b Merge pull request kubernetes-csi#262 from huww98/golang-toolchain
3c8d966f Treat main branch as equivalent to master branch
e31de525 Merge pull request kubernetes-csi#261 from huww98/golang
fd153a9e Bump golang to 1.23.1
a8b3d050 pull-test.sh: fix "git subtree pull" errors
6b05f0fc use new GOTOOLCHAIN env to manage go version
18b6ac6d chore: update CSI driver version to 1.15

git-subtree-dir: release-tools
git-subtree-split: 98f23071d946dd3de3188a7e1f84679067003162
TerryHowe added a commit to TerryHowe/external-attacher that referenced this pull request Dec 9, 2024
98f23071 Merge pull request kubernetes-csi#260 from TerryHowe/update-csi-driver-version
e9d8712d Merge pull request kubernetes-csi#259 from stmcginnis/deprecated-kind-kube-root
faf79ff6 Remove --kube-root deprecated kind argument
734c2b95 Merge pull request kubernetes-csi#265 from Rakshith-R/consider-main-branch
f95c855b Merge pull request kubernetes-csi#262 from huww98/golang-toolchain
3c8d966f Treat main branch as equivalent to master branch
e31de525 Merge pull request kubernetes-csi#261 from huww98/golang
fd153a9e Bump golang to 1.23.1
a8b3d050 pull-test.sh: fix "git subtree pull" errors
6b05f0fc use new GOTOOLCHAIN env to manage go version
18b6ac6d chore: update CSI driver version to 1.15

git-subtree-dir: release-tools
git-subtree-split: 98f23071d946dd3de3188a7e1f84679067003162
TerryHowe added a commit to TerryHowe/external-attacher that referenced this pull request Dec 9, 2024
98f23071 Merge pull request kubernetes-csi#260 from TerryHowe/update-csi-driver-version
e9d8712d Merge pull request kubernetes-csi#259 from stmcginnis/deprecated-kind-kube-root
faf79ff6 Remove --kube-root deprecated kind argument
734c2b95 Merge pull request kubernetes-csi#265 from Rakshith-R/consider-main-branch
f95c855b Merge pull request kubernetes-csi#262 from huww98/golang-toolchain
3c8d966f Treat main branch as equivalent to master branch
e31de525 Merge pull request kubernetes-csi#261 from huww98/golang
fd153a9e Bump golang to 1.23.1
a8b3d050 pull-test.sh: fix "git subtree pull" errors
6b05f0fc use new GOTOOLCHAIN env to manage go version
18b6ac6d chore: update CSI driver version to 1.15

git-subtree-dir: release-tools
git-subtree-split: 98f23071d946dd3de3188a7e1f84679067003162
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. kind/bug Categorizes issue or PR as related to a bug. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow adding ldflags during compilation.
5 participants