Skip to contentSkip to conversation

package/pkg-golang: add cflags/ldflags to GO_HOST_ENV

PATCH New Mirza Krak 4 participants 8 messages Jun 3, 2019 – Jun 23, 2019

lore
Share & tools
lore

Mirza Krak

author
#0 lore raw

PATCH 1/1 package/pkg-golang: add cflags/ldflags to GO_HOST_ENV

If a go host package is built using cgo, it needs access to HOST_CFLAGS/HOST_LDFLAGS to utilize host packages it might depend on.

---

This fixes current build errors of mender-artifact-3.0.0:

http://autobuild.buildroot.net/results/dd1a6dac03dd3b68ee63761c33dbb01c328d4f14/build-end.log

 package/pkg-golang.mk | 2 ++
 1 file changed, 2 insertions(+)
package/pkg-golang.mk +2 -0
index b4e8a53065..72e8f6b7af 100644
@@ -35,6 +35,8 @@ GO_TARGET_ENV = \
 	$(GO_COMMON_ENV)
 
 GO_HOST_ENV = \
+	CGO_CFLAGS="$(HOST_CFLAGS)" \
+	CGO_LDFLAGS="$(HOST_LDFLAGS)" \
 	$(GO_COMMON_ENV)
 
 ################################################################################

--
2.11.0

#1 lore raw

PATCH 1/1 package/pkg-golang: add cflags/ldflags to GO_HOST_ENV

All:

Quoted 35 lines · Mirza Krak

If a go host package is built using cgo, it needs access to HOST_CFLAGS/HOST_LDFLAGS to utilize host packages it might depend on.

---

This fixes current build errors of mender-artifact-3.0.0:

http://autobuild.buildroot.net/results/dd1a6dac03dd3b68ee63761c33dbb01c328d4f14/build-end.log

 package/pkg-golang.mk | 2 ++
 1 file changed, 2 insertions(+)
package/pkg-golang.mk +2 -1
index b4e8a53065..72e8f6b7af 100644
@@ -35,6 +35,8 @@ GO_TARGET_ENV = \
        $(GO_COMMON_ENV)
 
 GO_HOST_ENV = \
+       CGO_CFLAGS="$(HOST_CFLAGS)" \
+       CGO_LDFLAGS="$(HOST_LDFLAGS)" \
        $(GO_COMMON_ENV)
 
 ################################################################################
--

2.11.0

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

#2 lore raw

PATCH 1/1 package/pkg-golang: add cflags/ldflags to GO_HOST_ENV

In reply to Mirza Krak
Quoted 5 lines · Mirza Krak

If a go host package is built using cgo, it needs access to HOST_CFLAGS/HOST_LDFLAGS to utilize host packages it might depend on.

I apparently forgot to mention that I applied this to master, thanks. However...

Quoted 5 lines

---

This fixes current build errors of mender-artifact-3.0.0:

http://autobuild.buildroot.net/results/dd1a6dac03dd3b68ee63761c33dbb01c328d4f14/build-end.log

Still failing:

http://autobuild.buildroot.net/results/f9b/f9ba64ab4c8d7fa6cb301fab37ee4141ba442f61/build-end.log

I think the problem is that it is being linked statically, but host-xz only
builds the shared library...

Regards,
Arnout

Quoted 25 lines
 package/pkg-golang.mk | 2 ++
 1 file changed, 2 insertions(+)
package/pkg-golang.mk +2 -1
index b4e8a53065..72e8f6b7af 100644
@@ -35,6 +35,8 @@ GO_TARGET_ENV = \
 	$(GO_COMMON_ENV)
 
 GO_HOST_ENV = \
+	CGO_CFLAGS="$(HOST_CFLAGS)" \
+	CGO_LDFLAGS="$(HOST_LDFLAGS)" \
 	$(GO_COMMON_ENV)
 
 ################################################################################
--

2.11.0

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

author
#3 lore raw

PATCH 1/1 package/pkg-golang: add cflags/ldflags to GO_HOST_ENV

Quoted 16 lines · Arnout Vandecappelle
Quoted 5 lines · Mirza Krak

If a go host package is built using cgo, it needs access to HOST_CFLAGS/HOST_LDFLAGS to utilize host packages it might depend on.

I apparently forgot to mention that I applied this to master, thanks. However...

Quoted 4 lines

---

This fixes current build errors of mender-artifact-3.0.0:

Quoted 8 lines
Quoted 1 line

http://autobuild.buildroot.net/results/dd1a6dac03dd3b68ee63761c33dbb01c328d4f14/build-end.log

Still failing:

http://autobuild.buildroot.net/results/f9b/f9ba64ab4c8d7fa6cb301fab37ee4141ba442f61/build-end.log

I think the problem is that it is being linked statically, but host-xz only
builds the shared library...

I do not believe that it would try to link statically, at least that was not the intention. However I am not able to reproduce this locally.

Will compare defconfigs but I suspect it is related to,

BR2_STATIC_LIBS=y

being set in the erroneous build. This not something that I use locally. Maybe this is also what you where referring to?

