summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-graphics/vulkan/vulkan-samples/0001-support-link-against-libatomic-if-no-built-in-atomic.patch117
-rw-r--r--meta/recipes-graphics/vulkan/vulkan-samples_git.bb3
2 files changed, 1 insertions, 119 deletions
diff --git a/meta/recipes-graphics/vulkan/vulkan-samples/0001-support-link-against-libatomic-if-no-built-in-atomic.patch b/meta/recipes-graphics/vulkan/vulkan-samples/0001-support-link-against-libatomic-if-no-built-in-atomic.patch
deleted file mode 100644
index 6c0fb60868..0000000000
--- a/meta/recipes-graphics/vulkan/vulkan-samples/0001-support-link-against-libatomic-if-no-built-in-atomic.patch
+++ /dev/null
@@ -1,117 +0,0 @@
1From e20a5d13935a41a856e8f71c49f2cc9d81b1d92c Mon Sep 17 00:00:00 2001
2From: Changqing Li <changqing.li@windriver.com>
3Date: Fri, 13 Nov 2020 17:07:00 +0800
4Subject: [PATCH] support link against libatomic if no built-in atomic exist
5
6fix error:
7| framework/lib/ppc/libframework.a(device.cpp.o): in function `std::__atomic_base<unsigned long long>::load(std::memory_order) const':
8| /usr/include/c++/10.2.0/bits/atomic_base.h:426: undefined reference to `__atomic_load_8'
9
10Upstream-Status: Submitted [https://github.com/KhronosGroup/Vulkan-Samples/pull/212]
11
12Signed-off-by: Changqing Li <changqing.li@windriver.com>
13---
14 CMakeLists.txt | 1 +
15 bldsys/cmake/check_atomic.cmake | 62 +++++++++++++++++++++++++++++++++
16 framework/CMakeLists.txt | 4 +++
17 3 files changed, 67 insertions(+)
18 create mode 100644 bldsys/cmake/check_atomic.cmake
19
20diff --git a/CMakeLists.txt b/CMakeLists.txt
21index e72e829..466f51d 100644
22--- a/CMakeLists.txt
23+++ b/CMakeLists.txt
24@@ -42,6 +42,7 @@ endmacro(vulkan_samples_pch)
25 include(utils)
26 include(global_options)
27 include(sample_helper)
28+include(check_atomic)
29
30 # Add third party libraries
31 add_subdirectory(third_party)
32diff --git a/bldsys/cmake/check_atomic.cmake b/bldsys/cmake/check_atomic.cmake
33new file mode 100644
34index 0000000..6b47a7a
35--- /dev/null
36+++ b/bldsys/cmake/check_atomic.cmake
37@@ -0,0 +1,62 @@
38+# check weither need to link atomic library explicitly
39+INCLUDE(CheckCXXSourceCompiles)
40+INCLUDE(CheckLibraryExists)
41+
42+if(NOT DEFINED VULKAN_COMPILER_IS_GCC_COMPATIBLE)
43+ if(CMAKE_COMPILER_IS_GNUCXX)
44+ set(VULKAN_COMPILER_IS_GCC_COMPATIBLE ON)
45+ elseif( MSVC )
46+ set(VULKAN_COMPILER_IS_GCC_COMPATIBLE OFF)
47+ elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
48+ set(VULKAN_COMPILER_IS_GCC_COMPATIBLE ON)
49+ elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel" )
50+ set(VULKAN_COMPILER_IS_GCC_COMPATIBLE ON)
51+ endif()
52+endif()
53+
54+# Sometimes linking against libatomic is required for atomic ops, if
55+# the platform doesn't support lock-free atomics.
56+
57+function(check_working_cxx_atomics varname)
58+ set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
59+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11")
60+ CHECK_CXX_SOURCE_COMPILES("
61+#include <atomic>
62+std::atomic<int> x;
63+std::atomic<short> y;
64+std::atomic<char> z;
65+int main() {
66+ ++z;
67+ ++y;
68+ return ++x;
69+}
70+" ${varname})
71+ set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
72+endfunction(check_working_cxx_atomics)
73+
74+function(check_working_cxx_atomics64 varname)
75+ set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
76+ set(CMAKE_REQUIRED_FLAGS "-std=c++11 ${CMAKE_REQUIRED_FLAGS}")
77+ CHECK_CXX_SOURCE_COMPILES("
78+#include <atomic>
79+#include <cstdint>
80+std::atomic<uint64_t> x (0);
81+int main() {
82+ uint64_t i = x.load(std::memory_order_relaxed);
83+ (void)i;
84+ return 0;
85+}
86+" ${varname})
87+ set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
88+endfunction(check_working_cxx_atomics64)
89+
90+set(NEED_LINK_ATOMIC OFF CACHE BOOL "weither need to link against atomic library")
91+if(VULKAN_COMPILER_IS_GCC_COMPATIBLE)
92+ # check if non-64-bit atomics work without the library.
93+ check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITHOUT_LIB)
94+ # check 64-bit atomics work without the library.
95+ check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITHOUT_LIB)
96+ if (NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
97+ set(NEED_LINK_ATOMIC ON CACHE BOOL "weither need to link to atomic library" FORCE)
98+ endif()
99+endif()
100diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt
101index bf26786..322526e 100644
102--- a/framework/CMakeLists.txt
103+++ b/framework/CMakeLists.txt
104@@ -412,6 +412,10 @@ target_link_libraries(${PROJECT_NAME}
105 ctpl
106 docopt)
107
108+if(${NEED_LINK_ATOMIC})
109+ target_link_libraries(${PROJECT_NAME} atomic)
110+endif()
111+
112 # Link platform specific libraries
113 if(ANDROID)
114 target_link_libraries(${PROJECT_NAME} log android native_app_glue)
115--
1162.17.1
117
diff --git a/meta/recipes-graphics/vulkan/vulkan-samples_git.bb b/meta/recipes-graphics/vulkan/vulkan-samples_git.bb
index a61dddeb3b..05b9e855d7 100644
--- a/meta/recipes-graphics/vulkan/vulkan-samples_git.bb
+++ b/meta/recipes-graphics/vulkan/vulkan-samples_git.bb
@@ -5,12 +5,11 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=48aa35cefb768436223a6e7f18dc2a2a"
5 5
6SRC_URI = "gitsm://github.com/KhronosGroup/Vulkan-Samples.git \ 6SRC_URI = "gitsm://github.com/KhronosGroup/Vulkan-Samples.git \
7 file://0001-CMakeLists.txt-do-not-hardcode-lib-as-installation-t.patch \ 7 file://0001-CMakeLists.txt-do-not-hardcode-lib-as-installation-t.patch \
8 file://0001-support-link-against-libatomic-if-no-built-in-atomic.patch \
9 file://debugfix.patch \ 8 file://debugfix.patch \
10 " 9 "
11 10
12UPSTREAM_CHECK_COMMITS = "1" 11UPSTREAM_CHECK_COMMITS = "1"
13SRCREV = "fdc8fab1a520df5566de3eda7b526b24f04e6379" 12SRCREV = "524cdcd27005e7cd56e6694fa41e685519d7dbca"
14 13
15UPSTREAM_CHECK_GITTAGREGEX = "These are not the releases you're looking for" 14UPSTREAM_CHECK_GITTAGREGEX = "These are not the releases you're looking for"
16S = "${WORKDIR}/git" 15S = "${WORKDIR}/git"