Skip to contentSkip to conversation

oeqa/gotoolchain: put writable files in the Go module cache

PATCH New Ross Burton 1 participant 2 messages Jul 25, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 oeqa/gotoolchain: put writable files in the Go module cache

By default 'go mod' creates read-only files, but that just complicates things. Add -modcacherw to make the cache read/write, so it can be cleaned up without needing to chmod.

---
 meta/lib/oeqa/selftest/cases/gotoolchain.py | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
meta/lib/oeqa/selftest/cases/gotoolchain.py +1 -6
index c809d7c9b14..345f533379c 100644
@@ -43,12 +43,6 @@ class oeGoToolchainSelfTest(OESelftestTestCase):
 
     @classmethod
     def tearDownClass(cls):
-        # Go creates file which are readonly
-        for dirpath, dirnames, filenames in os.walk(cls.tmpdir_SDKQA):
-            for filename in filenames + dirnames:
-                f = os.path.join(dirpath, filename)
-                if not os.path.islink(f):
-                    os.chmod(f, 0o775)
         shutil.rmtree(cls.tmpdir_SDKQA, ignore_errors=True)
         super(oeGoToolchainSelfTest, cls).tearDownClass()
 
@@ -56,6 +50,7 @@ class oeGoToolchainSelfTest(OESelftestTestCase):
         cmd = "cd %s/src/%s/%s; " % (self.go_path, proj, name)
         cmd = cmd + ". %s; " % self.env_SDK
         cmd = cmd + "export GOPATH=%s; " % self.go_path
+        cmd = cmd + "export GOFLAGS=-modcacherw; "
         cmd = cmd + "${CROSS_COMPILE}go %s" % gocmd
         return runCmd(cmd).status
 
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 oeqa/gotoolchain: set CGO_ENABLED=1

In cross-compiles CGO_ENABLED=1 needs to be set explicitly, as otherwise Go refuses to use it even if CC is already set.

This fixes the selftest on setups where the host and the SDK target don't have matching architectures.

[ YOCTO #14859 ]

---
 meta/lib/oeqa/selftest/cases/gotoolchain.py | 1 +
 1 file changed, 1 insertion(+)
meta/lib/oeqa/selftest/cases/gotoolchain.py +1 -0
index 345f533379c..978898b86f1 100644
@@ -51,6 +51,7 @@ class oeGoToolchainSelfTest(OESelftestTestCase):
         cmd = cmd + ". %s; " % self.env_SDK
         cmd = cmd + "export GOPATH=%s; " % self.go_path
         cmd = cmd + "export GOFLAGS=-modcacherw; "
+        cmd = cmd + "export CGO_ENABLED=1; "
         cmd = cmd + "${CROSS_COMPILE}go %s" % gocmd
         return runCmd(cmd).status
 
Signature · 1 line
2.34.1