diff options
-rw-r--r-- | dev-util/ccache/ccache-4.0.ebuild | 40 | ||||
-rw-r--r-- | dev-util/ccache/files/ccache-4.0-atomic.patch | 21 |
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} .) + |