volatile: i tried already with clang/llvm it worked.
i'm using gentoo linux, trying to emerge everything with -flto. i'm not sure if i understand linker/compiler bug or not a bug, i wonder how many script is affected by this issue.
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.
how could -lfto be not used with configure yet with make? pass another CFLAGS to make as argument?
IIRC, we tends to assume configure use same CFLAGS as Makefile (which generated by configure anyway)
> 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