Skip to contentSkip to conversation

microsoft-cpr: add new recipe including ptest

PATCH Superseded Peter Marko 2 participants 8 messages Mar 26, 2024 – Apr 2, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 microsoft-cpr: add new recipe including ptest

From: Peter Marko <[email protected]>

The Guidelines Support Library (GSL) contains functions and types that are suggested for use by the C++ Core Guidelines maintained by the Standard C++ Foundation.
This repo contains Microsoft's implementation of GSL.

---
 .../include/ptest-packagelists-meta-oe.inc    |  1 +
 .../packagegroups/packagegroup-meta-oe.bb     |  1 +
 .../microsoft-gsl/microsoft-gsl/run-ptest     |  4 +++
 .../microsoft-gsl/microsoft-gsl_4.0.0.bb      | 36 +++++++++++++++++++
 4 files changed, 42 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/run-ptest
 create mode 100644 meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl_4.0.0.bb
meta-oe/conf/include/ptest-packagelists-meta-oe.inc +1 -0
index fadec1221..70e5dad08 100644
@@ -27,6 +27,7 @@ PTESTS_FAST_META_OE = "\
     libxml++-5.0 \
     libyang \
     lmdb \
+    microsoft-gsl \
     minicoredumper \
     neon \
     nlohmann-json \
meta-oe/recipes-core/packagegroups/packagegroup-meta-oe.bb +1 -0
index 6e2012dae..bc15373b6 100644
@@ -310,6 +310,7 @@ RDEPENDS:packagegroup-meta-oe-devtools ="\
     yasm \
     json-schema-validator \
     poke \
+    microsoft-gsl \
 "
 RDEPENDS:packagegroup-meta-oe-devtools:append:x86 = " cpuid msr-tools pahole pmtools"
 RDEPENDS:packagegroup-meta-oe-devtools:append:x86-64 = " cpuid msr-tools pahole pcimem pmtools"
meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/run-ptest new file +4 -0
new file mode 100644
index 000000000..2d5bdf4ff
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+gsl_tests && echo "PASS: gsl_tests" || echo "FAIL: gsl_tests"
+gsl_noexcept_tests && echo "PASS: gsl_noexcept_tests" || echo "FAIL: gsl_noexcept_tests"
meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl_4.0.0.bb new file +36 -0
new file mode 100644
index 000000000..d07430709
@@ -0,0 +1,36 @@
+SUMMARY = "GSL: Guidelines Support Library"
+DESCRIPTION = "The Guidelines Support Library (GSL) contains functions \
+    and types that are suggested for use by the C++ Core Guidelines \
+    maintained by the Standard C++ Foundation. \
+    This repo contains Microsoft's implementation of GSL."
+HOMEPAGE = "https://github.com/microsoft/GSL"
+
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=363055e71e77071107ba2bb9a54bd9a7"
+
+SRC_URI = "git://github.com/microsoft/GSL.git;protocol=https;branch=main \
+    file://run-ptest"
+SRCREV = "a3534567187d2edc428efd3f13466ff75fe5805c"
+
+S = "${WORKDIR}/git"
+
+inherit cmake pkgconfig ptest
+
+# this is header-only library
+ALLOW_EMPTY:${PN} = "1"
+
+PACKAGECONFIG ??= "${@bb.utils.contains('PTEST_ENABLED', '1', 'ptest','', d)}"
+PACKAGECONFIG[ptest] = "-DGSL_TEST=ON,-DGSL_TEST=OFF,googletest"
+
+do_install_ptest() {
+    install -d ${D}${bindir}
+    install -m 0755 ${B}/tests/gsl_tests ${D}${bindir}
+    install -m 0755 ${B}/tests/gsl_noexcept_tests ${D}${bindir}
+}
+
+FILES:${PN}-ptest = "${bindir}/gsl*_tests"
+
+# there is already other gsl recipe, so recipe name does not match the real component name
+CVE_PRODUCT = "microsoft:gsl"
+
+BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.30.2
#1 lore raw

fails build with clang - https://errors.yoctoproject.org/Errors/Details/761058/

Quoted 106 lines · Peter Marko via lists.openembedded.org

From: Peter Marko <[email protected]>

The Guidelines Support Library (GSL) contains functions and types that are suggested for use by the C++ Core Guidelines maintained by the Standard C++ Foundation.
This repo contains Microsoft's implementation of GSL.

