From: dkwo <dkwo@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] [rfc] build-style: go: set buildmode=pie globally
Date: Fri, 10 Jan 2025 13:36:14 +0100 [thread overview]
Message-ID: <20250110123614.4262622119@inbox.vuxu.org> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46958@inbox.vuxu.org>
[-- Attachment #1: Type: text/plain, Size: 798 bytes --]
There is an updated pull request by dkwo against master on the void-packages repository
https://github.com/dkwo/void-packages gopie
https://github.com/void-linux/void-packages/pull/46958
[rfc] build-style: go: set buildmode=pie globally
I rebuilt all packages natively on x86_64-glibc.
Packages that failed to build with `pie` have `nopie` set.
Building with pie may interfere with static binaries (e.g. if set `CGO_ENABLED=0`).
Up to now I disabled it for
- go-bindata
- go-md2man
- grafana
but further investigation/tests are needed.
See also https://go-review.googlesource.com/c/go/+/248199
https://github.com/golang/go/issues/41944
Todo: clean up `git grep buildmode=pie`
[ci skip]
A patch file from https://github.com/void-linux/void-packages/pull/46958.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-gopie-46958.patch --]
[-- Type: text/x-diff, Size: 7710 bytes --]
From 4952d7294c9dde800ea371ff99c871bac2f427f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
<congdanhqx@gmail.com>
Date: Sat, 12 Sep 2020 07:07:13 +0700
Subject: [PATCH 1/9] build-style: go: allow buildmode=pie
---
common/build-style/go.sh | 8 ++++++--
common/environment/build-style/go.sh | 1 -
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/common/build-style/go.sh b/common/build-style/go.sh
index 2a6305d959b8b6..88072a80abc3a6 100644
--- a/common/build-style/go.sh
+++ b/common/build-style/go.sh
@@ -30,6 +30,10 @@ do_build() {
done
: ${go_package:=$go_import_path}
+ local buildmode
+ if [ -z "$nopie" ]; then
+ buildmode=-buildmode=pie
+ fi
# Build using Go modules if there's a go.mod file
if [ "${go_mod_mode}" != "off" ] && [ -f go.mod ]; then
@@ -50,13 +54,13 @@ do_build() {
# default behavior.
go_mod_mode=
fi
- go install -p "$XBPS_MAKEJOBS" -mod="${go_mod_mode}" -modcacherw -v -tags "${go_build_tags}" -ldflags "${go_ldflags}" ${go_package}
+ go install -p "$XBPS_MAKEJOBS" -mod="${go_mod_mode}" $buildmode -modcacherw -v -tags "${go_build_tags}" -ldflags "${go_ldflags}" ${go_package}
if [[ -n "${_go_mod_path}" ]]; then
popd
fi
else
# Otherwise, build using GOPATH
- go install -p "$XBPS_MAKEJOBS" -v -tags "${go_build_tags}" -ldflags "${go_ldflags}" ${go_package}
+ go install -p "${XBPS_MAKEJOBS}" ${buildmode} -v -tags "${go_build_tags}" -ldflags "${go_ldflags}" ${go_package}
fi
}
diff --git a/common/environment/build-style/go.sh b/common/environment/build-style/go.sh
index 223bba83ff11b4..92a049411e0fbe 100644
--- a/common/environment/build-style/go.sh
+++ b/common/environment/build-style/go.sh
@@ -4,7 +4,6 @@ if [ -z "$hostmakedepends" -o "${hostmakedepends##*gcc-go-tools*}" ]; then
archs="aarch64* armv[567]* i686* x86_64* ppc64le* riscv64*"
fi
hostmakedepends+=" go"
- nopie=yes
else
# gccgo compiler
if [ -z "$archs" ]; then
From 7fe5af4b2decdb252939758345e3b7c8c7ab1fad Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Tue, 28 Nov 2023 16:01:32 -0500
Subject: [PATCH 2/9] cni-plugins: set nopie
---
srcpkgs/cni-plugins/template | 1 +
1 file changed, 1 insertion(+)
diff --git a/srcpkgs/cni-plugins/template b/srcpkgs/cni-plugins/template
index 1ac94367d0aea2..c7edeb69c6873c 100644
--- a/srcpkgs/cni-plugins/template
+++ b/srcpkgs/cni-plugins/template
@@ -11,6 +11,7 @@ homepage="https://github.com/containernetworking/plugins"
changelog="https://github.com/containernetworking/plugins/releases"
distfiles="https://github.com/containernetworking/plugins/archive/refs/tags/v${version}.tar.gz"
checksum=a2eff5f064f809ee41f8f49ef8aed1f0a4093c0c772f2ce2caaee4e6f395050a
+nopie=unverified
do_build() {
./build_linux.sh \
From 8b55b23a33149e29f8de335a3e8827fbad0805e8 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Tue, 28 Nov 2023 16:02:54 -0500
Subject: [PATCH 3/9] coyim: set nopie
---
srcpkgs/coyim/template | 1 +
1 file changed, 1 insertion(+)
diff --git a/srcpkgs/coyim/template b/srcpkgs/coyim/template
index 03d6d4f05cc905..6053f2a60082e4 100644
--- a/srcpkgs/coyim/template
+++ b/srcpkgs/coyim/template
@@ -12,6 +12,7 @@ license="GPL-3.0-only"
homepage="https://coy.im"
distfiles="https://github.com/coyim/coyim/archive/v${version}.tar.gz"
checksum=f2bf1e73562fbcc3a0b264a30f92dfe427dffe2046e9f44459087ecac5890098
+nopie=unverified
case "$XBPS_TARGET_MACHINE" in
x86_64*) ;;
From 3d536ea7e4115d9dc658125599ba86d2276602c3 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Tue, 28 Nov 2023 16:03:42 -0500
Subject: [PATCH 4/9] kubernetes: set nopie
---
srcpkgs/kubernetes/template | 1 +
1 file changed, 1 insertion(+)
diff --git a/srcpkgs/kubernetes/template b/srcpkgs/kubernetes/template
index 4766f97a01740c..d817feec89c543 100644
--- a/srcpkgs/kubernetes/template
+++ b/srcpkgs/kubernetes/template
@@ -17,6 +17,7 @@ nocross=yes
system_accounts="kube"
make_dirs="/var/lib/kubelet 0755 kube kube"
conf_files="/etc/kubernetes/*"
+nopie=unverified
do_build() {
make
From 01fda9ee79692cca39c9bb50c52f9ff6c71dd0f7 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Tue, 28 Nov 2023 16:04:26 -0500
Subject: [PATCH 5/9] moby: set nopie
---
srcpkgs/moby/template | 1 +
1 file changed, 1 insertion(+)
diff --git a/srcpkgs/moby/template b/srcpkgs/moby/template
index 83367b9b1b72e0..e0d600dd30a670 100644
--- a/srcpkgs/moby/template
+++ b/srcpkgs/moby/template
@@ -21,6 +21,7 @@ distfiles="https://github.com/moby/moby/archive/v${version}.tar.gz>moby-$version
checksum="ab0389f1e64f74626667dc773cfc21ac9bb686bacf62b14f15c5b5888ca95313
5c5e3aa7599e85036438a65016796aa11df4afb44d13b5927dcfb0ec5947a86b"
system_groups="docker"
+nopie=unverified
_moby_builddir="moby-$version"
_libnetwork_builddir="libnetwork-$_libnetwork_commit"
From 6378237cfe8c5387100d3dd0e51a648a55ac0152 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Tue, 28 Nov 2023 16:05:07 -0500
Subject: [PATCH 6/9] nncp: set nopie
---
srcpkgs/nncp/template | 1 +
1 file changed, 1 insertion(+)
diff --git a/srcpkgs/nncp/template b/srcpkgs/nncp/template
index 256a6b3c95a8bc..dae10bb7e8610d 100644
--- a/srcpkgs/nncp/template
+++ b/srcpkgs/nncp/template
@@ -10,6 +10,7 @@ license="GPL-3.0-only"
homepage="http://www.nncpgo.org/"
distfiles="http://www.nncpgo.org/download/${pkgname}-${version}.tar.xz"
checksum=ec4114bcd9184aa8781f38dbaa3aa04255dfbba9c3536bf75969e66bc334aff2
+nopie=unverified
do_build() {
./bin/build
From b664fe0e1c3afb585f49794444193f49a20f95ee Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Sun, 7 Jan 2024 18:33:20 +0100
Subject: [PATCH 7/9] go-bindata: set nopie
---
srcpkgs/go-bindata/template | 1 +
1 file changed, 1 insertion(+)
diff --git a/srcpkgs/go-bindata/template b/srcpkgs/go-bindata/template
index 25bb733eec5aa9..4784f9f129c9a7 100644
--- a/srcpkgs/go-bindata/template
+++ b/srcpkgs/go-bindata/template
@@ -12,3 +12,4 @@ license="Public Domain"
homepage="https://github.com/jteeuwen/go-bindata"
distfiles="https://github.com/jteeuwen/go-bindata/archive/${_commit}.tar.gz"
checksum=65cf65ac422fb8072abfaabec86c20a74e448a93b489e896a36642e7049f5d32
+nopie=static
From 3f9709c9902859e5a5579905ca299e6de3408797 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Sun, 7 Jan 2024 18:35:32 +0100
Subject: [PATCH 8/9] go-md2man: set nopie
---
srcpkgs/go-md2man/template | 1 +
1 file changed, 1 insertion(+)
diff --git a/srcpkgs/go-md2man/template b/srcpkgs/go-md2man/template
index 8e1486ebf4f29f..32d470fb5f8460 100644
--- a/srcpkgs/go-md2man/template
+++ b/srcpkgs/go-md2man/template
@@ -10,6 +10,7 @@ license="MIT"
homepage="https://github.com/cpuguy83/go-md2man"
distfiles="https://github.com/cpuguy83/go-md2man/archive/v${version}.tar.gz"
checksum=5fa29154237bc840a10a06231c066f9ddbe06bb31d1c3372eab12e1ed977271f
+nopie=static
post_install() {
vlicense LICENSE.md
From c73f46953b2e9599ed8d629ca0d8eec7b05e9ba7 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Sun, 7 Jan 2024 20:59:34 +0100
Subject: [PATCH 9/9] grafana: set nopie
---
srcpkgs/grafana/template | 1 +
1 file changed, 1 insertion(+)
diff --git a/srcpkgs/grafana/template b/srcpkgs/grafana/template
index 6efb6a22e0d242..14db16aec80981 100644
--- a/srcpkgs/grafana/template
+++ b/srcpkgs/grafana/template
@@ -23,6 +23,7 @@ make_dirs="/var/log/grafana 0755 _grafana _grafana"
conf_files="/etc/grafana/grafana.ini"
go_ldflags="-X main.version=${version}"
+nopie=static
post_extract() {
# remove prebuilt binaries
next prev parent reply other threads:[~2025-01-10 12:36 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-29 18:04 [PR PATCH] [rfc] build-style: go: allow pie (v2) dkwo
2023-10-29 18:12 ` [PR PATCH] [Updated] " dkwo
2023-10-31 21:01 ` dkwo
2023-11-21 16:41 ` dkwo
2023-11-21 16:42 ` dkwo
2023-11-22 15:04 ` leahneukirchen
2023-11-24 22:06 ` dkwo
2023-11-27 14:29 ` dkwo
2023-11-27 14:30 ` dkwo
2023-11-28 14:14 ` dkwo
2023-11-28 20:49 ` dkwo
2023-11-28 20:52 ` dkwo
2023-11-28 20:52 ` dkwo
2023-11-28 20:56 ` dkwo
2023-11-28 20:58 ` dkwo
2023-11-28 20:59 ` dkwo
2023-11-28 21:06 ` [PR PATCH] [Updated] " dkwo
2023-11-28 21:09 ` dkwo
2023-11-29 15:58 ` dkwo
2023-11-29 16:00 ` [PR PATCH] [Updated] " dkwo
2023-11-29 17:51 ` CameronNemo
2023-11-29 18:34 ` benalb
2023-11-29 20:59 ` benalb
2023-11-30 0:22 ` dkwo
2023-11-30 0:22 ` dkwo
2023-11-30 0:23 ` dkwo
2023-12-01 17:28 ` benalb
2023-12-02 15:17 ` [PR PATCH] [Updated] " dkwo
2023-12-02 15:20 ` dkwo
2023-12-02 22:00 ` dkwo
2023-12-03 19:47 ` [PR PATCH] [Updated] " dkwo
2023-12-04 15:42 ` dkwo
2023-12-06 21:25 ` dkwo
2023-12-06 21:28 ` dkwo
2023-12-07 15:04 ` [PR PATCH] [Updated] " dkwo
2023-12-07 15:07 ` dkwo
2023-12-07 15:12 ` dkwo
2023-12-08 21:35 ` leahneukirchen
2023-12-10 0:49 ` classabbyamp
2023-12-10 15:26 ` [PR PATCH] [Updated] " dkwo
2023-12-10 15:27 ` dkwo
2023-12-10 15:35 ` [PR PATCH] [Updated] " dkwo
2023-12-10 15:36 ` dkwo
2023-12-21 9:12 ` dkwo
2023-12-26 17:59 ` dkwo
2024-01-06 22:45 ` dkwo
2024-01-07 21:27 ` [PR PATCH] [Updated] [rfc] build-style: go: set pie globally dkwo
2024-01-08 14:15 ` [PR PATCH] [Updated] [rfc] build-style: go: set buildmode=pie globally dkwo
2024-02-15 15:06 ` dkwo
2024-05-16 1:46 ` github-actions
2024-05-16 14:18 ` [PR PATCH] [Updated] " dkwo
2024-08-12 13:29 ` dkwo
2024-10-10 15:11 ` dkwo
2025-01-10 2:01 ` github-actions
2025-01-10 12:36 ` dkwo [this message]
2025-04-11 2:06 ` github-actions
2025-04-12 17:24 ` [PR PATCH] [Updated] " dkwo
2025-07-13 2:14 ` github-actions
2025-07-13 20:09 ` [PR PATCH] [Updated] " dkwo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250110123614.4262622119@inbox.vuxu.org \
--to=dkwo@users.noreply.github.com \
--cc=ml@inbox.vuxu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).