[PATCH] tools/go: honor append build flags

Roger Pau Monne posted 1 patch 2 years, 9 months ago
Test gitlab-ci failed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20210707071531.69001-1-roger.pau@citrix.com
tools/golang/xenlight/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] tools/go: honor append build flags
Posted by Roger Pau Monne 2 years, 9 months ago
Make the go build use APPEND_{C/LD}FLAGS when necessary, just like
other parts of the build.

Reported-by: Ting-Wei Lan <lantw44@gmail.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Note sure if it's the best way to add the appended flags, I'm not
familiar with the go build system. In any case this fixes the build
when required libraries (ie: yajl) are not part of the system search
path and instead passed in APPEND_{C/LD}FLAGS.
---
 tools/golang/xenlight/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/golang/xenlight/Makefile b/tools/golang/xenlight/Makefile
index e394ef9b2b..64671f246c 100644
--- a/tools/golang/xenlight/Makefile
+++ b/tools/golang/xenlight/Makefile
@@ -27,7 +27,7 @@ GOXL_GEN_FILES = types.gen.go helpers.gen.go
 # so that it can find the actual library.
 .PHONY: build
 build: xenlight.go $(GOXL_GEN_FILES)
-	CGO_CFLAGS="$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog)" CGO_LDFLAGS="$(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -L$(XEN_libxenlight) -L$(XEN_libxentoollog)" $(GO) build -x
+	CGO_CFLAGS="$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog) $(APPEND_CFLAGS)" CGO_LDFLAGS="$(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -L$(XEN_libxenlight) -L$(XEN_libxentoollog) $(APPEND_LDFLAGS)" $(GO) build -x
 
 .PHONY: install
 install: build
-- 
2.31.1


Re: [PATCH] tools/go: honor append build flags
Posted by Nick Rosbrook 2 years, 9 months ago
On Wed, Jul 07, 2021 at 09:15:31AM +0200, Roger Pau Monne wrote:
> Make the go build use APPEND_{C/LD}FLAGS when necessary, just like
> other parts of the build.
> 
> Reported-by: Ting-Wei Lan <lantw44@gmail.com>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
> Note sure if it's the best way to add the appended flags, I'm not
> familiar with the go build system. In any case this fixes the build
> when required libraries (ie: yajl) are not part of the system search
> path and instead passed in APPEND_{C/LD}FLAGS.

This is right. The CGO_{C,LD}FLAGS environment variables basically work
just like regular {C,LD}FLAGS.

> ---
>  tools/golang/xenlight/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/golang/xenlight/Makefile b/tools/golang/xenlight/Makefile
> index e394ef9b2b..64671f246c 100644
> --- a/tools/golang/xenlight/Makefile
> +++ b/tools/golang/xenlight/Makefile
> @@ -27,7 +27,7 @@ GOXL_GEN_FILES = types.gen.go helpers.gen.go
>  # so that it can find the actual library.
>  .PHONY: build
>  build: xenlight.go $(GOXL_GEN_FILES)
> -	CGO_CFLAGS="$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog)" CGO_LDFLAGS="$(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -L$(XEN_libxenlight) -L$(XEN_libxentoollog)" $(GO) build -x
> +	CGO_CFLAGS="$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog) $(APPEND_CFLAGS)" CGO_LDFLAGS="$(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -L$(XEN_libxenlight) -L$(XEN_libxentoollog) $(APPEND_LDFLAGS)" $(GO) build -x
>  
>  .PHONY: install
>  install: build
> -- 
> 2.31.1
> 
> 
Acked-by: Nick Rosbrook <rosbrookn@ainfosec.com>

Thanks,
NR

Re: [PATCH] tools/go: honor append build flags
Posted by Roger Pau Monné 2 years, 7 months ago
On Wed, Jul 07, 2021 at 09:42:20AM -0400, Nick Rosbrook wrote:
> On Wed, Jul 07, 2021 at 09:15:31AM +0200, Roger Pau Monne wrote:
> > Make the go build use APPEND_{C/LD}FLAGS when necessary, just like
> > other parts of the build.
> > 
> > Reported-by: Ting-Wei Lan <lantw44@gmail.com>
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > ---
> > Note sure if it's the best way to add the appended flags, I'm not
> > familiar with the go build system. In any case this fixes the build
> > when required libraries (ie: yajl) are not part of the system search
> > path and instead passed in APPEND_{C/LD}FLAGS.
> 
> This is right. The CGO_{C,LD}FLAGS environment variables basically work
> just like regular {C,LD}FLAGS.
> 
> > ---
> >  tools/golang/xenlight/Makefile | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tools/golang/xenlight/Makefile b/tools/golang/xenlight/Makefile
> > index e394ef9b2b..64671f246c 100644
> > --- a/tools/golang/xenlight/Makefile
> > +++ b/tools/golang/xenlight/Makefile
> > @@ -27,7 +27,7 @@ GOXL_GEN_FILES = types.gen.go helpers.gen.go
> >  # so that it can find the actual library.
> >  .PHONY: build
> >  build: xenlight.go $(GOXL_GEN_FILES)
> > -	CGO_CFLAGS="$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog)" CGO_LDFLAGS="$(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -L$(XEN_libxenlight) -L$(XEN_libxentoollog)" $(GO) build -x
> > +	CGO_CFLAGS="$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog) $(APPEND_CFLAGS)" CGO_LDFLAGS="$(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -L$(XEN_libxenlight) -L$(XEN_libxentoollog) $(APPEND_LDFLAGS)" $(GO) build -x
> >  
> >  .PHONY: install
> >  install: build
> > -- 
> > 2.31.1
> > 
> > 
> Acked-by: Nick Rosbrook <rosbrookn@ainfosec.com>

Ping?

Unless someone else has opinions I think this is ready to be
committed. Can a committer please queue it up?

Thanks, Roger.

Re: [PATCH] tools/go: honor append build flags
Posted by Ian Jackson 2 years, 7 months ago
Roger Pau Monné writes ("Re: [PATCH] tools/go: honor append build flags"):
> Unless someone else has opinions I think this is ready to be
> committed. Can a committer please queue it up?

Thanks for the ping.  Committed, with my ack.

Thanks,
Ian.