diff mbox series

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

Message ID 20190603092101.8658-1-mirza.krak@northern.tech
State Accepted
Headers show
Series [1/1] package/pkg-golang: add cflags/ldflags to GO_HOST_ENV | expand

Commit Message

Mirza Krak June 3, 2019, 9:21 a.m. UTC
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.

Signed-off-by: Mirza Krak <mirza.krak@northern.tech>
---

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(+)

--
2.11.0

Comments

Adam Duskett June 8, 2019, 7:36 p.m. UTC | #1
All:

Acked-by: Adam Duskett <aduskett@gmail.com>
Tested-by: Adam Duskett <aduskett@gmail.com>

On Mon, Jun 3, 2019 at 5:21 AM Mirza Krak <mirza.krak@northern.tech> wrote:
>
> 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.
>
> Signed-off-by: Mirza Krak <mirza.krak@northern.tech>
> ---
>
> 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(+)
>
> diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk
> index b4e8a53065..72e8f6b7af 100644
> --- a/package/pkg-golang.mk
> +++ b/package/pkg-golang.mk
> @@ -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@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Arnout Vandecappelle June 10, 2019, 11:53 a.m. UTC | #2
On 03/06/2019 11:21, Mirza Krak wrote:
> 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.
> 
> Signed-off-by: Mirza Krak <mirza.krak@northern.tech>

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

> ---
> 
> 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

> 
>  package/pkg-golang.mk | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk
> index b4e8a53065..72e8f6b7af 100644
> --- a/package/pkg-golang.mk
> +++ b/package/pkg-golang.mk
> @@ -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@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
>
Mirza Krak June 10, 2019, 12:10 p.m. UTC | #3
On Mon, Jun 10, 2019 at 1:53 PM Arnout Vandecappelle <arnout@mind.be> wrote:
>
>
>
> On 03/06/2019 11:21, Mirza Krak wrote:
> > 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.
> >
> > Signed-off-by: Mirza Krak <mirza.krak@northern.tech>
>
>  I apparently forgot to mention that I applied this to master, thanks. However...
>
> > ---
> >
> > 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...

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?
Arnout Vandecappelle June 10, 2019, 2:55 p.m. UTC | #4
On 10/06/2019 14:10, Mirza Krak wrote:
> On Mon, Jun 10, 2019 at 1:53 PM Arnout Vandecappelle <arnout@mind.be> wrote:
>>
>>
>>
>> On 03/06/2019 11:21, Mirza Krak wrote:
>>> 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.
>>>
>>> Signed-off-by: Mirza Krak <mirza.krak@northern.tech>
>>
>>  I apparently forgot to mention that I applied this to master, thanks. However...
>>
>>> ---
>>>
>>> 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...
> 
> I do not believe that it would try to link statically, at least that
> was not the intention.

 Doesn't Go always link statically?

> However I am not able to reproduce this
> locally.

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

> 
> 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.

> This not something that I use
> locally.

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

 Regards,
 Arnout


> Maybe this is also what you where referring to?
Mirza Krak June 10, 2019, 3:12 p.m. UTC | #5
On Mon, Jun 10, 2019 at 4:55 PM Arnout Vandecappelle <arnout@mind.be> wrote:
>
>
>
> On 10/06/2019 14:10, Mirza Krak wrote:
> > On Mon, Jun 10, 2019 at 1:53 PM Arnout Vandecappelle <arnout@mind.be> wrote:
> >>
> >>
> >>
> >> On 03/06/2019 11:21, Mirza Krak wrote:
> >>> 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.
> >>>
> >>> Signed-off-by: Mirza Krak <mirza.krak@northern.tech>
> >>
> >>  I apparently forgot to mention that I applied this to master, thanks. However...
> >>
> >>> ---
> >>>
> >>> 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...
> >
> > 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.

> > However I am not able to reproduce this
> > locally.
>
>  Maybe you have liblzma.a installed on your host system?
>
> >
> > 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.
>
> > 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.
Mirza Krak June 10, 2019, 3:41 p.m. UTC | #6
On Mon, Jun 10, 2019 at 5:12 PM Mirza Krak <mirza.krak@northern.tech> wrote:
>

< snip >

> > >
> > > 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.
> >
> > > 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/
Peter Korsgaard June 23, 2019, 7:20 p.m. UTC | #7
>>>>> "Mirza" == Mirza Krak <mirza.krak@northern.tech> 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.

 > Signed-off-by: Mirza Krak <mirza.krak@northern.tech>
 > ---

 > 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.
diff mbox series

Patch

diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk
index b4e8a53065..72e8f6b7af 100644
--- a/package/pkg-golang.mk
+++ b/package/pkg-golang.mk
@@ -35,6 +35,8 @@  GO_TARGET_ENV = \
 	$(GO_COMMON_ENV)

 GO_HOST_ENV = \
+	CGO_CFLAGS="$(HOST_CFLAGS)" \
+	CGO_LDFLAGS="$(HOST_LDFLAGS)" \
 	$(GO_COMMON_ENV)

 ################################################################################