---
 .../include/ptest-packagelists-meta-oe.inc    |  1 +
 .../packagegroups/packagegroup-meta-oe.bb     |  1 +
 .../microsoft-gsl/microsoft-gsl/run-ptest     |  4 +++
 .../microsoft-gsl/microsoft-gsl_4.0.0.bb      | 36 +++++++++++++++++++
 4 files changed, 42 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/run-ptest
 create mode 100644 meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl_4.0.0.bb
meta-oe/conf/include/ptest-packagelists-meta-oe.inc +1 -0
index fadec1221..70e5dad08 100644
@@ -27,6 +27,7 @@ PTESTS_FAST_META_OE = "\
     libxml++-5.0 \
     libyang \
     lmdb \
+    microsoft-gsl \
     minicoredumper \
     neon \
     nlohmann-json \
meta-oe/recipes-core/packagegroups/packagegroup-meta-oe.bb +1 -0
index 6e2012dae..bc15373b6 100644
@@ -310,6 +310,7 @@ RDEPENDS:packagegroup-meta-oe-devtools ="\
     yasm \
     json-schema-validator \
     poke \
+    microsoft-gsl \
 "
 RDEPENDS:packagegroup-meta-oe-devtools:append:x86 = " cpuid msr-tools pahole pmtools"
 RDEPENDS:packagegroup-meta-oe-devtools:append:x86-64 = " cpuid msr-tools pahole pcimem pmtools"
meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/run-ptest new file +4 -0
new file mode 100644
index 000000000..2d5bdf4ff
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+gsl_tests && echo "PASS: gsl_tests" || echo "FAIL: gsl_tests"
+gsl_noexcept_tests && echo "PASS: gsl_noexcept_tests" || echo "FAIL: gsl_noexcept_tests"
meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl_4.0.0.bb new file +36 -1
new file mode 100644
index 000000000..d07430709
@@ -0,0 +1,36 @@
+SUMMARY = "GSL: Guidelines Support Library"
+DESCRIPTION = "The Guidelines Support Library (GSL) contains functions \
+    and types that are suggested for use by the C++ Core Guidelines \
+    maintained by the Standard C++ Foundation. \
+    This repo contains Microsoft's implementation of GSL."
+HOMEPAGE = "https://github.com/microsoft/GSL"
+
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=363055e71e77071107ba2bb9a54bd9a7"
+
+SRC_URI = "git://github.com/microsoft/GSL.git;protocol=https;branch=main \
+    file://run-ptest"
+SRCREV = "a3534567187d2edc428efd3f13466ff75fe5805c"
+
+S = "${WORKDIR}/git"
+
+inherit cmake pkgconfig ptest
+
+# this is header-only library
+ALLOW_EMPTY:${PN} = "1"
+
+PACKAGECONFIG ??= "${@bb.utils.contains('PTEST_ENABLED', '1', 'ptest','', d)}"
+PACKAGECONFIG[ptest] = "-DGSL_TEST=ON,-DGSL_TEST=OFF,googletest"
+
+do_install_ptest() {
+    install -d ${D}${bindir}
+    install -m 0755 ${B}/tests/gsl_tests ${D}${bindir}
+    install -m 0755 ${B}/tests/gsl_noexcept_tests ${D}${bindir}
+}
+
+FILES:${PN}-ptest = "${bindir}/gsl*_tests"
+
+# there is already other gsl recipe, so recipe name does not match the real component name
+CVE_PRODUCT = "microsoft:gsl"
+
+BBCLASSEXTEND = "native nativesdk"
--

2.30.2

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

#2 lore raw

PATCH v3 1/1 microsoft-gsl: add new recipe including ptest

From: Peter Marko <[email protected]>

The Guidelines Support Library (GSL) contains functions and types that are suggested for use by the C++ Core Guidelines maintained by the Standard C++ Foundation.
This repo contains Microsoft's implementation of GSL.

