When using target_link_libraries it is important in which order you specify the linked libraries.
This does not work when using gcc (at least in version 4.0):
target_link_libraries(myapp m mylib)
while it works:
target_link_libraries(myapp mylib m)
Thus, all mylib libraries depend on what is needed after mylib.
If you track the call to the actual linker using make VERBOSE=1 , you will find this for a broken example:
gcc main.co -o luatest -rdynamic -lm mylib.a
and this is for the worker:
gcc main.co -o luatest -rdynamic mylib.a -lm
Calling clang with exactly the same parameters works in both cases!
So @PatrickB seems to be correct:
The clang component is perhaps intelligent and expects all calls to be bound before actually dropping the library during the reference process.
source share