[OpenWrt-Devel] Build issue using ccache due to GCC patch / R_MIPS_26
Karl Vogel
karl.vogel at gmail.com
Tue Jul 14 04:10:47 EDT 2015
There seems to be an issue using ccache in combination with the openwrt
patched gcc.
Found the issue while investigating the following compilation issue:
---
openwrt/staging_dir/toolchain-mips_gcc-4.6-linaro_uClibc-0.9.33.2/lib/gcc/mips-openwrt-linux-uclibc/4.6.3/../../../../mips-openwrt-linux-uclibc/bin/ld:
.libs/libxt_ACCOUNT_cl.o: relocation R_MIPS_26 against `memset' can not
be used when making a shared object; recompile with -fPIC
libs/libxt_ACCOUNT_cl.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[8]: *** [libxt_ACCOUNT_cl.la] Error 1
---
This only happened sometimes and only on certain machines. Closer look
showed that libtool wasn't actually adding -fPIC. This was caused by
the autoconf check for the PIC flag sometimes failing on my machine:
checking for ccache_cc option to produce PIC... -fPIC -DPIC
checking if ccache_cc PIC flag -fPIC -DPIC works... no
Doing a 'clean prepare compile' of the package sometimes fixed it.
The problem is that the autoconf test is doing a compilation with -fPIC
then compares the stdout of the compiler to a 'normal' compilation. The
results have to be equal to pass the test, in my setup, this wasn't
always the case.
The reason was that the compilation output for that step sometimes gave
a warning:
warning: someone does not honour COPTS correctly, passed 2 times
This warning comes from the 910-mbsd_multi.patch patch to gcc, which
verifies that -fhonour-copts is on the compilation line and that it is
only present once. The patch also uses an environment variable called
GCC_HONOUR_COPTS which indicates what has to happen if the option isn't
present or is specified more than once. (possible values 0, 1, 2 and
's' for silent)
The problem that was occuring on my setup was that -fhonour-copts had
been specified more than once for an autoconf check and that this
result was cached by ccache.
All subsequent compilations for the same autoconf conftest.c file,
returned the result from the compiler cache as for ccache the same
inputs where used for the compilation. The problem here is that ccache
has no knowledge that the environment variable GCC_HONOUR_COPTS
influences the stdout from gcc and since the stdout is of importance to
autoconf, it was causing the PIC config test to fail due to a prior
cached compilation result.
To verify my finding, I tried compilation without ccache, which worked
and then tried patching ccache to also track GCC_HONOUR_COPTS, which
also produced the correct result:
--- ccache-3.1.7/ccache.c 2012-01-08 15:40:55.000000000 +0100
+++ ccache-3.1.7-patched/ccache.c 2015-07-14 09:56:02.037675777
+0200
@@ -965,6 +965,7 @@ calculate_object_hash(struct args *args,
"CPLUS_INCLUDE_PATH",
"OBJC_INCLUDE_PATH",
"OBJCPLUS_INCLUDE_PATH", /* clang */
+ "GCC_HONOUR_COPTS",
NULL
};
for (p = envvars; *p != NULL ; ++p) {
With this patch, ccache will also add the GCC_HONOUR_COPTS setting to
the hash of the compilation command and will consider 2 compilations
with a different GCC_HONOUR_COPTS to actually be 2 different
compilations.
However, this doesn't completely fix the problem as it appears that the
tools/ccache/Makefile will only be compiled if ccache isn't already
present on the host system, so probably the proper way to fix this is
to just unconditionally compile ccache too if it is selected by the
build system and then add the above ccache patch to the package.
Regards,
Karl
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list