---
v2: adapt conditional ptest clauses per review comments
v3: fix clang build

 .../include/ptest-packagelists-meta-oe.inc    |   1 +
 .../packagegroups/packagegroup-meta-oe.bb     |   1 +
 ...0001-Fix-initialization-in-test-1140.patch | 113 ++++++++++++++++++
 .../0002-Fix-gcc-build-problem.patch          |  82 +++++++++++++
 ...eck_cxx_compiler_flag-to-cmake-3.0.2.patch |  53 ++++++++
 .../microsoft-gsl/microsoft-gsl/run-ptest     |   4 +
 .../microsoft-gsl/microsoft-gsl_4.0.0.bb      |  43 +++++++
 7 files changed, 297 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0001-Fix-initialization-in-test-1140.patch
 create mode 100644 meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0002-Fix-gcc-build-problem.patch
 create mode 100644 meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0003-Adapt-check_cxx_compiler_flag-to-cmake-3.0.2.patch
 create mode 100644 meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/run-ptest
 create mode 100644 meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl_4.0.0.bb
meta-oe/conf/include/ptest-packagelists-meta-oe.inc +1 -0
index fadec1221..70e5dad08 100644
@@ -27,6 +27,7 @@ PTESTS_FAST_META_OE = "\
     libxml++-5.0 \
     libyang \
     lmdb \
+    microsoft-gsl \
     minicoredumper \
     neon \
     nlohmann-json \
meta-oe/recipes-core/packagegroups/packagegroup-meta-oe.bb +1 -0
index 6e2012dae..bc15373b6 100644
@@ -310,6 +310,7 @@ RDEPENDS:packagegroup-meta-oe-devtools ="\
     yasm \
     json-schema-validator \
     poke \
+    microsoft-gsl \
 "
 RDEPENDS:packagegroup-meta-oe-devtools:append:x86 = " cpuid msr-tools pahole pmtools"
 RDEPENDS:packagegroup-meta-oe-devtools:append:x86-64 = " cpuid msr-tools pahole pcimem pmtools"
meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0001-Fix-initialization-in-test-1140.patch new file +113 -0

113 lines not on this page · raw message

meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0002-Fix-gcc-build-problem.patch new file +82 -0

82 lines not on this page · raw message

meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0003-Adapt-check_cxx_compiler_flag-to-cmake-3.0.2.patch new file +53 -0

53 lines not on this page · raw message

meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/run-ptest new file +4 -0
new file mode 100644
index 000000000..2d5bdf4ff
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+gsl_tests && echo "PASS: gsl_tests" || echo "FAIL: gsl_tests"
+gsl_noexcept_tests && echo "PASS: gsl_noexcept_tests" || echo "FAIL: gsl_noexcept_tests"
meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl_4.0.0.bb new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
2.30.2
#3 lore raw

Re: [oe] [meta-oe][PATCH v3] microsoft-gsl: add new recipe including ptest

Thanks for reworking the patch, there however is still one error popping up when ptests distro feature is enabled

https://snips.sh/f/bftvz4ANO6

This patch fixes it, but I would like to see if this warning is already fixed or can be fixed.

https://snips.sh/f/pRVar8hlif

Quoted 388 lines · Peter Marko via lists.openembedded.org

From: Peter Marko <[email protected]>

The Guidelines Support Library (GSL) contains functions and types that are suggested for use by the C++ Core Guidelines maintained by the Standard C++ Foundation.
This repo contains Microsoft's implementation of GSL.

---
v2: adapt conditional ptest clauses per review comments
v3: fix clang build

 .../include/ptest-packagelists-meta-oe.inc    |   1 +
 .../packagegroups/packagegroup-meta-oe.bb     |   1 +
 ...0001-Fix-initialization-in-test-1140.patch | 113 ++++++++++++++++++
 .../0002-Fix-gcc-build-problem.patch          |  82 +++++++++++++
 ...eck_cxx_compiler_flag-to-cmake-3.0.2.patch |  53 ++++++++
 .../microsoft-gsl/microsoft-gsl/run-ptest     |   4 +
 .../microsoft-gsl/microsoft-gsl_4.0.0.bb      |  43 +++++++
 7 files changed, 297 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0001-Fix-initialization-in-test-1140.patch
 create mode 100644 meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0002-Fix-gcc-build-problem.patch
 create mode 100644 meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0003-Adapt-check_cxx_compiler_flag-to-cmake-3.0.2.patch
 create mode 100644 meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/run-ptest
 create mode 100644 meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl_4.0.0.bb
