http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53777
Bug #: 53777 Summary: [lto] lto does not propagate optimization flags from command lines given at "compilation time" Classification: Unclassified Product: gcc Version: 4.7.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto AssignedTo: unassig...@gcc.gnu.org ReportedBy: vincenzo.innoce...@cern.ch we are used to mix in the same library code compiled with -O2 and -Os Lto seems to ignore the options used in the "compilation" steps It does honor "pragma GCC optimize" though example cat optopt.cc // #pragma GCC optimize ("0") void bar(int); inline void foo(int i, int j) { if (i>0) bar(i); if (j>0) bar(j); if (i>0) bar(j); if (j>0) bar(i); }; void foo1(int i, int j) { foo(i,j); } void foo2(int i, int j) { foo(i,j); } void foo3(int i, int j) { foo(i,j); } c++ -flto -fno-fat-lto-objects -Os -c optopt.cc -fPIC c++ -flto -O2 -shared optopt.o -fPIC -o optopt.so; nm -C optopt.so …. U bar(int) 00000000000007a0 T foo1(int, int) 0000000000000740 T foo2(int, int) 00000000000006e0 T foo3(int, int) …. c++ -flto -Os -shared optopt.o -fPIC -o optopt.so; nm -C optopt.so …. U bar(int) 00000000000006e0 t foo(int, int) [clone .local.0.2370] 000000000000071c T foo1(int, int) 000000000000071a T foo2(int, int) 0000000000000718 T foo3(int, int) … if I decomment the pragma I get what intended c++ -flto -fno-fat-lto-objects -O2 -c optopt.cc -fPIC c++ -flto -O2 -shared optopt.o -fPIC -o optopt.so; nm -C optopt.so U bar(int) 00000000000006e0 t foo(int, int) [clone .local.0.2370] 0000000000000760 T foo1(int, int) 0000000000000750 T foo2(int, int) 0000000000000740 T foo3(int, int) due to PR53776 I cannot specify Os using a pragma. so I am a bit stuck