How to support circular dependencies (-Wl,--start-group & -Wl,--end-group)

698 views
Skip to first unread message

Fabio Porcedda

unread,
Feb 14, 2017, 6:05:57 AM2/14/17
to The Meson Build System
Hi all,

to support circular dependencies i need to put "-Wl,--start-group" and "'-Wl,--end-group" around the objects to links in the linker command line.

I've added the "'-Wl,--end-group" in the "link_args" in the "executable" command, but i don't know how to add properly the "-Wl,--start-group", in the mean time I've changed manually the "build.ninja" file at the line:

command = /opt/altair/br_mips-2013.11/usr/bin/mips-linux-gcc $ARGS -o $out $in $LINK_ARGS  $aliasing

=>

command = /opt/altair/br_mips-2013.11/usr/bin/mips-linux-gcc $ARGS -o $out -Wl,--start-group $in $LINK_ARGS  $aliasing

What is the best way to add the "-Wl,--start-group" in the linker command line before the "$in" argument?

I know the best solution is to fix the circular dependency, i hope to fix them in the future, but right now i have to support them.

Thanks and best regards
Fabio Porcedda

Fabio Porcedda

unread,
Feb 15, 2017, 8:26:13 AM2/15/17
to The Meson Build System
I will try to add a new keyword argument "link_args_pre"  to the "execute" function to be able to add arguments at the beginning.

Jussi Pakkanen

unread,
Feb 15, 2017, 8:38:48 AM2/15/17
to Fabio Porcedda, The Meson Build System
On Wed, Feb 15, 2017 at 3:26 PM, Fabio Porcedda
<fabio.p...@gmail.com> wrote:

> I will try to add a new keyword argument "link_args_pre" to the "execute"
> function to be able to add arguments at the beginning.

This probably needs higher level support, because different compilers
do it differently with different arguments. We aim to provide simple
general solutions rather than adding a ton of customisation points and
having every end user fight with the underlying tools themselves.

However if you only have a simple circular dependency A -> B -> A,
then there is a simpler solution. Just put the libraries there
multiple times, like so:

executable(..., links_with : [liba, libb, liba])

Fabio Porcedda

unread,
Feb 15, 2017, 9:04:52 AM2/15/17
to Jussi Pakkanen, The Meson Build System
That doesn't work, because the circular dependency is between a
library and project source code.

I managed to add the keyword argument "link_args_pre" to the
"executable" function, that solution works fine for me, i will make a
pull request for that.

Thanks
--
Fabio Porcedda
Reply all
Reply to author
Forward
0 new messages