[clang+ld.bfd] Unbreak devel/fmt

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[clang+ld.bfd] Unbreak devel/fmt

Charlene Wendling
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 | Threaded
Open this post in threaded view
|

Re: [clang+ld.bfd] Unbreak devel/fmt

Janne Johansson-3
Den tis 19 jan. 2021 kl 16:16 skrev Charlene Wendling <[hidden email]>:
> > 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)
>
> 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.
>

make test fails one of them on mips64
 5/15 Test  #5: gtest-extra-test .................   Passed    0.07 sec
      Start  6: format-test
 6/15 Test  #6: format-test ......................***Failed    0.80 sec
      Start  7: format-impl-test
 7/15 Test  #7: format-impl-test .................   Passed    0.18 sec
      Start  8: locale-test
 8/15 Test  #8: locale-test ......................   Passed    0.05 sec
      Start  9: ostream-test
 9/15 Test  #9: ostream-test .....................   Passed    0.06 sec
      Start 10: compile-test
10/15 Test #10: compile-test .....................   Passed    0.05 sec
      Start 11: printf-test
11/15 Test #11: printf-test ......................   Passed    0.09 sec
      Start 12: ranges-test
12/15 Test #12: ranges-test ......................   Passed    0.04 sec
      Start 13: scan-test
13/15 Test #13: scan-test ........................   Passed    0.05 sec
      Start 14: posix-mock-test
14/15 Test #14: posix-mock-test ..................   Passed    0.05 sec
      Start 15: os-test
15/15 Test #15: os-test ..........................   Passed    0.19 sec

93% tests passed, 1 tests failed out of 15

Total Test time (real) =   1.99 sec
The following tests FAILED:

          6 - format-test (Failed)

Errors while running CTest


--
May the most significant bit of your life be positive.

Reply | Threaded
Open this post in threaded view
|

Re: [clang+ld.bfd] Unbreak devel/fmt

Charlene Wendling
On Wed, 20 Jan 2021 18:25:22 +0100
Janne Johansson <[hidden email]> wrote:

> Den tis 19 jan. 2021 kl 16:16 skrev Charlene Wendling
> <[hidden email]>:
> > > 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)
> >
> > 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.
> >
>
> make test fails one of them on mips64
>  5/15 Test  #5: gtest-extra-test .................   Passed    0.07
> sec Start  6: format-test
>  6/15 Test  #6: format-test ......................***Failed    0.80
> sec Start  7: format-impl-test
>  7/15 Test  #7: format-impl-test .................   Passed    0.18
> sec Start  8: locale-test
>  8/15 Test  #8: locale-test ......................   Passed    0.05
> sec Start  9: ostream-test
>  9/15 Test  #9: ostream-test .....................   Passed    0.06
> sec Start 10: compile-test
> 10/15 Test #10: compile-test .....................   Passed    0.05
> sec Start 11: printf-test
> 11/15 Test #11: printf-test ......................   Passed    0.09
> sec Start 12: ranges-test
> 12/15 Test #12: ranges-test ......................   Passed    0.04
> sec Start 13: scan-test
> 13/15 Test #13: scan-test ........................   Passed    0.05
> sec Start 14: posix-mock-test
> 14/15 Test #14: posix-mock-test ..................   Passed    0.05
> sec Start 15: os-test
> 15/15 Test #15: os-test ..........................   Passed    0.19
> sec
>
> 93% tests passed, 1 tests failed out of 15
>
> Total Test time (real) =   1.99 sec
> The following tests FAILED:
>
>           6 - format-test (Failed)
>
> Errors while running CTest

Aw.

It would be nice to share $WRKBUILD/Testing/Temporary/LastTest.log
i guess.

> --
> May the most significant bit of your life be positive.
>

Reply | Threaded
Open this post in threaded view
|

Re: [clang+ld.bfd] Unbreak devel/fmt

Janne Johansson-3
Here,

http://c66.it.su.se:8080/obsd/LastTest.log

Den ons 20 jan. 2021 kl 18:49 skrev Charlene Wendling <[hidden email]>:

