Created attachment 8391 [details]
minimized test case
Test case attached. Essentially the problem occurs when there is a symbol `foo` that is hidden in the main executable, used in liba, and public in libb when liba is linked before libb. Note that this does actually only occur for the main executable; it won't happen when linking a library.
clang++ -fuse-ld=gold -fPIC -shared -o libbar.so bar.cpp
clang++ -fuse-ld=gold -fPIC -shared -o libfoo.so foo.cpp -L. -lbar
clang++ -fuse-ld=gold -Wl,--fatal-warnings -shared -o baz baz.cpp -L. -lfoo -lbar
/usr/bin/ld.gold: warning: hidden symbol 'foo()' in /tmp/baz-6c2f17.o is referenced by DSO ./libfoo.so
/usr/bin/ld.gold: error: treating warnings as errors
clang-3.6: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [baz] Error 1
`foo` is hidden in the main executable, but is public in libbar.so.
Duplicate of PR 15574.
*** This bug has been marked as a duplicate of bug 15574 ***