diff mbox series

[meta-oe,2/4] googlebenchmark: Fix type conversion errors found with clang

Message ID 20240529032948.150704-2-raj.khem@gmail.com
State New
Headers show
Series [meta-oe,1/4] ckermit: Define return type for main | expand

Commit Message

Khem Raj May 29, 2024, 3:29 a.m. UTC
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...ype-conversion-to-match-function-ret.patch | 34 +++++++++++++++++++
 .../googlebenchmark/googlebenchmark_1.8.4.bb  |  3 +-
 2 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-support/googlebenchmark/googlebenchmark/0001-cycleclock-Fix-type-conversion-to-match-function-ret.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-support/googlebenchmark/googlebenchmark/0001-cycleclock-Fix-type-conversion-to-match-function-ret.patch b/meta-oe/recipes-support/googlebenchmark/googlebenchmark/0001-cycleclock-Fix-type-conversion-to-match-function-ret.patch
new file mode 100644
index 0000000000..d514cf192b
--- /dev/null
+++ b/meta-oe/recipes-support/googlebenchmark/googlebenchmark/0001-cycleclock-Fix-type-conversion-to-match-function-ret.patch
@@ -0,0 +1,34 @@ 
+From db704bcc344529039d7fb28be380658625a9c08d Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Tue, 28 May 2024 19:34:43 -0700
+Subject: [PATCH] cycleclock: Fix type conversion to match function return type
+
+fixes build with clang19
+
+src/cycleclock.h:208:52: error: implicit conversion changes signedness: 'uint64_t' (aka 'unsigned long long') to 'int64_t' (aka 'long long') [-Werror,-Wsign-conversion]
+  208 |   return (static_cast<uint64_t>(cycles_hi1) << 32) | cycles_lo;
+      |   ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
+1 error generated.
+
+Upstream-Status: Submitted [https://github.com/google/benchmark/pull/1794]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ src/cycleclock.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/cycleclock.h b/src/cycleclock.h
+index a2584376..f96801c5 100644
+--- a/src/cycleclock.h
++++ b/src/cycleclock.h
+@@ -205,7 +205,7 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() {
+       "sub %0, zero, %0\n"
+       "and %1, %1, %0\n"
+       : "=r"(cycles_hi0), "=r"(cycles_lo), "=r"(cycles_hi1));
+-  return (static_cast<uint64_t>(cycles_hi1) << 32) | cycles_lo;
++  return static_cast<int64_t>((static_cast<uint64_t>(cycles_hi1) << 32) | cycles_lo);
+ #else
+   uint64_t cycles;
+   asm volatile("rdtime %0" : "=r"(cycles));
+-- 
+2.45.1
+
diff --git a/meta-oe/recipes-support/googlebenchmark/googlebenchmark_1.8.4.bb b/meta-oe/recipes-support/googlebenchmark/googlebenchmark_1.8.4.bb
index ffb57942ee..34732b42d9 100644
--- a/meta-oe/recipes-support/googlebenchmark/googlebenchmark_1.8.4.bb
+++ b/meta-oe/recipes-support/googlebenchmark/googlebenchmark_1.8.4.bb
@@ -4,7 +4,8 @@  SECTION = "libs"
 LICENSE = "Apache-2.0"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
 
-SRC_URI = "git://github.com/google/benchmark.git;protocol=https;branch=main"
+SRC_URI = "git://github.com/google/benchmark.git;protocol=https;branch=main \
+           file://0001-cycleclock-Fix-type-conversion-to-match-function-ret.patch"
 SRCREV = "a4cf155615c63e019ae549e31703bf367df5b471"
 
 S = "${WORKDIR}/git"