Re: failure of pructl (atexit/_Block_copy/--no-allow-shlib-undefined)
- In reply to: Kyle Evans : "Re: failure of pructl (atexit/_Block_copy/--no-allow-shlib-undefined)"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 02 Dec 2021 10:23:37 UTC
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:
>>
>> Hello,
>>
>> It seems like the recent changes to make --no-allow-shlib-undefined
>> broke pructl.
>>
>> 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=c99 -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)
>>
>> 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.
>>
>
> 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