cni: fix textrel QA issue

When building cni, we get textrel QA issue like below:

  cni: ELF binary /usr/libexec/cni/macvlan has relocations in .text

The problem could be solved by adding '-buildmode=pie' to ${GO}.

In go.bbclass, this flag is added to GOBUILDFLAGS conditionally,
that is, if the arch is not mips nor riscv32, this '-buildmode=pie'
is added to GOBUILDFLAGS. So make use of that.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
This commit is contained in:
Chen Qi 2023-12-11 10:53:19 +01:00 committed by Bruce Ashfield
parent 2efdfa20a4
commit 33f31493ed

View File

@ -39,10 +39,10 @@ do_compile() {
export GO111MODULE=off
cd ${B}/src/github.com/containernetworking/cni/libcni
${GO} build -trimpath
${GO} build ${GOBUILDFLAGS}
cd ${B}/src/github.com/containernetworking/cni/cnitool
${GO} build -trimpath
${GO} build ${GOBUILDFLAGS}
cd ${B}/src/github.com/containernetworking/plugins
PLUGINS="$(ls -d plugins/meta/*; ls -d plugins/ipam/*; ls -d plugins/main/* | grep -v windows)"
@ -50,7 +50,7 @@ do_compile() {
for p in $PLUGINS; do
plugin="$(basename "$p")"
echo "building: $p"
${GO} build -trimpath -o ${B}/plugins/bin/$plugin github.com/containernetworking/plugins/$p
${GO} build ${GOBUILDFLAGS} -o ${B}/plugins/bin/$plugin github.com/containernetworking/plugins/$p
done
}