kripken/emscripten — pull request #2342 by rsturgell (2014-05-08 20:19:21+00:00)
Title: Add archive groups support

emcc now understands `-Wl,--start-group` (or `-Wl,-(`) and `-Wl,--end-group`
(or `-Wl,-)`) to group static libraries. Static libraries in a group need not
be specified in dependent to dependency order and can have circular
dependencies.

There should be no impact when not using these flags EXCEPT that a bug in
library handling was fixed: emcc used to pull the `-l...` flags out and append
the resolved libraries to the end of the linker args, which I believe is
incorrect.

For example, suppose you have two object files a.o and b.o which both provide
the same symbol "s". If b.o is in an archive libb.a, then:

```
emcc -L. -lb a.o
```

_should_ use b.o (from b.a) and _not_ a.o (to satisfy symbol s), but emcc
shuffles b.a to the end of the list for linking, so a.o is incorrectly selected
for symbol s. In fact test_mutliply_defined_libsymbols_2 did just this, so I
had to rearrange the arguments in that test (moving the lib after the o) -
hopefully that test is still meaningful.

I also added a couple simple tests, but there's obviously a lot more I could
test, let me know if I should. Ideally I would unit test the core logic instead
of actually compiling (which is very slow), is that done in these tests?