public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: "Changqing Li" <changqing.li@windriver.com>
To: openembedded-core@lists.openembedded.org
Subject: Re: [OE-core] [PATCH V2] vulkan-samples: fix do_compile failure
Date: Thu, 19 Nov 2020 08:35:32 +0800	[thread overview]
Message-ID: <e1840377-1439-a538-bd83-e5c219d4be17@windriver.com> (raw)
In-Reply-To: <1647D99B9B8E3CA1.27572@lists.openembedded.org>

[-- Attachment #1: Type: text/plain, Size: 6397 bytes --]

ping

On 16/11/20 9:43 am, Changqing Li wrote:
> 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
>
> Signed-off-by: Changqing Li <changqing.li@windriver.com>
> ---
>   ...inst-libatomic-if-no-built-in-atomic.patch | 117 ++++++++++++++++++
>   .../vulkan/vulkan-samples_git.bb              |   2 +
>   2 files changed, 119 insertions(+)
>   create mode 100644 meta/recipes-graphics/vulkan/vulkan-samples/0001-support-link-against-libatomic-if-no-built-in-atomic.patch
>
> 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 @@
> +From e20a5d13935a41a856e8f71c49f2cc9d81b1d92c Mon Sep 17 00:00:00 2001
> +From: Changqing Li <changqing.li@windriver.com>
> +Date: Fri, 13 Nov 2020 17:07:00 +0800
> +Subject: [PATCH] support link against libatomic if no built-in atomic exist
> +
> +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'
> +
> +Upstream-Status: Submitted [https://github.com/KhronosGroup/Vulkan-Samples/pull/212]
> +
> +Signed-off-by: Changqing Li <changqing.li@windriver.com>
> +---
> + CMakeLists.txt                  |  1 +
> + bldsys/cmake/check_atomic.cmake | 62 +++++++++++++++++++++++++++++++++
> + framework/CMakeLists.txt        |  4 +++
> + 3 files changed, 67 insertions(+)
> + create mode 100644 bldsys/cmake/check_atomic.cmake
> +
> +diff --git a/CMakeLists.txt b/CMakeLists.txt
> +index e72e829..466f51d 100644
> +--- a/CMakeLists.txt
> ++++ b/CMakeLists.txt
> +@@ -42,6 +42,7 @@ endmacro(vulkan_samples_pch)
> + include(utils)
> + include(global_options)
> + include(sample_helper)
> ++include(check_atomic)
> +
> + # Add third party libraries
> + add_subdirectory(third_party)
> +diff --git a/bldsys/cmake/check_atomic.cmake b/bldsys/cmake/check_atomic.cmake
> +new file mode 100644
> +index 0000000..6b47a7a
> +--- /dev/null
> ++++ b/bldsys/cmake/check_atomic.cmake
> +@@ -0,0 +1,62 @@
> ++# check weither need to link atomic library explicitly
> ++INCLUDE(CheckCXXSourceCompiles)
> ++INCLUDE(CheckLibraryExists)
> ++
> ++if(NOT DEFINED VULKAN_COMPILER_IS_GCC_COMPATIBLE)
> ++  if(CMAKE_COMPILER_IS_GNUCXX)
> ++    set(VULKAN_COMPILER_IS_GCC_COMPATIBLE ON)
> ++  elseif( MSVC )
> ++    set(VULKAN_COMPILER_IS_GCC_COMPATIBLE OFF)
> ++  elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
> ++    set(VULKAN_COMPILER_IS_GCC_COMPATIBLE ON)
> ++  elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel" )
> ++    set(VULKAN_COMPILER_IS_GCC_COMPATIBLE ON)
> ++  endif()
> ++endif()
> ++
> ++# Sometimes linking against libatomic is required for atomic ops, if
> ++# the platform doesn't support lock-free atomics.
> ++
> ++function(check_working_cxx_atomics varname)
> ++  set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
> ++  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11")
> ++  CHECK_CXX_SOURCE_COMPILES("
> ++#include <atomic>
> ++std::atomic<int> x;
> ++std::atomic<short> y;
> ++std::atomic<char> z;
> ++int main() {
> ++  ++z;
> ++  ++y;
> ++  return ++x;
> ++}
> ++" ${varname})
> ++  set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
> ++endfunction(check_working_cxx_atomics)
> ++
> ++function(check_working_cxx_atomics64 varname)
> ++  set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
> ++  set(CMAKE_REQUIRED_FLAGS "-std=c++11 ${CMAKE_REQUIRED_FLAGS}")
> ++  CHECK_CXX_SOURCE_COMPILES("
> ++#include <atomic>
> ++#include <cstdint>
> ++std::atomic<uint64_t> x (0);
> ++int main() {
> ++  uint64_t i = x.load(std::memory_order_relaxed);
> ++  (void)i;
> ++  return 0;
> ++}
> ++" ${varname})
> ++  set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
> ++endfunction(check_working_cxx_atomics64)
> ++
> ++set(NEED_LINK_ATOMIC  OFF CACHE BOOL "weither need to link against atomic library")
> ++if(VULKAN_COMPILER_IS_GCC_COMPATIBLE)
> ++    # check if non-64-bit atomics work without the library.
> ++    check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITHOUT_LIB)
> ++    # check 64-bit atomics work without the library.
> ++    check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITHOUT_LIB)
> ++    if (NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
> ++        set(NEED_LINK_ATOMIC  ON CACHE BOOL "weither need to link to atomic library" FORCE)
> ++    endif()
> ++endif()
> +diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt
> +index bf26786..322526e 100644
> +--- a/framework/CMakeLists.txt
> ++++ b/framework/CMakeLists.txt
> +@@ -412,6 +412,10 @@ target_link_libraries(${PROJECT_NAME}
> +     ctpl
> +     docopt)
> +
> ++if(${NEED_LINK_ATOMIC})
> ++    target_link_libraries(${PROJECT_NAME} atomic)
> ++endif()
> ++
> + # Link platform specific libraries
> + if(ANDROID)
> +     target_link_libraries(${PROJECT_NAME} log android native_app_glue)
> +--
> +2.17.1
> +
> 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"
>   
>   SRC_URI = "gitsm://github.com/KhronosGroup/Vulkan-Samples.git \
>              file://0001-CMakeLists.txt-do-not-hardcode-lib-as-installation-t.patch \
> +           file://0001-support-link-against-libatomic-if-no-built-in-atomic.patch \
>              "
> +
>   UPSTREAM_CHECK_COMMITS = "1"
>   SRCREV = "f52361d3cd6ac8c30fc3365a464b4e220c32cfd6"
>   
>
> 
>

[-- Attachment #2: Type: text/html, Size: 7434 bytes --]

           reply	other threads:[~2020-11-19  0:35 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1647D99B9B8E3CA1.27572@lists.openembedded.org>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e1840377-1439-a538-bd83-e5c219d4be17@windriver.com \
    --to=changqing.li@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox