Skip to contentSkip to conversation

package/go/go-cf: new package

PATCH In review James Hilliard 2 participants 6 messages Oct 28, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 package/go/go-cf: new package

This is a fork of go needed for cloudflared to work properly.

---
 .checkpackageignore                           |   1 +
 ...explicit-option-for-crosscompilation.patch |   1 +
 ...ldvcs-false-when-building-go-bootstr.patch |   1 +
 package/go/go-cf/go-cf.hash                   |   3 +
 package/go/go-cf/go-cf.mk                     | 101 ++++++++++++++++++
 package/pkg-golang.mk                         |  13 ++-
 6 files changed, 117 insertions(+), 3 deletions(-)
 create mode 120000 package/go/go-cf/0001-build.go-explicit-option-for-crosscompilation.patch
 create mode 120000 package/go/go-cf/0002-cmd-dist-set-buildvcs-false-when-building-go-bootstr.patch
 create mode 100644 package/go/go-cf/go-cf.hash
 create mode 100644 package/go/go-cf/go-cf.mk
.checkpackageignore +1 -0
index babcb813b4..1213bd1ece 100644
@@ -553,6 +553,7 @@ package/glorytun/0002-aegis256.c-fix-aarch64-build-with-uclibc.patch lib_patch.U
 package/gnu-efi/0001-Make.defaults-don-t-override-ARCH-when-cross-compili.patch lib_patch.Upstream
 package/gnupg/0001-build-Always-use-EXTERN_UNLESS_MAIN_MODULE-pattern.patch lib_patch.Upstream
 package/gnuplot/0001-configure-add-without-demo-option.patch lib_patch.Upstream
+package/go/go-cf/0001-build.go-explicit-option-for-crosscompilation.patch lib_patch.Upstream
 package/go/go-src/0001-build.go-explicit-option-for-crosscompilation.patch lib_patch.Upstream
 package/gob2/0001-dont-include-from-prefix.patch lib_patch.Upstream
 package/gobject-introspection/0001-disable-tests.patch lib_patch.Upstream
package/go/go-cf/0001-build.go-explicit-option-for-crosscompilation.patch new file +1 -0
new file mode 120000
index 0000000000..e77a438613
@@ -0,0 +1 @@
+../go-src/0001-build.go-explicit-option-for-crosscompilation.patch
\ No newline at end of file
package/go/go-cf/0002-cmd-dist-set-buildvcs-false-when-building-go-bootstr.patch new file +1 -0
new file mode 120000
index 0000000000..ee0c654f08
@@ -0,0 +1 @@
+../go-src/0002-cmd-dist-set-buildvcs-false-when-building-go-bootstr.patch
\ No newline at end of file
package/go/go-cf/go-cf.hash new file +3 -0
new file mode 100644
index 0000000000..78bf3eec5b
@@ -0,0 +1,3 @@
+# From https://go.dev/dl
+sha256  da1bcdeb86767dab40bf4debd49615a32c795689ba2ac7f6f87d2f389691fdc1  go-cf-ec0a014545f180b0c74dfd687698657a9e86e310.tar.gz
+sha256  2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067  LICENSE
package/go/go-cf/go-cf.mk new file +101 -0

101 lines not on this page · raw message

package/pkg-golang.mk +10 -3
index 8e27602d41..2d19c044ee 100644
@@ -21,7 +21,6 @@
 #
 ################################################################################
 
-GO_BIN = $(HOST_DIR)/bin/go
 
 ################################################################################
 # inner-golang-package -- defines how the configuration, compilation and
@@ -40,6 +39,14 @@ GO_BIN = $(HOST_DIR)/bin/go
 
 define inner-golang-package
 
+ifndef $(2)_GO_BIN
+	ifdef $(3)_GO_BIN
+		$(2)_GO_BIN = $$($(3)_GO_BIN)
+	else
+		$(2)_GO_BIN ?= $$(HOST_DIR)/bin/go
+	endif
+endif
+
 $(2)_BUILD_OPTS += \
 	-ldflags "$$($(2)_LDFLAGS)" \
 	-modcacherw \
@@ -124,7 +131,7 @@ define $(2)_BUILD_CMDS
 		cd $$(@D); \
 		$$(HOST_GO_TARGET_ENV) \
 			$$($(2)_GO_ENV) \
-			$$(GO_BIN) build -v $$($(2)_BUILD_OPTS) \
+			$$($(2)_GO_BIN) build -v $$($(2)_BUILD_OPTS) \
 			-o $$(@D)/bin/$$(or $$($(2)_BIN_NAME),$$(notdir $$(d))) \
 			$$($(2)_GOMOD)/$$(d)
 	)
@@ -136,7 +143,7 @@ define $(2)_BUILD_CMDS
 		cd $$(@D); \
 		$$(HOST_GO_HOST_ENV) \
 			$$($(2)_GO_ENV) \
-			$$(GO_BIN) build -v $$($(2)_BUILD_OPTS) \
+			$$($(2)_GO_BIN) build -v $$($(2)_BUILD_OPTS) \
 			-o $$(@D)/bin/$$(or $$($(2)_BIN_NAME),$$(notdir $$(d))) \
 			$$($(2)_GOMOD)/$$(d)
 	)
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 2/2 package/cloudflared: use go-cf toolchain