meta-oe/conf/include/ptest-packagelists-meta-oe.inc +1 -0
index fadec1221..70e5dad08 100644
@@ -27,6 +27,7 @@ PTESTS_FAST_META_OE = "\
     libxml++-5.0 \
     libyang \
     lmdb \
+    microsoft-gsl \
     minicoredumper \
     neon \
     nlohmann-json \
meta-oe/recipes-core/packagegroups/packagegroup-meta-oe.bb +1 -0
index 6e2012dae..bc15373b6 100644
@@ -310,6 +310,7 @@ RDEPENDS:packagegroup-meta-oe-devtools ="\
     yasm \
     json-schema-validator \
     poke \
+    microsoft-gsl \
 "
 RDEPENDS:packagegroup-meta-oe-devtools:append:x86 = " cpuid msr-tools pahole pmtools"
 RDEPENDS:packagegroup-meta-oe-devtools:append:x86-64 = " cpuid msr-tools pahole pcimem pmtools"
meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0001-Fix-initialization-in-test-1140.patch new file +113 -0
new file mode 100644
index 000000000..84a585d3c
@@ -0,0 +1,113 @@
+From 1b4d42ca2e97061042ec44a0b34ceb176c78c7e1 Mon Sep 17 00:00:00 2001
+From: d-winsor <[email protected]>
+Date: Mon, 26 Feb 2024 13:17:12 -0800
+Subject: [PATCH] Fix initialization in test (#1140)
+
+* Suppress unsafe-buffer-usage
+
+Upstream-Status: Backport [https://github.com/microsoft/GSL/commit/1b4d42ca2e97061042ec44a0b34ceb176c78c7e1]
+
+Signed-off-by: Peter Marko <[email protected]>
+---
+ include/gsl/span     | 10 ++++++++++
+ include/gsl/util     | 10 ++++++++++
+ tests/CMakeLists.txt | 10 ++++++++++
+ tests/span_tests.cpp |  2 +-
+ 4 files changed, 31 insertions(+), 1 deletion(-)
+
+diff --git a/include/gsl/span b/include/gsl/span
+index cc8a7b9..d254e4d 100644
+--- a/include/gsl/span
++++ b/include/gsl/span
+@@ -58,6 +58,12 @@
+ #pragma GCC diagnostic ignored "-Wsign-conversion"
+ #endif
+
++// Turn off clang unsafe buffer warnings as all accessed are guarded by runtime checks
++#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
++#pragma clang diagnostic push
++#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
++#endif // defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
++
+ namespace gsl
+ {
+
+@@ -818,4 +824,8 @@ as_writable_bytes(span<ElementType, Extent> s) noexcept
+ #pragma GCC diagnostic pop
+ #endif // __GNUC__ > 6
+
++#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
++#pragma clang diagnostic pop
++#endif
++
+ #endif // GSL_SPAN_H
+diff --git a/include/gsl/util b/include/gsl/util
+index a215bad..11735a8 100644
+--- a/include/gsl/util
++++ b/include/gsl/util
+@@ -39,6 +39,12 @@
+
+ #endif // _MSC_VER
+
++// Turn off clang unsafe buffer warnings as all accessed are guarded by runtime checks
++#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
++#pragma clang diagnostic push
++#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
++#endif // defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
++
+ #if defined(__cplusplus) && (__cplusplus >= 201703L)
+ #define GSL_NODISCARD [[nodiscard]]
+ #else
+@@ -157,4 +163,8 @@ constexpr auto at(std::span<T, extent> sp, const index i) -> decltype(sp[sp.size
+
+ #endif // _MSC_VER
+
++#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
++#pragma clang diagnostic pop
++#endif
++
+ #endif // GSL_UTIL_H
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index cab4e56..20de9e1 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -167,6 +167,11 @@ else()
+         >
+     )
+ endif(MSVC)
++check_cxx_compiler_flag("-Wno-unsafe-buffer-usage" WARN_UNSAFE_BUFFER)
++if (WARN_UNSAFE_BUFFER)
++  # This test uses very greedy heuristics such as "no pointer arithmetic on raw buffer"
++  target_compile_options(gsl_tests_config INTERFACE "-Wno-unsafe-buffer-usage")
++endif()
+
+ # for tests to find the gtest header
+ target_include_directories(gsl_tests_config SYSTEM INTERFACE
+@@ -267,6 +272,11 @@ else()
+         >
+     )
+ endif(MSVC)
++check_cxx_compiler_flag("-Wno-unsafe-buffer-usage" WARN_UNSAFE_BUFFER)
++if (WARN_UNSAFE_BUFFER)
++  # This test uses very greedy heuristics such as "no pointer arithmetic on raw buffer"
++  target_compile_options(gsl_tests_config_noexcept INTERFACE "-Wno-unsafe-buffer-usage")
++endif()
+
+ add_executable(gsl_noexcept_tests no_exception_ensure_tests.cpp)
+ target_link_libraries(gsl_noexcept_tests
+diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp
+index 33ccf56..3c1dfe5 100644
+--- a/tests/span_tests.cpp
++++ b/tests/span_tests.cpp
+@@ -330,7 +330,7 @@ TEST(span_test, from_array_constructor)
+         EXPECT_TRUE(s.data() == std::addressof(arr2d[0]));
+     }
+
+-    int arr3d[2][3][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
++    int arr3d[2][3][2] = { { {1, 2}, {3, 4}, {5, 6} }, { {7, 8}, {9, 10}, {11, 12} } };
+
+ #ifdef CONFIRM_COMPILATION_ERRORS
+     {
+--
+2.30.2
+
meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0002-Fix-gcc-build-problem.patch new file +82 -0
new file mode 100644
index 000000000..2f7542c62
@@ -0,0 +1,82 @@
+From aa4fd1f57794964640005900c2b47af1a0940b7b Mon Sep 17 00:00:00 2001
+From: Werner Henze <[email protected]>
+Date: Fri, 1 Mar 2024 15:53:50 +0100
+Subject: [PATCH] Fix gcc build problem
+
+Closes issue #1148 by fixing problems introduced in PR #1140.
+
+Upstream-Status: Submitted [https://github.com/microsoft/GSL/pull/1149]
+
+Signed-off-by: Peter Marko <[email protected]>
+---
+ include/gsl/span | 12 ++++++++----
+ include/gsl/util | 12 ++++++++----
+ 2 files changed, 16 insertions(+), 8 deletions(-)
+
+diff --git a/include/gsl/span b/include/gsl/span
+index 0de2932..d2ef9f7 100644
+--- a/include/gsl/span
++++ b/include/gsl/span
+@@ -59,10 +59,12 @@
+ #endif
+
+ // Turn off clang unsafe buffer warnings as all accessed are guarded by runtime checks
+-#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
++#if defined(__clang__)
++#if __has_warning("-Wunsafe-buffer-usage")
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
+-#endif // defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
++#endif // __has_warning("-Wunsafe-buffer-usage")
++#endif // defined(__clang__)
+
+ namespace gsl
+ {
+@@ -824,8 +826,10 @@ as_writable_bytes(span<ElementType, Extent> s) noexcept
+ #pragma GCC diagnostic pop
+ #endif // __GNUC__ > 6
+
+-#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
++#if defined(__clang__)
++#if __has_warning("-Wunsafe-buffer-usage")
+ #pragma clang diagnostic pop
+-#endif
++#endif // __has_warning("-Wunsafe-buffer-usage")
++#endif // defined(__clang__)
+
+ #endif // GSL_SPAN_H
+diff --git a/include/gsl/util b/include/gsl/util
+index b853017..26b2f5f 100644
+--- a/include/gsl/util
++++ b/include/gsl/util
+@@ -40,10 +40,12 @@
+ #endif // _MSC_VER
+
+ // Turn off clang unsafe buffer warnings as all accessed are guarded by runtime checks
+-#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
++#if defined(__clang__)
++#if __has_warning("-Wunsafe-buffer-usage")
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
+-#endif // defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
++#endif // __has_warning("-Wunsafe-buffer-usage")
++#endif // defined(__clang__)
+
+ #if defined(__cplusplus) && (__cplusplus >= 201703L)
+ #define GSL_NODISCARD [[nodiscard]]
+@@ -163,8 +165,10 @@ constexpr auto at(std::span<T, extent> sp, const index i) -> decltype(sp[sp.size
+
+ #endif // _MSC_VER
+
+-#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage")
++#if defined(__clang__)
++#if __has_warning("-Wunsafe-buffer-usage")
+ #pragma clang diagnostic pop
+-#endif
++#endif // __has_warning("-Wunsafe-buffer-usage")
++#endif // defined(__clang__)
+
+ #endif // GSL_UTIL_H
+--
+2.30.2
+
meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0003-Adapt-check_cxx_compiler_flag-to-cmake-3.0.2.patch new file +53 -0
new file mode 100644
index 000000000..ed057f524
@@ -0,0 +1,53 @@
+From 85e1c38bcf84bd4e2ce63ef74f0cfa1f5e92261e Mon Sep 17 00:00:00 2001
+From: Peter Marko <[email protected]>
+Date: Wed, 27 Mar 2024 23:46:31 +0100
+Subject: [PATCH] Adapt check_cxx_compiler_flag to cmake 3.0.2
+
+Backporting commits which are upgrading cmake_minimum_required and
+include check_cxx_compiler_flag have too many additional changes.
+
+Let's just do a simple adaptation of our backported patch so
+it works with older cmake version instead.
+
+This can be safely removed when recipe version is upgraded.
+
+Upstream-Status: Inappropriate
+
+Signed-off-by: Peter Marko <[email protected]>
+---
+ tests/CMakeLists.txt | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index 20de9e1..54c3ac5 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -5,6 +5,7 @@ enable_testing()  # again, for support standalone testing
+
+ include(FindPkgConfig)
+ include(ExternalProject)
++include(CheckCXXCompilerFlag)
+
+ # will make visual studio generated project group files
+ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+@@ -167,7 +168,7 @@ else()
+         >
+     )
+ endif(MSVC)
+-check_cxx_compiler_flag("-Wno-unsafe-buffer-usage" WARN_UNSAFE_BUFFER)
++CHECK_CXX_COMPILER_FLAG("-Wno-unsafe-buffer-usage" WARN_UNSAFE_BUFFER)
+ if (WARN_UNSAFE_BUFFER)
+   # This test uses very greedy heuristics such as "no pointer arithmetic on raw buffer"
+   target_compile_options(gsl_tests_config INTERFACE "-Wno-unsafe-buffer-usage")
+@@ -272,7 +273,7 @@ else()
+         >
+     )
+ endif(MSVC)
+-check_cxx_compiler_flag("-Wno-unsafe-buffer-usage" WARN_UNSAFE_BUFFER)
++CHECK_CXX_COMPILER_FLAG("-Wno-unsafe-buffer-usage" WARN_UNSAFE_BUFFER)
+ if (WARN_UNSAFE_BUFFER)
+   # This test uses very greedy heuristics such as "no pointer arithmetic on raw buffer"
+   target_compile_options(gsl_tests_config_noexcept INTERFACE "-Wno-unsafe-buffer-usage")
+--
+2.30.2
+
meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/run-ptest new file +4 -0
new file mode 100644
index 000000000..2d5bdf4ff
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+gsl_tests && echo "PASS: gsl_tests" || echo "FAIL: gsl_tests"
+gsl_noexcept_tests && echo "PASS: gsl_noexcept_tests" || echo "FAIL: gsl_noexcept_tests"
meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl_4.0.0.bb new file +43 -1
new file mode 100644
index 000000000..7fc31486f
@@ -0,0 +1,43 @@
+SUMMARY = "GSL: Guidelines Support Library"
+DESCRIPTION = "The Guidelines Support Library (GSL) contains functions \
+    and types that are suggested for use by the C++ Core Guidelines \
+    maintained by the Standard C++ Foundation. \
+    This repo contains Microsoft's implementation of GSL."
+HOMEPAGE = "https://github.com/microsoft/GSL"
+
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=363055e71e77071107ba2bb9a54bd9a7"
+
+SRC_URI = "git://github.com/microsoft/GSL.git;protocol=https;branch=main \
+    file://run-ptest \
+    file://0001-Fix-initialization-in-test-1140.patch \
+    file://0002-Fix-gcc-build-problem.patch \
+    file://0003-Adapt-check_cxx_compiler_flag-to-cmake-3.0.2.patch \
+"
+SRCREV = "a3534567187d2edc428efd3f13466ff75fe5805c"
+
+S = "${WORKDIR}/git"
+
+inherit cmake pkgconfig ptest
+
+# this is header-only library
+ALLOW_EMPTY:${PN} = "1"
+
+PACKAGECONFIG ??= "${@bb.utils.contains('PTEST_ENABLED', '1', 'ptest','', d)}"
+PACKAGECONFIG[ptest] = "-DGSL_TEST=ON,-DGSL_TEST=OFF,googletest"
+
+# clang disagrees with https://github.com/google/googletest/pull/3457
+CXXFLAGS:append:toolchain-clang = " -Wno-error=switch-default"
+
+do_install_ptest() {
+    install -d ${D}${bindir}
+    install -m 0755 ${B}/tests/gsl_tests ${D}${bindir}
+    install -m 0755 ${B}/tests/gsl_noexcept_tests ${D}${bindir}
+}
+
+FILES:${PN}-ptest = "${bindir}/gsl*_tests"
+
+# there is already other gsl recipe, so recipe name does not match the real component name
+CVE_PRODUCT = "microsoft:gsl"
+
+BBCLASSEXTEND = "native nativesdk"
--

2.30.2

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

#4 lore raw

RE: [oe] [meta-oe][PATCH v3] microsoft-gsl: add new recipe including ptest

I did not see this when building locally with poky defaults (using 5.0_M3), but from screenshot I see it's failing with musl. I'll try to come up with a patch, but I have never worked with musl so far...

Peter.

-----Original Message-----
From: Khem Raj <[email protected]>
Sent: Thursday, March 28, 2024 5:32
To: Marko, Peter (ADV D EU SK BFS1) <[email protected]>
Cc: [email protected]
Subject: Re: [oe] [meta-oe][PATCH v3] microsoft-gsl: add new recipe including ptest

Quoted 9 lines

Thanks for reworking the patch, there however is still one error popping up when ptests distro feature is enabled

https://snips.sh/f/bftvz4ANO6

This patch fixes it, but I would like to see if this warning is already fixed or can be fixed.

https://snips.sh/f/pRVar8hlif

On Wed, Mar 27, 2024 at 4:07 PM Peter Marko via lists.openembedded.org <[email protected]> wrote:

...

#5 lore raw

RE: [oe] [meta-oe][PATCH v3] microsoft-gsl: add new recipe including ptest

Due to easter holidays I won't have time to analyze this until mid of next week. If you want to merge your patch meanwhile, please add a new comment/line for it. My comment with googletest PR reference is only valid for switch-default flag.

Peter

-----Original Message-----
From: Marko, Peter (ADV D EU SK BFS1)
Sent: Thursday, March 28, 2024 10:49
To: Khem Raj <[email protected]>
Cc: [email protected]
Subject: RE: [oe] [meta-oe][PATCH v3] microsoft-gsl: add new recipe including ptest

Quoted 21 lines

I did not see this when building locally with poky defaults (using 5.0_M3), but from screenshot I see it's failing with musl. I'll try to come up with a patch, but I have never worked with musl so far...

Peter.

-----Original Message-----
From: Khem Raj <[email protected]>
Sent: Thursday, March 28, 2024 5:32
To: Marko, Peter (ADV D EU SK BFS1) <[email protected]>
Cc: [email protected]
Subject: Re: [oe] [meta-oe][PATCH v3] microsoft-gsl: add new recipe including ptest

Quoted 9 lines

Thanks for reworking the patch, there however is still one error popping up when ptests distro feature is enabled

https://snips.sh/f/bftvz4ANO6

This patch fixes it, but I would like to see if this warning is already fixed or can be fixed.

https://snips.sh/f/pRVar8hlif

On Wed, Mar 27, 2024 at 4:07 PM Peter Marko via lists.openembedded.org <[email protected]> wrote:

...

#6 lore raw

Re: [oe] [meta-oe][PATCH v3] microsoft-gsl: add new recipe including ptest

No worries, I have separated it into a separate addition which will be effective for musl
based builds alone in master-next, let me know if you have further suggestions

Quoted 36 lines · Peter

Due to easter holidays I won't have time to analyze this until mid of next week. If you want to merge your patch meanwhile, please add a new comment/line for it. My comment with googletest PR reference is only valid for switch-default flag.

Peter

-----Original Message-----
From: Marko, Peter (ADV D EU SK BFS1)
Sent: Thursday, March 28, 2024 10:49
To: Khem Raj <[email protected]>
Cc: [email protected]
Subject: RE: [oe] [meta-oe][PATCH v3] microsoft-gsl: add new recipe including ptest

Quoted 21 lines

I did not see this when building locally with poky defaults (using 5.0_M3), but from screenshot I see it's failing with musl. I'll try to come up with a patch, but I have never worked with musl so far...

Peter.

-----Original Message-----
From: Khem Raj <[email protected]>
Sent: Thursday, March 28, 2024 5:32
To: Marko, Peter (ADV D EU SK BFS1) <[email protected]>
Cc: [email protected]
Subject: Re: [oe] [meta-oe][PATCH v3] microsoft-gsl: add new recipe including ptest

Quoted 9 lines

Thanks for reworking the patch, there however is still one error popping up when ptests distro feature is enabled

https://snips.sh/f/bftvz4ANO6

This patch fixes it, but I would like to see if this warning is already fixed or can be fixed.

https://snips.sh/f/pRVar8hlif

On Wed, Mar 27, 2024 at 4:07 PM Peter Marko via lists.openembedded.org <[email protected]> wrote:

...

#7 lore raw

RE: [oe] [meta-oe][PATCH v3] microsoft-gsl: add new recipe including ptest

I have checked these warnings, and the root-cause is that gsl sets "-Weverything".
That's super cool to be able to compile with this switch, but rather bad idea when trying to port that to new platforms (like our clang + musl combination).

I can also fix this by modifying musl stdio.h within the recipe sysroot to how glibc has stderr macro defined. That indicates that maybe there could be optimization possibility within the used libraries (musl or googletest)

recipe-sysroot/usr/include/stdio.h +1 -1
@@ -65,7 +65,7 @@ extern FILE *const stderr;
 
 #define stdin  (stdin)
 #define stdout (stdout)
-#define stderr (stderr)
+#define stderr stderr
 
 FILE *fopen(const char *__restrict, const char *__restrict);
 FILE *freopen(const char *__restrict, const char *__restrict, FILE *__restrict);

But I'm unsure if it's worth to invest further effort into this due to the dangerous -Weverything setting. This is my small reproducer where it also fails with the same warning/error...
... for case that someone wants to go and check with musl or googletest development.

$(CXX) $(CXXFLAGS) $(LDFLAGS) -Wall -Werror -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-global-constructors -Wno-missing-prototypes -lgmock_main -lgmock -lgtest_main -lgtest test.cpp -o test

#include <gtest/gtest.h>
int f(int i, int j) {std::cerr << "TEST"; return i/j;} TEST(MyTest, ExpectDeathWcoveredSwitchDefault) { EXPECT_DEATH(f(2, 0), ""); }

Peter

-----Original Message-----
From: Khem Raj <[email protected]>
Sent: Thursday, March 28, 2024 21:15
To: Marko, Peter (ADV D EU SK BFS1) <[email protected]>
Cc: [email protected]
Subject: Re: [oe] [meta-oe][PATCH v3] microsoft-gsl: add new recipe including ptest

Quoted 42 lines

No worries, I have separated it into a separate addition which will be effective for musl based builds alone in master-next, let me know if you have further suggestions

Quoted 39 lines · Peter

Due to easter holidays I won't have time to analyze this until mid of next week. If you want to merge your patch meanwhile, please add a new comment/line for it. My comment with googletest PR reference is only valid for switch-default flag.

Peter

-----Original Message-----
From: Marko, Peter (ADV D EU SK BFS1)
Sent: Thursday, March 28, 2024 10:49
To: Khem Raj <[email protected]>
Cc: [email protected]
Subject: RE: [oe] [meta-oe][PATCH v3] microsoft-gsl: add new recipe including ptest

Quoted 23 lines

I did not see this when building locally with poky defaults (using 5.0_M3), but from screenshot I see it's failing with musl. I'll try to come up with a patch, but I have never worked with musl so far...

Peter.

-----Original Message-----
From: Khem Raj <[email protected]>
Sent: Thursday, March 28, 2024 5:32
To: Marko, Peter (ADV D EU SK BFS1) <[email protected]>
Cc: [email protected]
Subject: Re: [oe] [meta-oe][PATCH v3] microsoft-gsl: add new recipe including ptest

Quoted 10 lines

Thanks for reworking the patch, there however is still one error popping up when ptests distro feature is enabled

https://snips.sh/f/bftvz4ANO6

This patch fixes it, but I would like to see if this warning is already fixed or can be fixed.

https://snips.sh/f/pRVar8hlif

On Wed, Mar 27, 2024 at 4:07 PM Peter Marko via lists.openembedded.org <[email protected]> wrote:

...