about summary refs log tree commit diff
path: root/src/test/ui/thinlto
diff options
context:
space:
mode:
authorDouglas Creager <dcreager@github.com>2018-12-20 15:46:42 -0500
committerDouglas Creager <dcreager@github.com>2018-12-20 16:01:32 -0500
commitd445e1ccaa18e501870dd4cf52f41980b7260c2c (patch)
tree9d4ec82cdcdce3f5eab4cf4e4dc455870d954514 /src/test/ui/thinlto
parent4755e2f3b635ad7391ba88b18672b05cbae5ba4c (diff)
downloadrust-d445e1ccaa18e501870dd4cf52f41980b7260c2c.tar.gz
rust-d445e1ccaa18e501870dd4cf52f41980b7260c2c.zip
Keep last redundant linker flag, not first
When a library (L1) is passed to the linker multiple times, this is
sometimes purposeful: there might be several other libraries in the
linker command (L2 and L3) that all depend on L1.  You'd end up with a
(simplified) linker command that looks like:

    -l2 -l1 -l3 -l1

With the previous behavior, when rustc encountered a redundant library,
it would keep the first instance, and remove the later ones, resulting
in:

    -l2 -l1 -l3

This can cause a linker error, because on some platforms (e.g. Linux),
the linker will only include symbols from L1 that are needed *at the
point it's referenced in the command line*.  So if L3 depends on
additional symbols from L1, which aren't needed by L2, the linker won't
know to include them, and you'll end up with "undefined symbols" errors.

A better behavior is to keep the *last* instance of the library:

    -l2 -l3 -l1

This ensures that all "downstream" libraries have been included in the
linker command before the "upstream" library is referenced.

Fixes rust-lang#47989
Diffstat (limited to 'src/test/ui/thinlto')
0 files changed, 0 insertions, 0 deletions