%% Bruno Haible <[EMAIL PROTECTED]> writes:

  bh> Paul D. Smith writes:

  >> Seems like any decent compiler would omit this code!  Since Linux is
  >> using GCC, I would double-expect that.  Maybe it only happens when you
  >> build with optimization on?

  bh> No compiler is required to omit "if (0)" code, and gcc indeed
  bh> doesn't omit it if -O is not given.

Certainly compilers aren't required to do so.

  bh> Therefore compiling the make-3.79.1 code without optimization but
  bh> without -lutil will result in a link error.  Since looking into
  bh> the optimization flags in order to know whether to link in
  bh> libutil.so is too tricky, it is preferrable to determine a priori
  bh> whether libutil.so will be needed.

I wasn't suggesting that -lutil be removed from the link line; I guess I
was assuming that the linker would be intelligent enough to not bother
with libraries where no reference exists in the code.

That is, if the compiler omitted the invocation of clock_gettime (as
most every compiler will do with -O at least--that's a _very_ simple
optimization), then the linker wouldn't add a reference to the library
even though it appeared on the link line since no symbol in that library
was used by the program.

I agree this is a good bit of assuming; nevertheless it would be
interesting to see if make included a reference to libutil.so if
compiled with -O.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[EMAIL PROTECTED]>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

Reply via email to