configure replaces CFLAGS but honors LDFLAGS, leading to incompatible command lines
Versatile Commodore Emulator
Brought to you by:
blackystardust,
gpz
When running ./configure
, vice sometimes replaces CFLAGS
from the environment with it's own CFLAGS
. For example, in configure.ac
:
old_CFLAGS="$CFLAGS" CFLAGS="$VICE_CFLAGS" dnl Do these checks before any Gtk3 flags are added AC_MSG_CHECKING(for time_t in time.h) AC_CACHE_VAL(bu_cv_decl_time_t_time_h, [AC_TRY_COMPILE([#include <time.h>], [time_t i;], bu_cv_decl_time_t_time_h=yes, bu_cv_decl_time_t_time_h=no)]) AC_MSG_RESULT($bu_cv_decl_time_t_time_h) if test $bu_cv_decl_time_t_time_h = yes; then AC_DEFINE([HAVE_TIME_T_IN_TIME_H],, ¦ [Is the type time_t defined in <time.h>?]) fi
This can lead to a problem if there are flags in CFLAGS
and LDFLAGS
that interact. For example, if we run the following:
CFLAGS='-fPIE' LDFLAGS='-pie' ./configure
The configure will fail:
checking size of time_t... 0 configure: error: can not figure type of time_t
The actual failure from config.log
is:
/usr/bin/ld: /tmp/ccHO6lM5.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: final link failed: nonrepresentable section on output collect2: error: ld returned 1 exit status
We run into exactly this situation when trying to build Vice packages for Fedora, because CFLAGS includes...
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1
...which sets -fPIE
, and LDFLAGS
includes...
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld
...which sets -pie
.
I've fixed this in my local package builds by simply comments out the line in configure
that replaces CFLAGS
. So I have:
old_CFLAGS="$CFLAGS" #CFLAGS="$VICE_CFLAGS"
I've updated the buildsystem to also use VICE_LDFLAGS in the way VICE_CFLAGS is currently used. Would surrounding configure tests with:
work? (in addition to the CFLAGS replacements)
Or do we require a different approach?
No response for a long time, but I've checked current trunk with
CFLAGS='-fPIE' LDFLAGS='-pie' ./configure
and that runs configure fine, build fine and runs fine.So, I'm closing this as fixed. Please let me know if there are still issues.