Charlene,

Thanks. This looks good to me (maintainer).

Cheers,

Ash

On Tue, 19 Jan 2021 at 10:14, Charlene Wendling <juliana...@posteo.jp> wrote:
>
> Hi,
>
> > http://build-failures.rhaalovely.net/mips64/2021-01-12/devel/fmt.log
> (and the same in the current bulk for the other clang+ld.bfd arch,
> macppc)
>
> As often '-Wl,--as-needed' causes undefined reference errors with
> ld.bfd. Surprisingly gcc archs are not impacted.
>
> target_link_libraries() takes precedence over our LDFLAGS, so i could
> not use them.
>
> Sadly cmake has not meson's 'b_asneeded' out of the box, so i've added
> an AS_NEEDED option, which is ON by default, bringing no change
> to clang+ld.lld archs, and turn it OFF on clang+ld.bfd archs.
>
> That also means no REVISION bump is needed (fmt has never been built on
> impacted archs).
>
> With the below diff i can build fmt and pass its tests on macppc [0].
> mips64 seems to have further problems, i'm not 100% positive it would
> fix the build there.
>
> I would be happy to upstream this, but it seems they preferred an OS
> centric approach which doesn't play nice with our situation.
>
> Comments and feedback are welcome,
>
> Charlène.
>
>
> [0] https://bin.charlenew.xyz/fmt.log
>
>
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/devel/fmt/Makefile,v
> retrieving revision 1.1.1.1
> diff -u -p -u -p -r1.1.1.1 Makefile
> --- Makefile    2 Jan 2021 21:51:19 -0000       1.1.1.1
> +++ Makefile    19 Jan 2021 14:59:19 -0000
> @@ -23,4 +23,11 @@ WANTLIB+=            ${COMPILER_LIBCXX}
>
>  CONFIGURE_ARGS+=       -DBUILD_SHARED_LIBS=on
>
> +# Fix undefined references to pthread_* symbols on clang+ld.bfd archs by
> +# disabling -Wl,--as-needed.
> +.include <bsd.port.arch.mk>
> +.if !${PROPERTIES:Mlld} && ${PROPERTIES:Mclang}
> +CONFIGURE_ARGS+=       -DAS_NEEDED=off
> +.endif
> +
>  .include <bsd.port.mk>
> Index: patches/patch-CMakeLists_txt
> ===================================================================
> RCS file: patches/patch-CMakeLists_txt
> diff -N patches/patch-CMakeLists_txt
> --- /dev/null   1 Jan 1970 00:00:00 -0000
> +++ patches/patch-CMakeLists_txt        19 Jan 2021 14:59:19 -0000
> @@ -0,0 +1,26 @@
> +$OpenBSD$
> +
> +Allow linking without '-Wl,--as-needed', fix the build on clang+ld.bfd archs.
> +It's needed to do it like this since target_link_libraries takes preference
> +over LDFLAGS.
> +
> +Index: CMakeLists.txt
> +--- CMakeLists.txt.orig
> ++++ CMakeLists.txt
> +@@ -59,6 +59,7 @@ set_verbose(FMT_INC_DIR ${CMAKE_INSTALL_INCLUDEDIR} CA
> + option(FMT_PEDANTIC "Enable extra warnings and expensive tests." OFF)
> + option(FMT_WERROR "Halt the compilation with an error on compiler warnings."
> +        OFF)
> ++option(AS_NEEDED "Use -Wl,--as-needed for linking." ON)
> +
> + # Options that control generation of various targets.
> + option(FMT_DOC "Generate the doc target." ${MASTER_PROJECT})
> +@@ -233,7 +234,7 @@ endif ()
> +
> + if (BUILD_SHARED_LIBS)
> +   if (UNIX AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND
> +-      NOT EMSCRIPTEN)
> ++      NOT EMSCRIPTEN AND AS_NEEDED)
> +     # Fix rpmlint warning:
> +     # unused-direct-shlib-dependency /usr/lib/libformat.so.1.1.0 
> /lib/libm.so.6.
> +     target_link_libraries(fmt -Wl,--as-needed)

Reply via email to