Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 21994

does gcc link order affect speed of the program execution

$
0
0

I know the linkage order in gcc is important for symbols to be correctly determined; but now I am seeing a weird speed issue on the resulting executable. I am linking objects and archieves as

g++ -m32 a.o b.o ar1.a ar2.a -lm -lpthread -lcrypt -lz -pthread -o afast.out

vs

g++ -m32 a.o ar1.a b.o ar2.a -lm -lpthread -lcrypt -lz -pthread -o aslow.out

The second version runs 2x slower. b.o is actually in the ar1.a archieve, but ar2.o has references to it, thus linker complains, thus I had to put the b.o. In the beginning, I was putting b.o all the way to the end of the linkage to make the correct dependency order, though then figured out it even works at beginning, and even faster.

Has anyone experienced this? Is object file linkage order different than archieve order? How can there be any speed impact?

getting similar results with gcc3.4.6 or gcc4.1.2


Viewing all articles
Browse latest Browse all 21994

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>