Cloudflared needs a custom fork of golang to function properly.

---
 package/cloudflared/cloudflared.mk | 3 +++
 1 file changed, 3 insertions(+)
package/cloudflared/cloudflared.mk +3 -0
index 68849e9b82..6820fe330f 100644
@@ -11,5 +11,8 @@ CLOUDFLARED_LICENSE_FILES = LICENSE
 CLOUDFLARED_CPE_ID_VENDOR = cloudflare
 CLOUDFLARED_BUILD_TARGETS = cmd/cloudflared
 CLOUDFLARED_LDFLAGS = -X main.Version=$(CLOUDFLARED_VERSION)
+CLOUDFLARED_DEPENDENCIES = host-go-cf
+CLOUDFLARED_GO_BIN = $(HOST_DIR)/bin/go-cf
+CLOUDFLARED_GO_ENV = $(HOST_GO_CF_TARGET_ENV)
 
 $(eval $(golang-package))
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw
In reply to James Hilliard
Quoted 3 lines · On Mon, 28 Oct 2024 16:10:44 -0600 James Hilliard <[email protected]>…

This is a fork of go needed for cloudflared to work properly.

This is really nuts/crazy. Are we going to have to package a different Go compiler for each and every project?

(Note: your commit message needs a lot more explanation on how it integrates in Buildroot, what happens if one uses both normal Go and go-cf, whether they will conflict, or not, etc.).

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

Hi Thomas, James,

Quoted 10 lines · Thomas Petazzoni
Quoted 3 lines · On Mon, 28 Oct 2024 16:10:44 -0600 James Hilliard <[email protected]>…

This is a fork of go needed for cloudflared to work properly.

This is really nuts/crazy. Are we going to have to package a different Go compiler for each and every project?

The maintenance overhead of adding multiple Go compilers seems not worth it.

I see from the Cloudflare fork of Go that it has these changes to TLS:

- Encrypted ClientHello (ECH)
- Post-quantum key agreement
- Delegated Credentials
- Post-quantum certificates.
- Configuraton of keyshares sent in ClientHello with tls.Config.ClientCurveGuess.

The concept of having a forked Go in itself is not that crazy.

What makes this difficult / not worth it is how complex the Go infrastructure is.

Just look at this patch and all the lines added: TARGET_ENV, etc. Do we have to keep updating these every time we change the Go infrastructure?

Is there some way we can reuse most of the code from the Go infra for this?

Best regards,
Christian Stewart
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw
Quoted 9 lines · Christian Stewart

Hi Thomas, James,

Quoted 4 lines · Thomas Petazzoni

On Mon, 28 Oct 2024 16:10:44 -0600
James Hilliard <[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

This is a fork of go needed for cloudflared to work properly.

This is really nuts/crazy. Are we going to have to package a different Go compiler for each and every project?

The maintenance overhead of adding multiple Go compilers seems not worth it.

Issue here is cloudflared doesn't really work otherwise so not sure what other approaches would work.

Quoted 10 lines

I see from the Cloudflare fork of Go that it has these changes to TLS:

- Encrypted ClientHello (ECH)
- Post-quantum key agreement
- Delegated Credentials
- Post-quantum certificates.
- Configuraton of keyshares sent in ClientHello with tls.Config.ClientCurveGuess.

Quoted 4 lines

The concept of having a forked Go in itself is not that crazy.

What makes this difficult / not worth it is how complex the Go infrastructure is.

Not sure how else to make cloudflared work properly since there are runtime issues without these features.

Quoted 4 lines

Just look at this patch and all the lines added: TARGET_ENV, etc. Do we have to keep updating these every time we change the Go infrastructure?

Well we have a bunch of these duplicated for go bootstrapping already, I kind of just followed that existing pattern.

Quoted 2 lines

Is there some way we can reuse most of the code from the Go infra for this?

Hmm, maybe there's a way to template the directories better? Might help with the bootstrapping stages as well.

Quoted 3 lines

Best regards,
Christian Stewart

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#5 lore raw
In reply to Thomas Petazzoni via buildroot
Quoted 10 lines · Thomas Petazzoni
Quoted 3 lines · On Mon, 28 Oct 2024 16:10:44 -0600 James Hilliard <[email protected]>…

This is a fork of go needed for cloudflared to work properly.

This is really nuts/crazy. Are we going to have to package a different Go compiler for each and every project?

Yeah, I agree it's a bit crazy, not sure if there's a better way to handle this however. I tried to model this on how we currently handle multiple go toolchains for bootstrapping purposes with this simply depending on the latest go toolchain for bootstrapping go-cf.

I sure hope not, however for cloudflared they seem to be depending on a bunch of experimental features that are not in upstream golang.

Quoted 4 lines

(Note: your commit message needs a lot more explanation on how it integrates in Buildroot, what happens if one uses both normal Go and go-cf, whether they will conflict, or not, etc.).

Yeah, it shouldn't conflict, I did verify I can build packages that require golang 1.23 at the same time as cloudflared on their 1.22 based fork.

Quoted 6 lines

Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training
https://bootlin.com

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot