Skip to contentSkip to conversation

goarch: map target os to windows for mingw* TARGET_OS

PATCH In review Peter Morrow 2 participants 5 messages Apr 6, 2021 – Apr 9, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 goarch: map target os to windows for mingw* TARGET_OS

mingw32/mingw64 is not a supported value for GOOS, so map from 'mingw*' to 'windows' to enable building for windows targets.

---
 meta/classes/goarch.bbclass | 2 ++
 1 file changed, 2 insertions(+)
meta/classes/goarch.bbclass +2 -0
index 1099b95..ecd3044 100644
@@ -114,6 +114,8 @@ def go_map_mips(a, f, d):
 def go_map_os(o, d):
     if o.startswith('linux'):
         return 'linux'
+    elif o.startswith('mingw'):
+        return 'windows'
     return o
 
 
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 2/2 go_1.14: don't set -buildmode=pie when building for windows targets

go 1.14 for windows targets does not support -buildmode=pie, disable it and use the default buildmode instead. Support for -buildmode=pie for windows targets is added with go 1.15 (https://golang.org/doc/go1.15) which is added to poky in gatesgarth.

---
 meta/classes/go.bbclass             | 8 ++++----
 meta/recipes-devtools/go/go_1.14.bb | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)
meta/classes/go.bbclass +4 -4
index a9e31b5..8ff482b 100644
@@ -144,11 +144,11 @@ FILES_${PN}-staticdev = "${libdir}/go/pkg"
 
 INSANE_SKIP_${PN} += "ldflags"
 
-# Add -buildmode=pie to GOBUILDFLAGS to satisfy "textrel" QA checking, but mips
-# doesn't support -buildmode=pie, so skip the QA checking for mips and its
-# variants.
+# Add -buildmode=pie to GOBUILDFLAGS to satisfy "textrel" QA checking, but
+# windows/mips/riscv doesn't support -buildmode=pie, so skip the QA checking
+# for windows/mips/riscv and their variants.
 python() {
-    if 'mips' in d.getVar('TARGET_ARCH') or 'riscv' in d.getVar('TARGET_ARCH'):
+    if 'mips' in d.getVar('TARGET_ARCH') or 'riscv' in d.getVar('TARGET_ARCH') or 'windows' in d.getVar('TARGET_GOOS'):
         d.appendVar('INSANE_SKIP_%s' % d.getVar('PN'), " textrel")
     else:
         d.appendVar('GOBUILDFLAGS', ' -buildmode=pie')
meta/recipes-devtools/go/go_1.14.bb +4 -4
index bc90a13..c175279 100644
@@ -3,11 +3,11 @@ require go-target.inc
 
 export GOBUILDMODE=""
 export CGO_ENABLED_riscv64 = ""
-# Add pie to GOBUILDMODE to satisfy "textrel" QA checking, but mips/riscv
-# doesn't support -buildmode=pie, so skip the QA checking for mips/riscv and its
-# variants.
+# Add pie to GOBUILDMODE to satisfy "textrel" QA checking, but
+# windows/mips/riscv doesn't support -buildmode=pie, so skip the QA checking
+# for windows/mips/riscv and their variants.
 python() {
-    if 'mips' in d.getVar('TARGET_ARCH',True) or 'riscv' in d.getVar('TARGET_ARCH',True):
+    if 'mips' in d.getVar('TARGET_ARCH',True) or 'riscv' in d.getVar('TARGET_ARCH',True) or 'windows' in d.getVar('TARGET_GOOS', True):
         d.appendVar('INSANE_SKIP_%s' % d.getVar('PN',True), " textrel")
     else:
         d.setVar('GOBUILDMODE', 'pie')
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [dunfell][PATCH 2/2] go_1.14: don't set -buildmode=pie when building for windows targets

This looks good to me

Quoted 67 lines · Peter Morrow

go 1.14 for windows targets does not support -buildmode=pie, disable it and use
the default buildmode instead. Support for -buildmode=pie for windows targets
is added with go 1.15 (https://golang.org/doc/go1.15) which is added to poky in
gatesgarth.

---
 meta/classes/go.bbclass             | 8 ++++----
 meta/recipes-devtools/go/go_1.14.bb | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)
meta/classes/go.bbclass +0 -1
index a9e31b5..8ff482b 100644
@@ -144,11 +144,11 @@ FILES_${PN}-staticdev = "${libdir}/go/pkg"
 
 INSANE_SKIP_${PN} += "ldflags"
 
-# Add -buildmode=pie to GOBUILDFLAGS to satisfy "textrel" QA checking,

but mips

meta/classes/go.bbclass +2 -2
-# doesn't support -buildmode=pie, so skip the QA checking for mips and its
-# variants.
+# Add -buildmode=pie to GOBUILDFLAGS to satisfy "textrel" QA checking, but
+# windows/mips/riscv doesn't support -buildmode=pie, so skip the QA

checking

meta/classes/go.bbclass +1 -1
+# for windows/mips/riscv and their variants.
 python() {
-    if 'mips' in d.getVar('TARGET_ARCH') or 'riscv' in

d.getVar('TARGET_ARCH'):
+ if 'mips' in d.getVar('TARGET_ARCH') or 'riscv' in
d.getVar('TARGET_ARCH') or 'windows' in d.getVar('TARGET_GOOS'):
d.appendVar('INSANE_SKIP_%s' % d.getVar('PN'), " textrel")
else:
d.appendVar('GOBUILDFLAGS', ' -buildmode=pie')

meta/recipes-devtools/go/go_1.14.bb +0 -2
index bc90a13..c175279 100644
@@ -3,11 +3,11 @@ require go-target.inc
 
 export GOBUILDMODE=""
 export CGO_ENABLED_riscv64 = ""
-# Add pie to GOBUILDMODE to satisfy "textrel" QA checking, but mips/riscv
-# doesn't support -buildmode=pie, so skip the QA checking for mips/riscv

and its

meta/recipes-devtools/go/go_1.14.bb +2 -1
-# variants.
+# Add pie to GOBUILDMODE to satisfy "textrel" QA checking, but
+# windows/mips/riscv doesn't support -buildmode=pie, so skip the QA

checking

meta/recipes-devtools/go/go_1.14.bb +1 -1
+# for windows/mips/riscv and their variants.
 python() {
-    if 'mips' in d.getVar('TARGET_ARCH',True) or 'riscv' in

d.getVar('TARGET_ARCH',True):
+ if 'mips' in d.getVar('TARGET_ARCH',True) or 'riscv' in
d.getVar('TARGET_ARCH',True) or 'windows' in d.getVar('TARGET_GOOS', True):

         d.appendVar('INSANE_SKIP_%s' % d.getVar('PN',True), " textrel")
     else:
         d.setVar('GOBUILDMODE', 'pie')

--
1.8.3.1

#3 lore raw
In reply to Peter Morrow

Lgtm

Quoted 25 lines · Peter Morrow

mingw32/mingw64 is not a supported value for GOOS, so map from 'mingw*' to 'windows' to enable building for windows targets.

---
 meta/classes/goarch.bbclass | 2 ++
 1 file changed, 2 insertions(+)
meta/classes/goarch.bbclass +2 -1
index 1099b95..ecd3044 100644
@@ -114,6 +114,8 @@ def go_map_mips(a, f, d):
 def go_map_os(o, d):
     if o.startswith('linux'):
         return 'linux'
+    elif o.startswith('mingw'):
+        return 'windows'
     return o
 
 
--

1.8.3.1

#4 lore raw
Quoted 1 line · Khem Raj

Lgtm

Thanks Khem!

Peter.

Quoted 29 lines
Quoted 25 lines · Peter Morrow

mingw32/mingw64 is not a supported value for GOOS, so map from 'mingw*' to 'windows' to enable building for windows targets.

---
 meta/classes/goarch.bbclass | 2 ++
 1 file changed, 2 insertions(+)
meta/classes/goarch.bbclass +2 -1
index 1099b95..ecd3044 100644
@@ -114,6 +114,8 @@ def go_map_mips(a, f, d):
 def go_map_os(o, d):
     if o.startswith('linux'):
         return 'linux'
+    elif o.startswith('mingw'):
+        return 'windows'
     return o
 
 
--

1.8.3.1