[Lldb-commits] [PATCH] D29333: [CMake] Add accurate dependency specifications
Pavel Labath via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Jan 31 11:43:43 PST 2017
labath added a comment.
In https://reviews.llvm.org/D29333#661994, @beanz wrote:
> In https://reviews.llvm.org/D29333#661979, @labath wrote:
>
> > I was thinking about that as well. I am not sure if it will work if we actually need multiple iterations of the loop to get all the dependencies converging, but it may be worth trying out.
>
>
> The way it is supposed to work, CMake will duplicate the libraries on the command line in the right order to avoid the need for looping at all.
I am not sure that is enough. Imagine this:
X.a(x1.o x2.o)
Y.a(y1.o y2.o)
if X depends on Y and vice-versa, cmake will add something like -lX -lY -lX
however, if the dependency graph is something like:
main.o -> x1.o -> y1.o -> x2.o -> y2.o
then this won't be enough because by the time the linker figures out it really needs y2.o it will already have scanned past the -lY, and the link will still fail. It this example it is enough to repeat all libraries twice, but in theory the chain can be arbitrarily long and cmake has no way of figuring that out.
labath4 /tmp/X $ nm x.a
x1.o:
0000000000000000 T _x1
U _y1
x2.o:
0000000000000000 T _x2
U _y2
labath4 /tmp/X $ nm y.a
y1.o:
U _x2
0000000000000000 T _y1
y2.o:
0000000000000000 T _y2
labath4 /tmp/X $ gcc main.c
/tmp/ccAoBLxC.o: In function `main':
main.c:(.text+0xa): undefined reference to `_x1'
collect2: error: ld returned 1 exit status
labath4 /tmp/X $ gcc main.c x.a y.a x.a
x.a(x2.o): In function `_x2':
a.c:(.text+0xa): undefined reference to `_y2'
collect2: error: ld returned 1 exit status
labath4 /tmp/X $ gcc main.c x.a y.a x.a y.a && echo OK
OK
That said, maybe the situation in lldb is not so dire, and it will actually work -- only one way to find out.
https://reviews.llvm.org/D29333
More information about the lldb-commits
mailing list