summaryrefslogtreecommitdiff
blob: 6b0a91913e9c5a0c869acbd33feea63064e3bb68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

# These must be bumped together:
# dev-cpp/edencommon
# dev-cpp/folly
# dev-util/watchman

inherit cmake toolchain-funcs

DESCRIPTION="An open-source C++ library developed and used at Facebook"
HOMEPAGE="https://github.com/facebook/folly"
SRC_URI="https://github.com/facebook/folly/releases/download/v${PV}/${PN}-v${PV}.tar.gz"
S="${WORKDIR}"

LICENSE="Apache-2.0"
SLOT="0/${PV}"
KEYWORDS="amd64"
IUSE="llvm-libunwind test"
RESTRICT="!test? ( test )"

RDEPEND="app-arch/bzip2
	app-arch/lz4:=
	app-arch/snappy:=
	app-arch/xz-utils
	app-arch/zstd:=
	dev-cpp/gflags:=
	dev-cpp/glog:=[gflags]
	dev-libs/boost:=[context]
	dev-libs/double-conversion:=
	dev-libs/libaio
	dev-libs/libevent:=
	dev-libs/libfmt:=
	dev-libs/libsodium:=
	dev-libs/openssl:=
	>=sys-libs/liburing-2.2:=
	sys-libs/zlib
	llvm-libunwind? ( sys-libs/llvm-libunwind:= )
	!llvm-libunwind? ( sys-libs/libunwind:= )"
# libiberty is linked statically
DEPEND="${RDEPEND}
	sys-libs/binutils-libs
	test? ( dev-cpp/gtest )"
BDEPEND="test? ( sys-devel/clang )"

PATCHES=(
	"${FILESDIR}"/${PN}-2022.07.04.00-musl-fix.patch
)

pkg_setup() {
	[[ ${BUILD_TYPE} == binary ]] && return

	if use test && ! tc-is-clang ; then
		# Always build w/ Clang for now to avoid gcc ICE
		# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106230
		#if [[ $(gcc-major-version) -eq 12 ]] ; then
		#	return
		#fi

		## Only older GCC 11 is broken
		#if [[ $(gcc-major-version) -eq 11 && $(gcc-minor-version) -ge 3 && $(gcc-micro-version) -ge 1 ]] ; then
		#	return
		#fi

		ewarn "Forcing build with Clang due to GCC bug (because tests are enabled)"
		#ewarn "(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104008)"

		export CC=${CHOST}-clang
		export CXX=${CHOST}-clang++
	fi
}

src_configure() {
	# Fragile when changing compilers
	export CCACHE_DISABLE=1

	# TODO: liburing could in theory be optional but fails to link
	local mycmakeargs=(
		-DLIB_INSTALL_DIR="$(get_libdir)"

		-DBUILD_TESTS=$(usex test)
	)

	cmake_src_configure
}

src_test() {
	local myctestargs=(
		# - timeseries_histogram_test.TimeseriesHistogram.Percentile|HHWheelTimerTest
		# Long-standing known test failure
		# TODO: report upstream
		# - HHWheelTimerTest.HHWheelTimerTest.CancelTimeout
		# Timeouts are fragile
		-E "(timeseries_histogram_test.TimeseriesHistogram.Percentile|HHWheelTimerTest.HHWheelTimerTest.CancelTimeout)"
	)

	cmake_src_test
}