summaryrefslogtreecommitdiffstats
path: root/recipes-networking/netns
diff options
context:
space:
mode:
authorMark Asselstine <mark.asselstine@windriver.com>2019-03-18 14:48:55 -0400
committerBruce Ashfield <bruce.ashfield@gmail.com>2019-03-20 14:42:42 -0400
commitfb524ca5a228b58c3feb048956c5f0713f6cea45 (patch)
tree4819010c1d7bd951b68a517307c15c04151f3ffa /recipes-networking/netns
parenta1528f85a679b11b71e0b1da9df3363d21c0a48a (diff)
downloadmeta-virtualization-fb524ca5a228b58c3feb048956c5f0713f6cea45.tar.gz
netns: change build target to 'build' instead of 'static'
Attempting to build for x86-64 will result in an error: cannot find package runtime/cgo (using -importcfg) ...go/pkg/tool/linux_amd64/link: cannot open file : open : no such file or directory As a workaround we switch the build target to 'build' which results in a slightly smaller executable but does mean that several dynamic libraries are required to run the generated executable. This shouldn't be a problem as the build system will ensure the libraries are present on images where the executable will be included. This change only means the executable can't be copied as a single entity to a different machine and run. We do also patch the Makefile to allow the 'static' target to build successfully and in the patch commit log we describe the issue in full (at least in as much detail as we currently have on the issue). But since the issue isn't fully understood we don't recommend the 'static' build to be used at this time, thus default to the 'build' target. Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'recipes-networking/netns')
-rw-r--r--recipes-networking/netns/files/Makefile-force-rebuilding-all-packages-to-avoid-cgo.patch54
-rw-r--r--recipes-networking/netns/netns_git.bb5
2 files changed, 58 insertions, 1 deletions
diff --git a/recipes-networking/netns/files/Makefile-force-rebuilding-all-packages-to-avoid-cgo.patch b/recipes-networking/netns/files/Makefile-force-rebuilding-all-packages-to-avoid-cgo.patch
new file mode 100644
index 00000000..3b0c0a46
--- /dev/null
+++ b/recipes-networking/netns/files/Makefile-force-rebuilding-all-packages-to-avoid-cgo.patch
@@ -0,0 +1,54 @@
1From 09524d187ef108784c854a0c247ac6476a10bb67 Mon Sep 17 00:00:00 2001
2From: Mark Asselstine <mark.asselstine@windriver.com>
3Date: Mon, 18 Mar 2019 14:04:16 -0400
4Subject: [PATCH] Makefile: force rebuilding all packages to avoid cgo
5
6We are running into an issue when attempting to build 'static',
7similar to what is described by
8
9https://plus.google.com/117192131596509381660/posts/eNnNePihYnK
10and
11https://github.com/golang/go/issues/9369
12
13In our case we can see that it manifests as a build error
14
15 cannot find package runtime/cgo (using -importcfg)
16 ...go/pkg/tool/linux_amd64/link: cannot open file : open : no such file or directory
17
18Although the descriptions of issue indicate that newer versions of GO,
19such as the version we are using, should not have this issue it is
20clear from the error that cgo is being referenced when it should be
21out of the picture.
22
23Interesting enough this issue only manifests when we are building on
24x86-64 and building for x86-64 which might indicate that GO might be
25finding -native packages and not -cross packages.
26
27This change works around the issue and will allow for the building of
28the 'static' make target, but at this time and until the issue is
29completely understood, it is recommended that the 'build' target is
30used.
31
32Upstream-Status: Inappropriate [only an issue with our builds]
33
34Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
35---
36 Makefile | 2 +-
37 1 file changed, 1 insertion(+), 1 deletion(-)
38
39diff --git a/Makefile b/Makefile
40index 476cb9b..ecd0df4 100644
41--- a/src/import/Makefile
42+++ b/src/import/Makefile
43@@ -41,7 +41,7 @@ $(NAME): *.go VERSION.txt
44 .PHONY: static
45 static: ## Builds a static executable
46 @echo "+ $@"
47- CGO_ENABLED=0 $(GO) build \
48+ CGO_ENABLED=0 $(GO) build -a -pkgdir dontusecurrentpkgs \
49 -tags "$(BUILDTAGS) static_build" \
50 ${GO_LDFLAGS_STATIC} -o $(NAME) .
51
52--
532.7.4
54
diff --git a/recipes-networking/netns/netns_git.bb b/recipes-networking/netns/netns_git.bb
index b6d35948..f5cdace0 100644
--- a/recipes-networking/netns/netns_git.bb
+++ b/recipes-networking/netns/netns_git.bb
@@ -5,6 +5,7 @@ LIC_FILES_CHKSUM = "file://src/import/LICENSE;md5=48ef0979a2bcc3fae14ff30b8a7f5d
5 5
6SRC_URI = "git://github.com/genuinetools/netns;branch=master \ 6SRC_URI = "git://github.com/genuinetools/netns;branch=master \
7 file://0001-Allow-selection-of-go-compiler.patch \ 7 file://0001-Allow-selection-of-go-compiler.patch \
8 file://Makefile-force-rebuilding-all-packages-to-avoid-cgo.patch \
8 " 9 "
9SRCREV = "0da6ab0997707024debe68c91e940c9168041bf8" 10SRCREV = "0da6ab0997707024debe68c91e940c9168041bf8"
10PV = "0.4.0" 11PV = "0.4.0"
@@ -42,7 +43,9 @@ do_compile() {
42 export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" 43 export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
43 44
44 cd ${S}/src/import 45 cd ${S}/src/import
45 oe_runmake static 46 # Static builds work but are not recommended. See Makefile*cgo patch.
47 #oe_runmake static
48 oe_runmake build
46} 49}
47 50
48do_install() { 51do_install() {