Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Dec 2021 11:23:37 +0100
From:      Dimitry Andric <dim@FreeBSD.org>
To:        Kyle Evans <kevans@FreeBSD.org>
Cc:        FreeBSD Current <freebsd-current@freebsd.org>, Jessica Clarke <jrtc27@freebsd.org>
Subject:   Re: failure of pructl (atexit/_Block_copy/--no-allow-shlib-undefined)
Message-ID:  <D849A463-DC08-41EB-BC4B-D8A028BAC667@FreeBSD.org>
In-Reply-To: <CACNAnaEOmpuJX4yi%2BEFP2NLnv9srC4C5anmfO7mseG_HFfzy%2BA@mail.gmail.com>
References:  <20211202020326.GU35602@funkthat.com> <CACNAnaEOmpuJX4yi%2BEFP2NLnv9srC4C5anmfO7mseG_HFfzy%2BA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--Apple-Mail=_43BB1695-2407-43C1-8516-107F604811E0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

On 2 Dec 2021, at 06:42, Kyle Evans <kevans@FreeBSD.org> wrote:
> On Wed, Dec 1, 2021 at 8:05 PM John-Mark Gurney <jmg@funkthat.com> =
wrote:
>>=20
>> Hello,
>>=20
>> It seems like the recent changes to make --no-allow-shlib-undefined
>> broke pructl.
>>=20
>> lib/libc/stdlib/atexit.c uses a weak _Block_copy symbol, but
>> pructl does not use atexit_b, and yet gets the following error:
>> : && /usr/bin/cc -Werror -O2 -pipe  -fstack-protector-strong -isystem =
/usr/local/include -fno-strict-aliasing -std=3Dc99 =
-fstack-protector-strong CMakeFiles/pructl.dir/pructl.c.o -o pructl  =
-Wl,-rpath,/usr/local/lib:  /usr/local/lib/libpru.so && :
>> ld: error: /lib/libc.so.7: undefined reference to _Block_copy =
[--no-allow-shlib-undefined]
>> cc: error: linker command failed with exit code 1 (use -v to see =
invocation)
>>=20
>> What is the correct fix?  It seems like atexit.c or the linker should
>> be fixed, as pructl doesn't use atexit_b at all.
>>=20
>=20
> CC dim@ and jrtc27@... this seems like a toolchain regression? We're
> relying on the address of weak _Block_copy to simply evaluate to NULL
> if it's undefined here, which seems legit and pretty well-defined at
> this point from my recollection.

Naive patch, which appears to work:

diff --git a/devel/pructl/files/patch-CMakeLists.txt =
b/devel/pructl/files/patch-CMakeLists.txt
index f378dd44e6f6..8a41cc91aba8 100644
--- a/devel/pructl/files/patch-CMakeLists.txt
+++ b/devel/pructl/files/patch-CMakeLists.txt
@@ -1,9 +1,16 @@
 --- CMakeLists.txt.orig	2018-12-24 20:28:37 UTC
 +++ CMakeLists.txt
-@@ -8,5 +8,5 @@ find_library(libedit NAMES edit)
+@@ -4,9 +4,10 @@ add_executable(pructl pructl.c)
+ add_executable(prudbg prudbg.c)
+ include_directories(/usr/local/include ${CMAKE_SOURCE_DIR}/../libpru)
+ find_library(libpru  NAMES pru PATHS /usr/local/lib =
${CMAKE_SOURCE_DIR}/../libpru/build)
++find_library(libBlocksRuntime NAMES BlocksRuntime)
+ find_library(libedit NAMES edit)
  find_library(libutil NAMES util)
- target_link_libraries(pructl ${libpru})
- target_link_libraries(prudbg ${libpru} ${libedit} ${libutil})
+-target_link_libraries(pructl ${libpru})
+-target_link_libraries(prudbg ${libpru} ${libedit} ${libutil})
 -set(CMAKE_C_FLAGS "-Weverything -Werror")
++target_link_libraries(pructl ${libpru} ${libBlocksRuntime})
++target_link_libraries(prudbg ${libpru} ${libBlocksRuntime} ${libedit} =
${libutil})
 +set(CMAKE_C_FLAGS "-Werror")
  install(TARGETS pructl prudbg DESTINATION sbin)

-Dimitry


--Apple-Mail=_43BB1695-2407-43C1-8516-107F604811E0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename=signature.asc
Content-Type: application/pgp-signature;
	name=signature.asc
Content-Description: Message signed with OpenPGP

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.2

iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCYaieqQAKCRCwXqMKLiCW
o8BQAJ9ugzkvc0g6gFofIgxiYSqP69iUiwCg7fZv2BHLWvK7iWTSBTSdqpQ4yhY=
=ilTB
-----END PGP SIGNATURE-----

--Apple-Mail=_43BB1695-2407-43C1-8516-107F604811E0--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?D849A463-DC08-41EB-BC4B-D8A028BAC667>