Quite frankly - I don't know. Looking at the compiler code 
([pragmas.nim](https://github.com/nim-lang/Nim/blob/415689323c625afb7d39d923c4165a541beb9927/compiler/pragmas.nim#L1083)
 and 
[extccomp.nim](https://github.com/nim-lang/Nim/blob/415689323c625afb7d39d923c4165a541beb9927/compiler/extccomp.nim#L882))
 we can see that indeed entries from `externalToLink` (`link` pragma modifies 
it) are added first to the linker command and then the object files from nimc 
compilation. Lastly, other linking options are used - from `passl` pragma.

With default _GNU ld_ linker I don't see how it could work at all. If you'd use 
modern linkers like _lld_ or _mold_ ([symbol 
resolution](https://rui314.github.io/mold.html#Archive_symbol_resolution)) or 
even _MS link.exe_ \- you can forget about the linking order.

Reply via email to