libtool
[Top][All Lists]
Advanced

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

Using the same options for compilation and linking


From: Pau Koning
Subject: Using the same options for compilation and linking
Date: Sun, 5 May 2013 19:03:11 +0200

Hi,

there are currently some things going on regarding the analysis of the build logs using blhc. This is extreme nice and made me think about a sentence most people missed in the GCC documentation (it is repeated often):

"For predictable results, you must also specify the same set of options used for compilation (-fpic, -fPIC, or model suboptions) when you specify this linker option."

Most of the time it works quite well, but what happens when somebody wants to enable -flto (just using the environment CFLAGS variable)? For example libtool will then stop to generate debug info because it drops the -g from Debians CFLAGS in the linking stage.

Or as another example take the builtin rules from GNU make:

LINK.o = $(CC) $(LDFLAGS) $(TARGET_ARCH)

%: %.o
#  commands to execute (built-in):
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@

It is missing the CFLAGS completely. So, the requested optimizations (either added by the Makefile to CFLAGS or by the user environment) is now completely dropped and only linker flags are used during the -flto compile step during the linking (when CFLAGS and LDFLAGS have -flto). Or the link-time optimization is not done as expected (-flto only specified in CFLAGS)

This is rather problematic for my example but also subtle defects can happen.

Any thoughts on making this a long term QA goal? Or are there other ideas about this problem? I've Cc'ed the mentioned projects to allow them to make statements about their position.

reply via email to

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