summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2020-11-18 19:07:21 +0000
committerSergei Trofimovich <slyfox@gentoo.org>2020-11-18 19:07:34 +0000
commit8cad6ded95c9f172ad2913e10d146b6afc3b69bb (patch)
treea926422e3e78c054b2928b720eb95355aece5746 /dev-util/ccache
parentdev-python/line_profiler: add python3_9 (diff)
downloadgentoo-8cad6ded95c9f172ad2913e10d146b6afc3b69bb.tar.gz
gentoo-8cad6ded95c9f172ad2913e10d146b6afc3b69bb.tar.bz2
gentoo-8cad6ded95c9f172ad2913e10d146b6afc3b69bb.zip
dev-util/ccache: link in missing libatomic
Fixes build failure on powerpc. Package-Manager: Portage-3.0.9, Repoman-3.0.2 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Diffstat (limited to 'dev-util/ccache')
-rw-r--r--dev-util/ccache/ccache-4.0.ebuild40
-rw-r--r--dev-util/ccache/files/ccache-4.0-atomic.patch21
2 files changed, 60 insertions, 1 deletions
diff --git a/dev-util/ccache/ccache-4.0.ebuild b/dev-util/ccache/ccache-4.0.ebuild
index 66c0f19279a3..da46cf9b15a3 100644
--- a/dev-util/ccache/ccache-4.0.ebuild
+++ b/dev-util/ccache/ccache-4.0.ebuild
@@ -3,7 +3,7 @@
EAPI=7
-inherit cmake
+inherit cmake toolchain-funcs
DESCRIPTION="fast compiler cache"
HOMEPAGE="https://ccache.dev/"
@@ -31,8 +31,39 @@ PATCHES=(
"${FILESDIR}"/${PN}-3.5-nvcc-test.patch
"${FILESDIR}"/${PN}-4.0-objdump.patch
"${FILESDIR}"/${PN}-4.0-avoid-run-user.patch
+ "${FILESDIR}"/${PN}-4.0-atomic.patch
)
+# ccache does not do it automatically. TODO: fix upstream
+need_latomic() {
+ # test if -latomic is needed and helps. -latomic is needed
+ # at least on ppc32. Use bit of inodeCache.cpp test.
+ cat >"${T}"/a-test.cc <<-EOF
+ #include <atomic>
+ #include <cstdint>
+ std::atomic<std::int64_t> a;
+ int main() { return a.load() == 0; }
+ EOF
+
+ local cxx_cmd=(
+ $(tc-getCXX)
+ $CXXFLAGS
+ $LDFLAGS
+ "${T}"/a-test.cc
+ -o "${T}"/a-test
+ )
+
+ einfo "${cxx_cmd[@]}"
+ "${cxx_cmd[@]}" && return 1
+
+ einfo "Trying to add -latomic"
+ einfo "${cxx_cmd[@]}"
+ cxx_cmd+=(-latomic)
+ "${cxx_cmd[@]}" && return 0
+
+ return 1
+}
+
src_prepare() {
cmake_src_prepare
@@ -44,6 +75,13 @@ src_prepare() {
tc-export CC OBJDUMP
}
+src_configure() {
+ local mycmakeargs=(
+ -DLINK_WITH_ATOMIC=$(need_latomic && echo YES || echo NO)
+ )
+ cmake_src_configure
+}
+
src_install() {
# TODO: install manpage: https://github.com/ccache/ccache/issues/684
cmake_src_install
diff --git a/dev-util/ccache/files/ccache-4.0-atomic.patch b/dev-util/ccache/files/ccache-4.0-atomic.patch
new file mode 100644
index 000000000000..87b237c7dd56
--- /dev/null
+++ b/dev-util/ccache/files/ccache-4.0-atomic.patch
@@ -0,0 +1,21 @@
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -63,11 +63,17 @@ if(WIN32)
+ endif()
+ endif()
+
++option(LINK_WITH_ATOMIC "Add 'atomic' if needed" OFF)
++set(atomic_lib "")
++if(LINK_WITH_ATOMIC)
++ set(atomic_lib "atomic")
++endif()
++
+ find_package(Threads REQUIRED)
+ target_link_libraries(
+ ccache_lib
+ PRIVATE standard_settings standard_warnings ZSTD::ZSTD
+- Threads::Threads third_party_lib)
++ Threads::Threads third_party_lib ${atomic_lib})
+
+ target_include_directories(ccache_lib PRIVATE ${CMAKE_BINARY_DIR} .)
+