Would gcc -O take effect for linked static library?

Viewed 67

such as:

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

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

1 Answers

-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.

Related