On 01/16/2017 10:32 AM, Xuefer wrote:
without -flto or without -O2 produce good (expected) result:
================================
configure:5332: checking for dlsym
...

It isn't the linker that is the problem here. It is the compiler. But it isn't a compiler bug. An optimizing compiler is supposed to optimize code like this.

I'd say the main problem is trying to use -flto at configure time. This is likely to break lots of configure scripts.

char (*f) ();

However, this particular problem I can fix with gcc by changing this line to

char (* volatile f) ();

and now gcc won't optimize away the store, even with -flto. Unfortunately, I can't check LLVM at the moment, as I don't have LLVM -flto support set up on any of my machines at the moment.

So this can be fixed by not using -flto at configure time, or by modifying configure scripts to use volatile. There is no linker or compiler fix to make here.

Jim


_______________________________________________
bug-binutils mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to