Signature · 3 lines
Mirza Krak | Embedded Solutions Architect | https://mender.io

 Northern.tech AS | @northerntechHQ
#4 lore raw

PATCH 1/1 package/pkg-golang: add cflags/ldflags to GO_HOST_ENV

Quoted 21 lines · Mirza Krak
Quoted 20 lines · Arnout Vandecappelle
Quoted 5 lines · Mirza Krak

If a go host package is built using cgo, it needs access to HOST_CFLAGS/HOST_LDFLAGS to utilize host packages it might depend on.

I apparently forgot to mention that I applied this to master, thanks. However...

Quoted 5 lines

---

This fixes current build errors of mender-artifact-3.0.0:

http://autobuild.buildroot.net/results/dd1a6dac03dd3b68ee63761c33dbb01c328d4f14/build-end.log

Still failing:

Quoted 7 lines
Quoted 4 lines

http://autobuild.buildroot.net/results/f9b/f9ba64ab4c8d7fa6cb301fab37ee4141ba442f61/build-end.log

I think the problem is that it is being linked statically, but host-xz only
builds the shared library...

I do not believe that it would try to link statically, at least that was not the intention.

Doesn't Go always link statically?

Quoted 2 lines

However I am not able to reproduce this
locally.

Maybe you have liblzma.a installed on your host system?

Quoted 6 lines

Will compare defconfigs but I suspect it is related to,

BR2_STATIC_LIBS=y

being set in the erroneous build.

It may be related, but it shouldn't be: the build of host packages should not
depend on the setting of BR2_STATIC_LIBS on the target.

Quoted 2 lines

This not something that I use
locally.

You can try to reproduce locally using the config from the autobuilder.

Regards,
Arnout

Quoted 1 line

Maybe this is also what you where referring to?

author
#5 lore raw

PATCH 1/1 package/pkg-golang: add cflags/ldflags to GO_HOST_ENV

Quoted 27 lines · Arnout Vandecappelle
Quoted 23 lines · Mirza Krak
Quoted 22 lines · Arnout Vandecappelle
Quoted 5 lines · Mirza Krak

If a go host package is built using cgo, it needs access to HOST_CFLAGS/HOST_LDFLAGS to utilize host packages it might depend on.

I apparently forgot to mention that I applied this to master, thanks. However...

Quoted 5 lines

---

This fixes current build errors of mender-artifact-3.0.0:

http://autobuild.buildroot.net/results/dd1a6dac03dd3b68ee63761c33dbb01c328d4f14/build-end.log

Still failing:

http://autobuild.buildroot.net/results/f9b/f9ba64ab4c8d7fa6cb301fab37ee4141ba442f61/build-end.log

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I think the problem is that it is being linked statically, but host-xz only
builds the shared library...

I do not believe that it would try to link statically, at least that was not the intention.

Doesn't Go always link statically?

From my understanding, this is not the case when using CGO unless you explicitly state so.

Quoted 12 lines
Quoted 2 lines

However I am not able to reproduce this
locally.

Maybe you have liblzma.a installed on your host system?

Quoted 6 lines

Will compare defconfigs but I suspect it is related to,

BR2_STATIC_LIBS=y

being set in the erroneous build.

Quoted 7 lines

It may be related, but it shouldn't be: the build of host packages should not
depend on the setting of BR2_STATIC_LIBS on the target.

Quoted 2 lines

This not something that I use
locally.

You can try to reproduce locally using the config from the autobuilder.

Thanks for the pointers, I will investigate further.

Signature · 3 lines
Mirza Krak | Embedded Solutions Architect | https://mender.io

 Northern.tech AS | @northerntechHQ
author
#6 lore raw

PATCH 1/1 package/pkg-golang: add cflags/ldflags to GO_HOST_ENV

Quoted 1 line · Mirza Krak

< snip >

Quoted 10 lines
Quoted 10 lines
Quoted 6 lines

Will compare defconfigs but I suspect it is related to,

BR2_STATIC_LIBS=y

being set in the erroneous build.

It may be related, but it shouldn't be: the build of host packages should not
depend on the setting of BR2_STATIC_LIBS on the target.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

This not something that I use
locally.

You can try to reproduce locally using the config from the autobuilder.

Thanks for the pointers, I will investigate further.

I believe that I found the cause of this, patch sent

      https://patchwork.ozlabs.org/patch/1113150/
Signature · 3 lines
Mirza Krak | Embedded Solutions Architect | https://mender.io

 Northern.tech AS | @northerntechHQ
#7 lore raw

PATCH 1/1 package/pkg-golang: add cflags/ldflags to GO_HOST_ENV

In reply to Mirza Krak
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Mirza" == Mirza Krak <[email protected]> writes:

If a go host package is built using cgo, it needs access to HOST_CFLAGS/HOST_LDFLAGS to utilize host packages it might depend on.

Quoted 6 lines

---

This fixes current build errors of mender-artifact-3.0.0:

http://autobuild.buildroot.net/results/dd1a6dac03dd3b68ee63761c33dbb01c328d4f14/build-end.log

Committed to 2019.05.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard