Openembedded Core Discussions
 help / color / mirror / Atom feed
* [dunfell][PATCH 1/4] go-mod.bbclass: Add class for `go mod` support
@ 2020-06-22 20:02 Khem Raj
  2020-06-22 20:02 ` [dunfell][PATCH 2/4] go.bbclass: Add `-trimpath` to default build flags Khem Raj
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Khem Raj @ 2020-06-22 20:02 UTC (permalink / raw)
  To: openembedded-core; +Cc: Otavio Salvador, Otavio Salvador, Richard Purdie

From: Otavio Salvador <otavio.salvador@gmail.com>

When using Go Modules, the the current working directory MUST be at or
below the location of the 'go.mod' file when the go tool is used, and
there is no way to tell it to look elsewhere.  It will automatically
look upwards for the file, but not downwards.

To support this use case, we provide the `GO_WORKDIR` variable, which
defaults to `GO_IMPORT` but allows for easy override.

[YOCTO #13883]

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/go-mod.bbclass | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 meta/classes/go-mod.bbclass

diff --git a/meta/classes/go-mod.bbclass b/meta/classes/go-mod.bbclass
new file mode 100644
index 0000000000..5871d02506
--- /dev/null
+++ b/meta/classes/go-mod.bbclass
@@ -0,0 +1,20 @@
+# Handle Go Modules support
+#
+# When using Go Modules, the the current working directory MUST be at or below
+# the location of the 'go.mod' file when the go tool is used, and there is no
+# way to tell it to look elsewhere.  It will automatically look upwards for the
+# file, but not downwards.
+#
+# To support this use case, we provide the `GO_WORKDIR` variable, which defaults
+# to `GO_IMPORT` but allows for easy override.
+#
+# Copyright 2020 (C) O.S. Systems Software LTDA.
+
+# The '-modcacherw' option ensures we have write access to the cached objects so
+# we avoid errors during clean task as well as when removing the TMPDIR.
+export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS} -modcacherw"
+
+inherit go
+
+GO_WORKDIR ?= "${GO_IMPORT}"
+do_compile[dirs] += "${B}/src/${GO_WORKDIR}"
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [dunfell][PATCH 2/4] go.bbclass: Add `-trimpath` to default build flags
  2020-06-22 20:02 [dunfell][PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Khem Raj
@ 2020-06-22 20:02 ` Khem Raj
  2020-06-22 20:02 ` [dunfell][PATCH 3/4] go-dep: Avoid use of 'go mod' support Khem Raj
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Khem Raj @ 2020-06-22 20:02 UTC (permalink / raw)
  To: openembedded-core; +Cc: Otavio Salvador, Otavio Salvador, Richard Purdie

From: Otavio Salvador <otavio.salvador@gmail.com>

The `-trimpath` option is important for reproducible builds so full
build paths and module paths are not embedded.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/go.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
index c99689ac59..a9e31b50ea 100644
--- a/meta/classes/go.bbclass
+++ b/meta/classes/go.bbclass
@@ -41,7 +41,7 @@ GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${GO_RPATH_LINK} ${LDFLAGS
 GO_LINKMODE ?= ""
 GO_LINKMODE_class-nativesdk = "--linkmode=external"
 GO_LDFLAGS ?= '-ldflags="${GO_RPATH} ${GO_LINKMODE} -extldflags '${GO_EXTLDFLAGS}'"'
-export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS}"
+export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS} -trimpath"
 export GOPATH_OMIT_IN_ACTIONID ?= "1"
 export GOPTESTBUILDFLAGS ?= "${GOBUILDFLAGS} -c"
 export GOPTESTFLAGS ?= ""
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [dunfell][PATCH 3/4] go-dep: Avoid use of 'go mod' support
  2020-06-22 20:02 [dunfell][PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Khem Raj
  2020-06-22 20:02 ` [dunfell][PATCH 2/4] go.bbclass: Add `-trimpath` to default build flags Khem Raj
