[PATCH] CMakeLists.txt: Handle 'undefined' values returned by getconf
authorAlexandre Ghiti <alexandre.ghiti@canonical.com>
Wed, 15 Sep 2021 09:24:38 +0000 (11:24 +0200)
committerAndreas Beckmann <anbe@debian.org>
Thu, 30 Sep 2021 16:07:33 +0000 (17:07 +0100)
This allows to avoid build failures when using qemu user mode for riscv64 [1]:
the corresponding bug in qemu [2] will get fixed but handling that here allows
to keep pocl buildable by old qemu versions.

[1]: https://bugs.launchpad.net/ubuntu/+source/pocl/+bug/1942895
[2]: https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1942884

Signed-off-by: Alexandre Ghiti <alexandre.ghiti@canonical.com>
Gbp-Pq: Name 1002-CMakeLists.txt-Handle-undefined-values-returned-by-g.patch

CMakeLists.txt

index 5183b157e5535f4f8ed61f8e053a65373295787e..014fea106104237c0c9e121f95153abc08c00e46 100644 (file)
@@ -421,6 +421,10 @@ if(NOT HOST_CPU_CACHELINE_SIZE)
         message(WARNING "getconf exited with nonzero status!")
         set(CL_SIZE 0)
       else()
+        # getconf may in rare conditions return "undefined" value
+        if (CL_SIZE STREQUAL "undefined\n")
+          set(CL_SIZE 0)
+        endif()
         # getconf sometimes just returns zero
         if(NOT (CL_SIZE EQUAL 0))
           string(STRIP "${CL_SIZE}" CL_SIZE)