dev-util/b2: Sync with Gentoo

It's from Gentoo commit 2532659389b878a296a487663d21f8c3396dd3c7.
This commit is contained in:
Flatcar Buildbot 2023-02-27 07:22:37 +00:00 committed by Krzesimir Nowak
parent f5aec429d2
commit 97dbf53633
2 changed files with 122 additions and 0 deletions

View File

@ -0,0 +1,67 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit edo flag-o-matic toolchain-funcs
MY_PV="$(ver_rs 1- _)"
DESCRIPTION="A system for large project software construction, simple to use and powerful"
HOMEPAGE="https://www.bfgroup.xyz/b2/"
SRC_URI="https://github.com/bfgroup/b2/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz"
S="${WORKDIR}/${P}/src"
LICENSE="Boost-1.0"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
IUSE="examples"
RESTRICT="test"
RDEPEND="!dev-util/boost-build"
PATCHES=(
"${FILESDIR}"/${PN}-4.9.2-disable_python_rpath.patch
"${FILESDIR}"/${PN}-4.9.2-darwin-gentoo-toolchain.patch
"${FILESDIR}"/${PN}-4.9.2-add-none-feature-options.patch
"${FILESDIR}"/${PN}-4.9.2-no-implicit-march-flags.patch
"${FILESDIR}"/${PN}-4.9.2-odr.patch
"${FILESDIR}"/${PN}-4.9.3-fix-apple-m1-crash-by-explicit-pointer-cast.patch
)
src_configure() {
# need to enable LFS explicitly for 64-bit offsets on 32-bit hosts (#761100)
append-lfs-flags
}
src_compile() {
cd engine || die
# upstream doesn't want separate flags for CPPFLAGS/LDFLAGS
# https://github.com/bfgroup/b2/pull/187#issuecomment-1335688424
edo ${CONFIG_SHELL:-${BASH}} ./build.sh cxx --cxx="$(tc-getCXX)" --cxxflags="${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}" -d+2 --without-python
}
src_test() {
# Forget tests, b2 is a lost cause
:
}
src_install() {
dobin engine/b2
insinto /usr/share/b2/src
doins -r "${FILESDIR}/site-config.jam" \
bootstrap.jam build-system.jam ../example/user-config.jam \
build kernel options tools util
find "${ED}"/usr/share/b2/src -iname '*.py' -delete || die
dodoc ../notes/{changes,release_procedure,build_dir_option,relative_source_paths}.txt
if use examples; then
docinto examples
dodoc -r ../example/.
docompress -x /usr/share/doc/${PF}/examples
fi
}

View File

@ -0,0 +1,55 @@
https://github.com/bfgroup/b2/issues/152
https://github.com/bfgroup/b2/pull/214
https://bugs.gentoo.org/895524
From 62dc6ff74a0b9717b4a8dd61ce06770e6fb7c177 Mon Sep 17 00:00:00 2001
From: Yifeng Li <tomli@tomli.me>
Date: Mon, 20 Feb 2023 09:52:32 +0000
Subject: [PATCH] Fix #152 crash on Apple M1 by casting 0 to (OBJECT *)
explicitly.
Currently, when the NULL-terminated variadic function call_rule()
is invoked, the value "0" is passed as the last argument to act
as a terminator. However, this is an integer value, which is
incompatible with the pointer data type expected by call_rule().
This is undefined behavior in C, correct operation is not
guaranteed. In fact, it causes b2 to crash on Apple M1 when GCC
is used - the loop is not terminated when it should, instead, it
keeps running, creating the following error:
> lol_add failed due to reached limit of 19 elements
In some cases, it can even corrupt the internal state of the program,
creating an infinite loop.
This commit fixes the problem by explicitly casting the value 0 to
the correct pointer type (OBJECT *).
Signed-off-by: Yifeng Li <tomli@tomli.me>
---
src/engine/modules/property-set.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/engine/modules/property-set.cpp b/src/engine/modules/property-set.cpp
index 6e190a7639..b0d3c2dab8 100644
--- src/engine/modules/property-set.cpp
+++ src/engine/modules/property-set.cpp
@@ -162,7 +162,7 @@ LIST * property_set_create( FRAME * frame, int flags )
OBJECT * rulename = object_new( "new" );
OBJECT * varname = object_new( "self.raw" );
LIST * val = call_rule( rulename, frame,
- list_new( object_new( "property-set" ) ), 0 );
+ list_new( object_new( "property-set" ) ), (OBJECT *) 0 );
LISTITER iter, end;
object_free( rulename );
pos->value = object_copy( list_front( val ) );
@@ -183,7 +183,7 @@ LIST * property_set_create( FRAME * frame, int flags )
import_module( imports, frame->module );
rulename = object_new( "errors.error" );
call_rule( rulename, frame,
- list_new( object_new( message->value ) ), 0 );
+ list_new( object_new( message->value ) ), (OBJECT *) 0 );
/* unreachable */
string_free( message );
list_free( imports );