diff options
author | Changqing Li <changqing.li@windriver.com> | 2020-11-16 09:43:42 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-11-24 10:27:45 +0000 |
commit | 0fa07d1811fa9612e3f643a4d6bf711b281ca7fd (patch) | |
tree | 30b5cc3b2ac880d3bbae7df8471c2b045292373b /meta/recipes-graphics/vulkan | |
parent | 0d5b99b33643ae39126933444e5425097b73cfd5 (diff) | |
download | poky-0fa07d1811fa9612e3f643a4d6bf711b281ca7fd.tar.gz |
vulkan-samples: fix do_compile failure
fix error:
| framework/lib/ppc/libframework.a(device.cpp.o): in function `std::__atomic_base<unsigned long long>::load(std::memory_order) const':
| /usr/include/c++/10.2.0/bits/atomic_base.h:426: undefined reference to `__atomic_load_8'
some arch don't have built-in atomic, so need to link it
explicitly
(From OE-Core rev: 65410c5ff4f9c34758d1e2270132c631166e7d1a)
Signed-off-by: Changqing Li <changqing.li@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-graphics/vulkan')
-rw-r--r-- | meta/recipes-graphics/vulkan/vulkan-samples/0001-support-link-against-libatomic-if-no-built-in-atomic.patch | 117 | ||||
-rw-r--r-- | meta/recipes-graphics/vulkan/vulkan-samples_git.bb | 2 |
2 files changed, 119 insertions, 0 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 new file mode 100644 index 0000000000..6c0fb60868 --- /dev/null +++ b/meta/recipes-graphics/vulkan/vulkan-samples/0001-support-link-against-libatomic-if-no-built-in-atomic.patch | |||
@@ -0,0 +1,117 @@ | |||
1 | From e20a5d13935a41a856e8f71c49f2cc9d81b1d92c Mon Sep 17 00:00:00 2001 | ||
2 | From: Changqing Li <changqing.li@windriver.com> | ||
3 | Date: Fri, 13 Nov 2020 17:07:00 +0800 | ||
4 | Subject: [PATCH] support link against libatomic if no built-in atomic exist | ||
5 | |||
6 | fix 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 | |||
10 | Upstream-Status: Submitted [https://github.com/KhronosGroup/Vulkan-Samples/pull/212] | ||
11 | |||
12 | Signed-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 | |||
20 | diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
21 | index 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) | ||
32 | diff --git a/bldsys/cmake/check_atomic.cmake b/bldsys/cmake/check_atomic.cmake | ||
33 | new file mode 100644 | ||
34 | index 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() | ||
100 | diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt | ||
101 | index 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 | -- | ||
116 | 2.17.1 | ||
117 | |||
diff --git a/meta/recipes-graphics/vulkan/vulkan-samples_git.bb b/meta/recipes-graphics/vulkan/vulkan-samples_git.bb index 241a313a7b..980557a3b9 100644 --- a/meta/recipes-graphics/vulkan/vulkan-samples_git.bb +++ b/meta/recipes-graphics/vulkan/vulkan-samples_git.bb | |||
@@ -5,7 +5,9 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=48aa35cefb768436223a6e7f18dc2a2a" | |||
5 | 5 | ||
6 | SRC_URI = "gitsm://github.com/KhronosGroup/Vulkan-Samples.git \ | 6 | SRC_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 \ | ||
8 | " | 9 | " |
10 | |||
9 | UPSTREAM_CHECK_COMMITS = "1" | 11 | UPSTREAM_CHECK_COMMITS = "1" |
10 | SRCREV = "f52361d3cd6ac8c30fc3365a464b4e220c32cfd6" | 12 | SRCREV = "f52361d3cd6ac8c30fc3365a464b4e220c32cfd6" |
11 | 13 | ||