nonkr
nonkr

Reputation: 61

Would gcc -O take effect for linked static library?

such as:

gcc test.c mystaticlib.a -o test -O2

would -O2 take effect for mystaticlib.a, or just test.c?

Upvotes: 3

Views: 72

Answers (1)

Mureinik
Mureinik

Reputation: 311498

-O2 is a compilation flag. The only input you're compiling in this example is test.c. mystaticlib.a is not compiled, but rather linked with the compilation output of test.c to create the executable test. Since mystaticlib.a isn't compiled here, the -O2 flag does not affect it.

Upvotes: 6

Related Questions