@ 2020-06-22 20:02 ` Khem Raj
  2020-06-22 20:02 ` [dunfell][PATCH 4/4] glide: " Khem Raj
  2020-06-22 20:12 ` [OE-core] [dunfell][PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Steve Sakoman
  3 siblings, 0 replies; 6+ messages in thread
From: Khem Raj @ 2020-06-22 20:02 UTC (permalink / raw)
  To: openembedded-core; +Cc: Otavio Salvador, Otavio Salvador, Richard Purdie

From: Otavio Salvador <otavio.salvador@gmail.com>

dep utility must not use 'go mod' support, so we explicitly disable it.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/recipes-devtools/go/go-dep_0.5.4.bb | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/meta/recipes-devtools/go/go-dep_0.5.4.bb b/meta/recipes-devtools/go/go-dep_0.5.4.bb
index 615cb289e5..496224a5cf 100644
--- a/meta/recipes-devtools/go/go-dep_0.5.4.bb
+++ b/meta/recipes-devtools/go/go-dep_0.5.4.bb
@@ -13,6 +13,10 @@ SRCREV = "1f7c19e5f52f49ffb9f956f64c010be14683468b"
 
 inherit go
 
+# New Go versions has Go modules support enabled by default and cause the Glide
+# tool build to fail.
+export GO111MODULE = "off"
+
 GO_INSTALL = "${GO_IMPORT}/cmd/dep"
 
 RDEPENDS_${PN}-dev += "bash"
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [dunfell][PATCH 4/4] glide: Avoid use of 'go mod' support
  2020-06-22 20:02 [dunfell][PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Khem Raj
  2020-06-22 20:02 ` [dunfell][PATCH 2/4] go.bbclass: Add `-trimpath` to default build flags Khem Raj
  2020-06-22 20:02 ` [dunfell][PATCH 3/4] go-dep: Avoid use of 'go mod' support Khem Raj
@ 2020-06-22 20:02 ` Khem Raj
  2020-06-22 20:12 ` [OE-core] [dunfell][PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Steve Sakoman
  3 siblings, 0 replies; 6+ messages in thread
From: Khem Raj @ 2020-06-22 20:02 UTC (permalink / raw)
  To: openembedded-core; +Cc: Otavio Salvador, Otavio Salvador, Richard Purdie

From: Otavio Salvador <otavio.salvador@gmail.com>

Glide utility must not use 'go mod' support, so we explicitly disable
it.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/recipes-devtools/glide/glide_0.13.3.bb | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/meta/recipes-devtools/glide/glide_0.13.3.bb b/meta/recipes-devtools/glide/glide_0.13.3.bb
index ebad0ec60a..31295edf90 100644
--- a/meta/recipes-devtools/glide/glide_0.13.3.bb
+++ b/meta/recipes-devtools/glide/glide_0.13.3.bb
@@ -9,6 +9,10 @@ SRCREV = "8ed5b9292379d86c39592a7e6a58eb9c903877cf"
 
 inherit go
 
+# New Go versions has Go modules support enabled by default and cause the Glide
+# tool build to fail.
+export GO111MODULE = "off"
+
 RDEPENDS_${PN}-dev += "bash"
 RDEPENDS_${PN}-ptest += "bash"
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [OE-core] [dunfell][PATCH 1/4] go-mod.bbclass: Add class for `go mod` support
  2020-06-22 20:02 [dunfell][PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Khem Raj
                   ` (2 preceding siblings ...)
  2020-06-22 20:02 ` [dunfell][PATCH 4/4] glide: " Khem Raj
@ 2020-06-22 20:12 ` Steve Sakoman
  2020-06-22 23:08   ` Khem Raj
  3 siblings, 1 reply; 6+ messages in thread
From: Steve Sakoman @ 2020-06-22 20:12 UTC (permalink / raw)
  To: Khem Raj
  Cc: Patches and discussions about the oe-core layer, Otavio Salvador,
	Otavio Salvador, Richard Purdie

This set of patches is contained in the series I sent out for review
this morning :-)

Steve

On Mon, Jun 22, 2020 at 10:02 AM Khem Raj <raj.khem@gmail.com> wrote:
>
> From: Otavio Salvador <otavio.salvador@gmail.com>
>
> When using Go Modules, the the current working directory MUST be at or
> below the location of the 'go.mod' file when the go tool is used, and
> there is no way to tell it to look elsewhere.  It will automatically
> look upwards for the file, but not downwards.
>
> To support this use case, we provide the `GO_WORKDIR` variable, which
> defaults to `GO_IMPORT` but allows for easy override.
>
> [YOCTO #13883]
>
> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  meta/classes/go-mod.bbclass | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
>  create mode 100644 meta/classes/go-mod.bbclass
>
> diff --git a/meta/classes/go-mod.bbclass b/meta/classes/go-mod.bbclass
> new file mode 100644
> index 0000000000..5871d02506
> --- /dev/null
> +++ b/meta/classes/go-mod.bbclass
> @@ -0,0 +1,20 @@
> +# Handle Go Modules support
> +#
> +# When using Go Modules, the the current working directory MUST be at or below
> +# the location of the 'go.mod' file when the go tool is used, and there is no
> +# way to tell it to look elsewhere.  It will automatically look upwards for the
> +# file, but not downwards.
> +#
> +# To support this use case, we provide the `GO_WORKDIR` variable, which defaults
> +# to `GO_IMPORT` but allows for easy override.
> +#
> +# Copyright 2020 (C) O.S. Systems Software LTDA.
> +
> +# The '-modcacherw' option ensures we have write access to the cached objects so
> +# we avoid errors during clean task as well as when removing the TMPDIR.
> +export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS} -modcacherw"
> +
> +inherit go
> +
> +GO_WORKDIR ?= "${GO_IMPORT}"
> +do_compile[dirs] += "${B}/src/${GO_WORKDIR}"
> --
> 2.27.0
>
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [OE-core] [dunfell][PATCH 1/4] go-mod.bbclass: Add class for `go mod` support
  2020-06-22 20:12 ` [OE-core] [dunfell][PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Steve Sakoman
@ 2020-06-22 23:08   ` Khem Raj
  0 siblings, 0 replies; 6+ messages in thread
From: Khem Raj @ 2020-06-22 23:08 UTC (permalink / raw)
  To: Steve Sakoman
  Cc: Patches and discussions about the oe-core layer, Otavio Salvador,
	Otavio Salvador, Richard Purdie

On Mon, Jun 22, 2020 at 1:13 PM Steve Sakoman <sakoman@gmail.com> wrote:
>
> This set of patches is contained in the series I sent out for review
> this morning :-)

ah even better, Feel free to ignore this series then

>
> Steve
>
> On Mon, Jun 22, 2020 at 10:02 AM Khem Raj <raj.khem@gmail.com> wrote:
> >
> > From: Otavio Salvador <otavio.salvador@gmail.com>
> >
> > When using Go Modules, the the current working directory MUST be at or
> > below the location of the 'go.mod' file when the go tool is used, and
> > there is no way to tell it to look elsewhere.  It will automatically
> > look upwards for the file, but not downwards.
> >
> > To support this use case, we provide the `GO_WORKDIR` variable, which
> > defaults to `GO_IMPORT` but allows for easy override.
> >
> > [YOCTO #13883]
> >
> > Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> > Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> > ---
> >  meta/classes/go-mod.bbclass | 20 ++++++++++++++++++++
> >  1 file changed, 20 insertions(+)
> >  create mode 100644 meta/classes/go-mod.bbclass
> >
> > diff --git a/meta/classes/go-mod.bbclass b/meta/classes/go-mod.bbclass
> > new file mode 100644
> > index 0000000000..5871d02506
> > --- /dev/null
> > +++ b/meta/classes/go-mod.bbclass
> > @@ -0,0 +1,20 @@
> > +# Handle Go Modules support
> > +#
> > +# When using Go Modules, the the current working directory MUST be at or below
> > +# the location of the 'go.mod' file when the go tool is used, and there is no
> > +# way to tell it to look elsewhere.  It will automatically look upwards for the
> > +# file, but not downwards.
> > +#
> > +# To support this use case, we provide the `GO_WORKDIR` variable, which defaults
> > +# to `GO_IMPORT` but allows for easy override.
> > +#
> > +# Copyright 2020 (C) O.S. Systems Software LTDA.
> > +
> > +# The '-modcacherw' option ensures we have write access to the cached objects so
> > +# we avoid errors during clean task as well as when removing the TMPDIR.
> > +export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS} -modcacherw"
> > +
> > +inherit go
> > +
> > +GO_WORKDIR ?= "${GO_IMPORT}"
> > +do_compile[dirs] += "${B}/src/${GO_WORKDIR}"
> > --
> > 2.27.0
> >
> > 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-22 23:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-22 20:02 [dunfell][PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Khem Raj
2020-06-22 20:02 ` [dunfell][PATCH 2/4] go.bbclass: Add `-trimpath` to default build flags Khem Raj
2020-06-22 20:02 ` [dunfell][PATCH 3/4] go-dep: Avoid use of 'go mod' support Khem Raj
2020-06-22 20:02 ` [dunfell][PATCH 4/4] glide: " Khem Raj
2020-06-22 20:12 ` [OE-core] [dunfell][PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Steve Sakoman
2020-06-22 23:08   ` Khem Raj

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox