summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifeng Li <tomli@tomli.me>2023-05-16 23:11:24 +0200
committerDavid Seifert <soap@gentoo.org>2023-05-16 23:11:24 +0200
commite442bb64a57259f89e12d901c8fe23a5abe62a76 (patch)
treeef791f1e83c2a5dc635f7e1b96c47abadd55434a
parentprofiles: remove dead implicit userland_* flags (diff)
downloadgentoo-e442bb64a57259f89e12d901c8fe23a5abe62a76.tar.gz
gentoo-e442bb64a57259f89e12d901c8fe23a5abe62a76.tar.bz2
gentoo-e442bb64a57259f89e12d901c8fe23a5abe62a76.zip
dev-libs/boost: fix build on macOS / Apple Silicon
This commits fix three problems in existing Boost 1.82.0 ebuilds, allowing one to install Boost on macOS, including Apple Silicon. 1. Boost wants to build static library, which is unsupported on macOS. Using the unmodified ebuild, Boost fails because the build system wants to pass the "-static" flag to ar, but this option (and static linking in general) is unsupported by macOS, creating this error message: arm64-apple-darwin22-ar: only one of -a and -[bi] options allowed It turned out that "toolset=darwin" is actually broken in Boost [1] and has even been removed from Boost since 2019 [2]. Thus, the fix is to remove the option compiler="darwin". 2. error: O_LARGEFILE was not declared in this scope It appears that on modern macOS, 64-bit file I/O is already the default, and there's no special support for options like O_LARGEFILE. Thus, on on Darwin, we avoid running the command append-lfs-flags. 3. invalid install_name found, your application or library will crash at runtime To fix the broken install_name and references, a hack is used on Darwin to find a list paths. The original command began with "grep ^libboost" to match a library name at the beginning of the output of "otool -XL". But for some reason, the library names now include a path prefix, such as: bin.v2/libs/thread/build/gcc-12.1/gentoorelease/pch-off/ threadapi-pthread/threading-multi/visibility-hidden/ libboost_thread.dylib Thus, matching at the beginning of the line no longer works. To fix the problem, we instead use "grep libboost" to allow lines with a path prefix to be matched as well. We then extract the basename the filename from the path. [1] https://web.archive.org/web/20160713132921/https://svn.boost.org/trac/boost/ticket/9772#comment:19 [2] https://github.com/boostorg/build/issues/528 Closes: https://github.com/gentoo/gentoo/pull/30758 Closes: https://bugs.gentoo.org/904983 Signed-off-by: Yifeng Li <tomli@tomli.me> Signed-off-by: David Seifert <soap@gentoo.org>
-rw-r--r--dev-libs/boost/boost-1.82.0.ebuild36
1 files changed, 23 insertions, 13 deletions
diff --git a/dev-libs/boost/boost-1.82.0.ebuild b/dev-libs/boost/boost-1.82.0.ebuild
index efe85c331913..30ce182a1f86 100644
--- a/dev-libs/boost/boost-1.82.0.ebuild
+++ b/dev-libs/boost/boost-1.82.0.ebuild
@@ -16,7 +16,7 @@ S="${WORKDIR}/${PN}_${MY_PV}"
LICENSE="Boost-1.0"
SLOT="0/${PV}" # ${PV} instead of the major version due to bug 486122
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris ~x86-winnt"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris ~x86-winnt"
IUSE="bzip2 context debug doc icu lzma +nls mpi numpy python tools zlib zstd"
REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
# the tests will never fail because these are not intended as sanity
@@ -71,13 +71,8 @@ create_user-config.jam() {
fi
local compiler compiler_version compiler_executable="$(tc-getCXX)"
- if [[ ${CHOST} == *-darwin* ]]; then
- compiler="darwin"
- compiler_version="$(gcc-fullversion)"
- else
- compiler="gcc"
- compiler_version="$(gcc-version)"
- fi
+ compiler="gcc"
+ compiler_version="$(gcc-version)"
if use mpi; then
local mpi_configuration="using mpi ;"
@@ -194,8 +189,15 @@ src_configure() {
# Use C++17 globally as of 1.80
append-cxxflags -std=c++17
- # need to enable LFS explicitly for 64-bit offsets on 32-bit hosts (#894564)
- append-lfs-flags
+ if [[ ${CHOST} != *-darwin* ]]; then
+ # On modern macOS, file I/O is already 64-bit by default,
+ # there's no support for special options like O_LARGEFILE.
+ # Thus, LFS must be disabled.
+ #
+ # On other systems, we need to enable LFS explicitly for 64-bit
+ # offsets on 32-bit hosts (#894564)
+ append-lfs-flags
+ fi
}
multilib_src_compile() {
@@ -242,16 +244,24 @@ multilib_src_install() {
install_name_tool -id "/${d#${D}}" "${d}"
eend $?
# fix references to other libs
+ # these paths look like this:
+ # bin.v2/libs/thread/build/gcc-12.1/gentoorelease/pch-off/
+ # threadapi-pthread/threading-multi/visibility-hidden/
+ # libboost_thread.dylib
refs=$(otool -XL "${d}" | \
sed -e '1d' -e 's/^\t//' | \
- grep "^libboost_" | \
+ grep "libboost_" | \
cut -f1 -d' ')
local r
for r in ${refs}; do
- ebegin " correcting reference to ${r}"
+ # strip path prefix from references, so we obtain
+ # something like libboost_thread.dylib.
+ local r_basename=${r##*/}
+
+ ebegin " correcting reference to ${r_basename}"
install_name_tool -change \
"${r}" \
- "${EPREFIX}/usr/lib/${r}" \
+ "${EPREFIX}/usr/lib/${r_basename}" \
"${d}"
eend $?
done