>
> On Wed, 20 Jan 2021 18:25:22 +0100
> Janne Johansson <[hidden email]> wrote:
>
> > Den tis 19 jan. 2021 kl 16:16 skrev Charlene Wendling
> > <[hidden email]>:
> > > > 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)
> > >
> > > 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.
> > >
> >
> > make test fails one of them on mips64
> >  5/15 Test  #5: gtest-extra-test .................   Passed    0.07
> > sec Start  6: format-test
> >  6/15 Test  #6: format-test ......................***Failed    0.80
> > sec Start  7: format-impl-test
> >  7/15 Test  #7: format-impl-test .................   Passed    0.18
> > sec Start  8: locale-test
> >  8/15 Test  #8: locale-test ......................   Passed    0.05
> > sec Start  9: ostream-test
> >  9/15 Test  #9: ostream-test .....................   Passed    0.06
> > sec Start 10: compile-test
> > 10/15 Test #10: compile-test .....................   Passed    0.05
> > sec Start 11: printf-test
> > 11/15 Test #11: printf-test ......................   Passed    0.09
> > sec Start 12: ranges-test
> > 12/15 Test #12: ranges-test ......................   Passed    0.04
> > sec Start 13: scan-test
> > 13/15 Test #13: scan-test ........................   Passed    0.05
> > sec Start 14: posix-mock-test
> > 14/15 Test #14: posix-mock-test ..................   Passed    0.05
> > sec Start 15: os-test
> > 15/15 Test #15: os-test ..........................   Passed    0.19
> > sec
> >
> > 93% tests passed, 1 tests failed out of 15
> >
> > Total Test time (real) =   1.99 sec
> > The following tests FAILED:
> >
> >           6 - format-test (Failed)
> >
> > Errors while running CTest
>
> Aw.
>
> It would be nice to share $WRKBUILD/Testing/Temporary/LastTest.log
> i guess.
>
> > --
> > May the most significant bit of your life be positive.
> >



--
May the most significant bit of your life be positive.

Reply | Threaded
Open this post in threaded view
|

Re: [clang+ld.bfd] Unbreak devel/fmt

Charlene Wendling
On Wed, 20 Jan 2021 22:24:45 +0100
Janne Johansson <[hidden email]> wrote:

> Here,
>
> http://c66.it.su.se:8080/obsd/LastTest.log

Thanks! I was watching upstream bug reports and it's not the first
time they have similar issues with that test. I'm not sure if the
right course of action is to undef FMT_USE_INT128 for mips64 in
$WRKSRC/include/fmt/core.h.

> Den ons 20 jan. 2021 kl 18:49 skrev Charlene Wendling
> <[hidden email]>:
> >
> > On Wed, 20 Jan 2021 18:25:22 +0100
> > Janne Johansson <[hidden email]> wrote:
> >
> > > Den tis 19 jan. 2021 kl 16:16 skrev Charlene Wendling
> > > <[hidden email]>:
> > > > > 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)
> > > >
> > > > 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.
> > > >
> > >
> > > make test fails one of them on mips64
> > >  5/15 Test  #5: gtest-extra-test .................   Passed
> > > 0.07 sec Start  6: format-test
> > >  6/15 Test  #6: format-test ......................***Failed
> > > 0.80 sec Start  7: format-impl-test
> > >  7/15 Test  #7: format-impl-test .................   Passed
> > > 0.18 sec Start  8: locale-test
> > >  8/15 Test  #8: locale-test ......................   Passed
> > > 0.05 sec Start  9: ostream-test
> > >  9/15 Test  #9: ostream-test .....................   Passed
> > > 0.06 sec Start 10: compile-test
> > > 10/15 Test #10: compile-test .....................   Passed
> > > 0.05 sec Start 11: printf-test
> > > 11/15 Test #11: printf-test ......................   Passed
> > > 0.09 sec Start 12: ranges-test
> > > 12/15 Test #12: ranges-test ......................   Passed
> > > 0.04 sec Start 13: scan-test
> > > 13/15 Test #13: scan-test ........................   Passed
> > > 0.05 sec Start 14: posix-mock-test
> > > 14/15 Test #14: posix-mock-test ..................   Passed
> > > 0.05 sec Start 15: os-test
> > > 15/15 Test #15: os-test ..........................   Passed
> > > 0.19 sec
> > >
> > > 93% tests passed, 1 tests failed out of 15
> > >
> > > Total Test time (real) =   1.99 sec
> > > The following tests FAILED:
> > >
> > >           6 - format-test (Failed)
> > >
> > > Errors while running CTest
> >
> > Aw.
> >
> > It would be nice to share $WRKBUILD/Testing/Temporary/LastTest.log
> > i guess.
> >
> > > --
> > > May the most significant bit of your life be positive.
> > >
>
>
>
> --
> May the most significant bit of your life be positive.
>

Reply | Threaded
Open this post in threaded view
|

Re: [clang+ld.bfd] Unbreak devel/fmt

Jeremie Courreges-Anglas-2
In reply to this post by Charlene Wendling
On Tue, Jan 19 2021, Charlene Wendling <[hidden email]> 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,

IIRC this is a bug in binutils, and it's not likely to be fixed soon.

cmake itself provides
https://cmake.org/cmake/help/latest/prop_tgt/LINK_WHAT_YOU_USE.html but
I doubt that it would help us autodetect that --as-needed doesn't work.

An alternative would be to just strip --as-needed on all archs and keep
that as a local patch (we probably don't care about the improvements
from --as-needed).  But your approach makes sense too.  ok jca@ fwiw

--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply | Threaded
Open this post in threaded view
|

Re: [clang+ld.bfd] Unbreak devel/fmt

Ashton Fagg
In reply to this post by Charlene Wendling
Charlene,

Thanks. This looks good to me (maintainer).

Cheers,

Ash

On Tue, 19 Jan 2021 at 10:14, Charlene Wendling <[hidden email]> 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)