From 42c39d9d57b076d8a6ef0ed6656e2acb18cf82a7 Mon Sep 17 00:00:00 2001
From: Pavel Zhukov <pavel.zhukov@huawei.com>
Date: Thu, 23 Jun 2022 22:07:57 +0200
Subject: [PATCH] sysota: fix static linking with clang

When sysota is built with toolchain-clang broken dynamicaly linked
binary file is produced even if GO_DYNLINK is disabled. This can be
fixed with specifying external linker for clang toolchain (by default Go
swutched to internal linker if -pie has been specified since version
1.15). Limiting this change to clang only to be safe.

Fixes:
Subprocess output:x86_64-oniro-linux-llvm-strip: error: SHT_STRTAB
        string table section [index 7] is non-null terminated

Fixes: #624

Signed-off-by: Pavel Zhukov <pavel.zhukov@huawei.com>
---
 meta-oniro-core/recipes-core/sysota/sysota_git.bb | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta-oniro-core/recipes-core/sysota/sysota_git.bb b/meta-oniro-core/recipes-core/sysota/sysota_git.bb
index 99307391..5c1afe84 100644
--- a/meta-oniro-core/recipes-core/sysota/sysota_git.bb
+++ b/meta-oniro-core/recipes-core/sysota/sysota_git.bb
@@ -19,6 +19,8 @@ GO_DYNLINK:x86 = ""
 GO_DYNLINK:x86-64 = ""
 GO_DYNLINK:arm = ""
 GO_DYNLINK:aarch64 = ""
+GO_LINKMODE:toolchain-clang  ?= "-linkmode external"
+GO_EXTLDFLAGS:toolchain-clang:append = " -static "
 
 # This package is built with go-mod as well as with make.
 #
-- 
GitLab