bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "-flto -O2" shouln't opt out "undefined reference" error


From: Jim Wilson
Subject: Re: "-flto -O2" shouln't opt out "undefined reference" error
Date: Tue, 17 Jan 2017 15:53:11 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]