On Fri, 2026-05-15 at 10:41 +0800, Changqing Li via
lists.openembedded.org wrote:
> Add a go example recipe with cgo enabled. This is for covering
> go reproducibility with cgo enabled. Related to the following commit [1]:
> [0642d23230 go.bbclass: change GOTMPDIR to improve reproducibility]
> 
> [1] 
> https://git.openembedded.org/openembedded-core/commit/?id=0642d2323072f561a4d0eeb9266213387b2997fc
> 
> [YOCTO #16100]
> 
> Signed-off-by: Changqing Li <[email protected]>
> ---
>  meta/conf/distro/include/maintainers.inc      |  1 +
>  .../cgo-helloworld/cgo-helloworld.go          |  9 ++++++++
>  .../go-examples/cgo-helloworld_1.0.bb         | 23 +++++++++++++++++++
>  3 files changed, 33 insertions(+)
>  create mode 100644 
> meta/recipes-extended/go-examples/cgo-helloworld/cgo-helloworld.go
>  create mode 100644 meta/recipes-extended/go-examples/cgo-helloworld_1.0.bb
> 
> diff --git a/meta/conf/distro/include/maintainers.inc 
> b/meta/conf/distro/include/maintainers.inc
> index 24c5a9d712..b72cbe7c93 100644
> --- a/meta/conf/distro/include/maintainers.inc
> +++ b/meta/conf/distro/include/maintainers.inc
> @@ -97,6 +97,7 @@ RECIPE_MAINTAINER:pn-cargo = "Randy MacLeod 
> <[email protected]>"
>  RECIPE_MAINTAINER:pn-cargo-c = "Deepesh Varatharajan 
> <[email protected]>"
>  RECIPE_MAINTAINER:pn-ccache = "Robert Yang <[email protected]>"
>  RECIPE_MAINTAINER:pn-cdrtools-native = "Yi Zhao <[email protected]>"
> +RECIPE_MAINTAINER:pn-cgo-helloworld = "Changqing Li 
> <[email protected]>"
>  RECIPE_MAINTAINER:pn-chrpath = "Yi Zhao <[email protected]>"
>  RECIPE_MAINTAINER:pn-clang = "Khem Raj <[email protected]>"
>  RECIPE_MAINTAINER:pn-clang-cross-${TARGET_ARCH} = "Khem Raj 
> <[email protected]>"
> diff --git 
> a/meta/recipes-extended/go-examples/cgo-helloworld/cgo-helloworld.go 
> b/meta/recipes-extended/go-examples/cgo-helloworld/cgo-helloworld.go
> new file mode 100644
> index 0000000000..4eb052a09e
> --- /dev/null
> +++ b/meta/recipes-extended/go-examples/cgo-helloworld/cgo-helloworld.go
> @@ -0,0 +1,9 @@
> +package main
> +
> +// #include <stdio.h>
> +// void hello() { printf("Hello, World!\n"); }
> +import "C"
> +
> +func main() {
> +     C.hello()
> +}
> diff --git a/meta/recipes-extended/go-examples/cgo-helloworld_1.0.bb 
> b/meta/recipes-extended/go-examples/cgo-helloworld_1.0.bb
> new file mode 100644
> index 0000000000..9ca1e16c7a
> --- /dev/null
> +++ b/meta/recipes-extended/go-examples/cgo-helloworld_1.0.bb
> @@ -0,0 +1,23 @@
> +SUMMARY = "A simple CGO example that calls C to print hello world"
> +SECTION = "examples"
> +HOMEPAGE = "https://golang.org/";
> +
> +LICENSE = "MIT"
> +LIC_FILES_CHKSUM = 
> "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
> +
> +SRC_URI = "file://cgo-helloworld.go"
> +
> +S = "${UNPACKDIR}"
> +
> +GO_IMPORT = "cgo-helloworld"
> +GO_INSTALL = "${GO_IMPORT}"
> +
> +inherit go
> +
> +export GO111MODULE = "off"
> +export CGO_ENABLED = "1"
> +
> +do_configure:prepend() {
> +    mkdir -p ${S}/src/${GO_IMPORT}
> +    cp ${UNPACKDIR}/cgo-helloworld.go ${S}/src/${GO_IMPORT}/main.go
> +}

Hi Changqing,

Please could you add a selftest case which checks that this recipe can
be built? I think this should be added in the existing file
meta/lib/oeqa/selftest/cases/gotoolchain.py.

Best regards,

-- 
Paul Barker

Attachment: signature.asc
Description: This is a digitally signed message part

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#237203): 
https://lists.openembedded.org/g/openembedded-core/message/237203
Mute This Topic: https://lists.openembedded.org/mt/119324500/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to