File: generic-cpu.patch

package info (click to toggle)
pocl 7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 29,768 kB
  • sloc: lisp: 151,669; ansic: 135,425; cpp: 65,801; python: 1,846; sh: 1,084; ruby: 255; pascal: 231; tcl: 180; makefile: 174; asm: 81; java: 72; xml: 49
file content (62 lines) | stat: -rw-r--r-- 2,549 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Author: Andreas Beckmann <anbe@debian.org>
Description: add support for a GENERIC cpu type that uses llvm defaults
Forwarded: not-needed

Index: pocl/lib/kernel/host/CMakeLists.txt
===================================================================
--- pocl.orig/lib/kernel/host/CMakeLists.txt	2026-03-09 14:53:58.012919653 +0100
+++ pocl/lib/kernel/host/CMakeLists.txt	2026-03-09 14:53:58.012383560 +0100
@@ -674,6 +674,11 @@
   set(LLC_CPUFLAGS "")
 endif()
 
+if("${VARIANT}" STREQUAL "GENERIC")
+  set(CLANG_CPUFLAGS "")
+  set(LLC_CPUFLAGS "")
+endif()
+
 separate_arguments(CLANG_CPUFLAGS)
 separate_arguments(LLC_CPUFLAGS)
 set(CLANG_FLAGS ${HOST_CLANG_FLAGS} ${CLANG_CPUFLAGS}
Index: pocl/cmake/LLVM.cmake
===================================================================
--- pocl.orig/cmake/LLVM.cmake	2026-03-09 14:53:58.012919653 +0100
+++ pocl/cmake/LLVM.cmake	2026-03-09 14:59:07.020303321 +0100
@@ -802,7 +802,14 @@
 # Some architectures have -march and -mcpu reversed
 if(NOT DEFINED CLANG_MARCH_FLAG)
   message(STATUS "Checking clang -march vs. -mcpu flag")
-  custom_try_compile_clang_silent("" "return 0;" RES --target=${LLC_TRIPLE} -march=${SELECTED_HOST_CPU})
+  if(LLC_HOST_CPU STREQUAL "GENERIC" AND NOT KERNELLIB_HOST_CPU_VARIANTS STREQUAL "distro")
+    set(CLANG_MARCH_FLAG "-None=")
+  else()
+    set(LLC_HOST_CPU_TEST "${SELECTED_HOST_CPU}")
+  if(LLC_HOST_CPU STREQUAL "GENERIC")
+    set(LLC_HOST_CPU_TEST "${LLC_HOST_CPU_AUTO}")
+  endif()
+  custom_try_compile_clang_silent("" "return 0;" RES --target=${LLC_TRIPLE} -march=${LLC_HOST_CPU_TEST})
   if(NOT RES)
     set(CLANG_MARCH_FLAG "-march=")
   else()
@@ -813,6 +820,7 @@
       message(FATAL_ERROR "Could not determine whether to use -march or -mcpu with clang")
     endif()
   endif()
+  endif()
   message(STATUS "  Using ${CLANG_MARCH_FLAG}")
 
   set(CLANG_MARCH_FLAG ${CLANG_MARCH_FLAG} CACHE INTERNAL "Clang option used to specify the target cpu")
Index: pocl/lib/CL/devices/common_utils.c
===================================================================
--- pocl.orig/lib/CL/devices/common_utils.c	2026-03-09 14:53:58.012919653 +0100
+++ pocl/lib/CL/devices/common_utils.c	2026-03-09 14:53:58.012860920 +0100
@@ -304,6 +304,9 @@
     device->kernellib_subdir = "host";
   device->llvm_abi = pocl_get_llvm_cpu_abi ();
 
+  if(device->llvm_cpu && (!strcmp(device->llvm_cpu, "GENERIC")))
+    device->llvm_cpu = NULL;
+
 #ifndef ENABLE_SIGFPE_HANDLER
   if (strstr (OCL_KERNEL_TARGET, "x86") != NULL)
     device->run_sanitize_divrem_pass = CL_TRUE;