* Peter Rosin wrote on Wed, Aug 13, 2008 at 10:12:23PM CEST: >> 24: link-order.at:26 Link order test. >> Exporting int c variable. > > With MSVC, you can declare any variable with __decspec(dllimport), even > if you are not actually importing it. The only thing that happens is > that you get an extra indirection in the generated code. This is a > small price to pay,
The relative cost of extra indirection quite depends on the way it is used. To give you an extreme, but real-world example, using Autoconf with the master branch of GNU m4 is 15% slower with PIC code than without (for an example package; this amounts to 4 seconds), on GNU/Linux. That's basically the overhead of having to go through the GOT indirection. (Disclaimer: I haven't tried to use PIC objects in a static link.) I don't know whether the dllimport indirection is as costly though. Of course for our examples in the test suite it's not the overhead that matters. > when the gain is that you don't need to compile > things differently depending on how you are going to link with the > library. The situation is quite similar to pic/non-pic, but the trouble > is that the difference is in the library consumer and not when > producing the library. Yep. > So, ignoring the runtime performance penalty, patch things up like > this: Thanks, please apply. Cheers, Ralf > 2008-08-13 Peter Rosin <[EMAIL PROTECTED]> > > * tests/link-order.at [MSVC]: Always dllimport exported > variables.
