[meta-virtualization] [PATCH 1/2] cni: fix problem about cross compilation

Bruce Ashfield bruce.ashfield at gmail.com
Fri Aug 9 07:21:05 PDT 2019


On Fri, Aug 9, 2019 at 5:37 AM Chen Qi <Qi.Chen at windriver.com> wrote:

> When setting up k8s, the following error appeared, failing
> to setup coredns pod.
>
>   NetworkPlugin cni failed to set up pod
> "coredns-5f7fc64c95-4nnfq_kube-system" network: fork/exec
> /opt/cni/bin/loopback: no such file or directory
>
> This is because the binary, /opt/cni/bin/loopback, has wrong interpreter.
>
> So fix do_compile to use ${GO} instead of go to fix this problem.
>
> Also clean up all unnecessary settings which have already been in
> go.bbclass.
>

These need to be separate patches.

In particular, I want the CGO_ENABLED flag to remain, as well as GOPATH,
since on uprev, I'm constantly tweaking them.

Bruce


>
> Signed-off-by: Chen Qi <Qi.Chen at windriver.com>
> ---
>  recipes-networking/cni/cni_git.bb | 25 +++----------------------
>  1 file changed, 3 insertions(+), 22 deletions(-)
>
> diff --git a/recipes-networking/cni/cni_git.bb b/recipes-networking/cni/
> cni_git.bb
> index d07154b..f392ea6 100644
> --- a/recipes-networking/cni/cni_git.bb
> +++ b/recipes-networking/cni/cni_git.bb
> @@ -29,18 +29,6 @@ inherit go
>  inherit goarch
>
>  do_compile() {
> -       export GOARCH="${TARGET_GOARCH}"
> -       export GOROOT="${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go"
> -       export GOPATH="${S}/src/import:${S}/src/import/vendor"
> -
> -       # Pass the needed cflags/ldflags so that cgo
> -       # can find the needed headers files and libraries
> -       export CGO_ENABLED="1"
> -       export CFLAGS=""
> -       export LDFLAGS=""
> -       export CGO_CFLAGS="${BUILDSDK_CFLAGS}
> --sysroot=${STAGING_DIR_TARGET}"
> -       export CGO_LDFLAGS="${BUILDSDK_LDFLAGS}
> --sysroot=${STAGING_DIR_TARGET}"
> -
>         # link fixups for compilation
>         rm -f ${S}/src/import/vendor/src
>         mkdir -p ${S}/src/import/vendor/
> @@ -56,19 +44,12 @@ do_compile() {
>         ln -sf ${WORKDIR}/plugins ${S}/src/import/vendor/
> github.com/containernetworking/plugins
>
>         export
> GOPATH="${S}/src/import/.gopath:${S}/src/import/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go"
> -       export
> GOROOT="${STAGING_DIR_NATIVE}/${nonarch_libdir}/${HOST_SYS}/go"
> -
> -       # Pass the needed cflags/ldflags so that cgo
> -       # can find the needed headers files and libraries
> -       export CGO_ENABLED="1"
> -       export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
> -       export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
>
>         cd ${S}/src/import/vendor/
> github.com/containernetworking/cni/libcni
> -       go build
> +       ${GO} build
>
>         cd ${S}/src/import/vendor/
> github.com/containernetworking/cni/cnitool
> -       go build
> +       ${GO} build
>
>         cd ${S}/src/import/vendor/github.com/containernetworking/plugins/
>         PLUGINS="$(ls -d plugins/meta/*; ls -d plugins/main/* | grep -v
> windows)"
> @@ -76,7 +57,7 @@ do_compile() {
>         for p in $PLUGINS; do
>             plugin="$(basename "$p")"
>             echo "building: $p"
> -           go build -o ${WORKDIR}/plugins/bin/$plugin
> github.com/containernetworking/plugins/$p
> +           ${GO} build -o ${WORKDIR}/plugins/bin/$plugin
> github.com/containernetworking/plugins/$p
>         done
>  }
>
> --
> 2.17.1
>
> --
> _______________________________________________
> meta-virtualization mailing list
> meta-virtualization at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/meta-virtualization
>


-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/meta-virtualization/attachments/20190809/89d5c10a/attachment-0001.html>


More information about the meta-virtualization mailing list