I am trying to build my own lfs system for Raspberry PI 2.
As a part of it I am trying to compile gcc on Raspberry PI 2, with raspbian as a base operating system.
I could build the binutils using the instructions on lfs development version. But while compiling gcc I am getting below error
g++ -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -I. -I. -I../../gcc-5.2.0/gcc -I../../gcc-5.2.0/gcc/. -I../../gcc-5.2.0/gcc/../include -I../../gcc-5.2.0/gcc/../libcpp/include -I/mnt/lfs/sources/gcc-build/./gmp -I/mnt/lfs/sources/gcc-5.2.0/gmp -I/mnt/lfs/sources/gcc-build/./mpfr/src -I/mnt/lfs/sources/gcc-5.2.0/mpfr/src -I/mnt/lfs/sources/gcc-5.2.0/mpc/src -I../../gcc-5.2.0/gcc/../libdecnumber -I../../gcc-5.2.0/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc-5.2.0/gcc/../libbacktrace -o except.o -MT except.o -MMD -MP -MF ./.deps/except.TPo ../../gcc-5.2.0/gcc/except.c
g++ -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -I. -I. -I../../gcc-5.2.0/gcc -I../../gcc-5.2.0/gcc/. -I../../gcc-5.2.0/gcc/../include -I../../gcc-5.2.0/gcc/../libcpp/include -I/mnt/lfs/sources/gcc-build/./gmp -I/mnt/lfs/sources/gcc-5.2.0/gmp -I/mnt/lfs/sources/gcc-build/./mpfr/src -I/mnt/lfs/sources/gcc-5.2.0/mpfr/src -I/mnt/lfs/sources/gcc-5.2.0/mpc/src -I../../gcc-5.2.0/gcc/../libdecnumber -I../../gcc-5.2.0/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc-5.2.0/gcc/../libbacktrace -o explow.o -MT explow.o -MMD -MP -MF ./.deps/explow.TPo ../../gcc-5.2.0/gcc/explow.c
g++ -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -I. -I. -I../../gcc-5.2.0/gcc -I../../gcc-5.2.0/gcc/. -I../../gcc-5.2.0/gcc/../include -I../../gcc-5.2.0/gcc/../libcpp/include -I/mnt/lfs/sources/gcc-build/./gmp -I/mnt/lfs/sources/gcc-5.2.0/gmp -I/mnt/lfs/sources/gcc-build/./mpfr/src -I/mnt/lfs/sources/gcc-5.2.0/mpfr/src -I/mnt/lfs/sources/gcc-5.2.0/mpc/src -I../../gcc-5.2.0/gcc/../libdecnumber -I../../gcc-5.2.0/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc-5.2.0/gcc/../libbacktrace -o expmed.o -MT expmed.o -MMD -MP -MF ./.deps/expmed.TPo ../../gcc-5.2.0/gcc/expmed.c
../../gcc-5.2.0/gcc/wide-int.h: In function 'long long unsigned int choose_multiplier(long long unsigned int, int, int, long long unsigned int*, int*, int*)':
../../gcc-5.2.0/gcc/wide-int.h:798:57: warning: array subscript is below array bounds [-Warray-bounds]
../../gcc-5.2.0/gcc/wide-int.h:798:57: warning: array subscript is below array bounds [-Warray-bounds]
g++ -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -I. -I. -I../../gcc-5.2.0/gcc -I../../gcc-5.2.0/gcc/. -I../../gcc-5.2.0/gcc/../include -I../../gcc-5.2.0/gcc/../libcpp/include -I/mnt/lfs/sources/gcc-build/./gmp -I/mnt/lfs/sources/gcc-5.2.0/gmp -I/mnt/lfs/sources/gcc-build/./mpfr/src -I/mnt/lfs/sources/gcc-5.2.0/mpfr/src -I/mnt/lfs/sources/gcc-5.2.0/mpc/src -I../../gcc-5.2.0/gcc/../libdecnumber -I../../gcc-5.2.0/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc-5.2.0/gcc/../libbacktrace -o expr.o -MT expr.o -MMD -MP -MF ./.deps/expr.TPo ../../gcc-5.2.0/gcc/expr.c
../../gcc-5.2.0/gcc/expr.c: In function 'void store_constructor(tree, rtx, int, long long int)':
../../gcc-5.2.0/gcc/expr.c:6529:1: internal compiler error: output_operand: invalid shift operand
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
Preprocessed source stored into /tmp/ccAUc9Pu.out file, please attach this to your bugreport.
Makefile:1065: recipe for target 'expr.o' failed
make[2]: *** [expr.o] Error 1
make[2]: Leaving directory '/mnt/lfs/sources/gcc-build/gcc'
Makefile:4105: recipe for target 'all-gcc' failed
make[1]: *** [all-gcc] Error 2
make[1]: Leaving directory '/mnt/lfs/sources/gcc-build'
Makefile:858: recipe for target 'all' failed
make: *** [all] Error 2
I tried to trace the cause of error by looking at the expr.c file, but could not find issue. I have uploaded the "/tmp/ccAUc9Pu.out" to http://turl.ca/dcfansr
Can someone please help me how to debug the exact cause of issue
I had the same problem after checking all the system requirements were installed by running the version check at http://www.linuxfromscratch.org/lfs/view/stable-systemd/prologue/hostreqs.html and rebooting the system it worked afterwards.
Related
I'm working on some open source code; I have a configure.ac, in which I've added the following:
: ${FFT_MODE=1}
AC_ARG_VAR([FFT_MODE], [1 for fftw3, 2 for kiss_fft])
AC_DEFINE_UNQUOTED([FFTMODE], [$FFT_MODE],
[1 for fftw3, 2 for kiss_fft])
The idea is that (after calling autoconf --install), the user can run e.g. ./configure FFT_MODE=2 to switch modes. Now, I thought it was working - the status check at the end of the configuration file output the correct value, and an if/elif/endif in my code showed the correct block was executing. However - at some point I added an else, and discovered that both the if AND else blocks were running. First I thought my compiler was possessed, then I realized the file was getting loaded twice, and the second time, for some reason, FFTMODE is unset (or set to zero or something). I don't understand how, though. FTR, the check is in a file fsk.h, like so:
#warning before
#if(FFTMODE == 1)
#warning FFTMODE 1
#include <fftw3.h>
#elif(FFTMODE == 2)
#warning FFTMODE 2
#include <kiss_fftr.h>
#else
#warning FFTMODE ???
#error Unsupported FFTMODE
#endif
#warning after
The output of make is as follows:
make all-recursive
make[1]: Entering directory '/home/erhannis/mods/minimodem'
Making all in src
make[2]: Entering directory '/home/erhannis/mods/minimodem/src'
gcc -DHAVE_CONFIG_H -I. -I.. -D_REENTRANT -Wall -g -O2 -MT minimodem.o -MD -MP -MF .deps/minimodem.Tpo -c -o minimodem.o minimodem.c
In file included from minimodem.c:43:
fsk.h:20:2: warning: #warning before [-Wcpp]
20 | #warning before
| ^~~~~~~
fsk.h:22:2: warning: #warning FFTMODE 1 [-Wcpp]
22 | #warning FFTMODE 1
| ^~~~~~~
In file included from minimodem.c:43:
fsk.h:31:2: warning: #warning after [-Wcpp]
31 | #warning after
| ^~~~~~~
mv -f .deps/minimodem.Tpo .deps/minimodem.Po
gcc -DHAVE_CONFIG_H -I. -I.. -D_REENTRANT -Wall -g -O2 -MT databits_ascii.o -MD -MP -MF .deps/databits_ascii.Tpo -c -o databits_ascii.o databits_ascii.c
mv -f .deps/databits_ascii.Tpo .deps/databits_ascii.Po
gcc -DHAVE_CONFIG_H -I. -I.. -D_REENTRANT -Wall -g -O2 -MT databits_binary.o -MD -MP -MF .deps/databits_binary.Tpo -c -o databits_binary.o databits_binary.c
mv -f .deps/databits_binary.Tpo .deps/databits_binary.Po
gcc -DHAVE_CONFIG_H -I. -I.. -D_REENTRANT -Wall -g -O2 -MT databits_callerid.o -MD -MP -MF .deps/databits_callerid.Tpo -c -o databits_callerid.o databits_callerid.c
mv -f .deps/databits_callerid.Tpo .deps/databits_callerid.Po
gcc -DHAVE_CONFIG_H -I. -I.. -D_REENTRANT -Wall -g -O2 -MT databits_baudot.o -MD -MP -MF .deps/databits_baudot.Tpo -c -o databits_baudot.o databits_baudot.c
mv -f .deps/databits_baudot.Tpo .deps/databits_baudot.Po
gcc -DHAVE_CONFIG_H -I. -I.. -D_REENTRANT -Wall -g -O2 -MT baudot.o -MD -MP -MF .deps/baudot.Tpo -c -o baudot.o baudot.c
mv -f .deps/baudot.Tpo .deps/baudot.Po
gcc -DHAVE_CONFIG_H -I. -I.. -D_REENTRANT -Wall -g -O2 -MT databits_uic.o -MD -MP -MF .deps/databits_uic.Tpo -c -o databits_uic.o databits_uic.c
mv -f .deps/databits_uic.Tpo .deps/databits_uic.Po
gcc -DHAVE_CONFIG_H -I. -I.. -D_REENTRANT -Wall -g -O2 -MT uic_codes.o -MD -MP -MF .deps/uic_codes.Tpo -c -o uic_codes.o uic_codes.c
mv -f .deps/uic_codes.Tpo .deps/uic_codes.Po
gcc -DHAVE_CONFIG_H -I. -I.. -D_REENTRANT -Wall -g -O2 -MT fsk.o -MD -MP -MF .deps/fsk.Tpo -c -o fsk.o fsk.c
In file included from fsk.c:30:
fsk.h:20:2: warning: #warning before [-Wcpp]
20 | #warning before
| ^~~~~~~
fsk.h:28:2: warning: #warning FFTMODE ??? [-Wcpp]
28 | #warning FFTMODE ???
| ^~~~~~~
fsk.h:29:2: error: #error Unsupported FFTMODE
29 | #error Unsupported FFTMODE
| ^~~~~
fsk.h:31:2: warning: #warning after [-Wcpp]
31 | #warning after
| ^~~~~~~
fsk.c: In function ‘fsk_bit_analyze’:
fsk.c:200:10: error: ‘mag_mark’ undeclared (first use in this function)
200 | if ( mag_mark > mag_space ) {
| ^~~~~~~~
fsk.c:200:10: note: each undeclared identifier is reported only once for each function it appears in
fsk.c:200:21: error: ‘mag_space’ undeclared (first use in this function)
200 | if ( mag_mark > mag_space ) {
| ^~~~~~~~~
fsk.c:166:11: warning: unused variable ‘magscalar’ [-Wunused-variable]
166 | float magscalar = 2.0f / (float)bit_nsamples;
| ^~~~~~~~~
fsk.c: In function ‘fsk_detect_carrier’:
fsk.c:628:1: warning: control reaches end of non-void function [-Wreturn-type]
628 | }
| ^
make[2]: *** [Makefile:470: fsk.o] Error 1
make[2]: Leaving directory '/home/erhannis/mods/minimodem/src'
make[1]: *** [Makefile:361: all-recursive] Error 1
make[1]: Leaving directory '/home/erhannis/mods/minimodem'
make: *** [Makefile:302: all] Error 2
So, what's going on? There IS one instance of #undef FFTMODE in config.h.in - but while I can guess that file's for cleaning up after the build is done, the build isn't done yet, so why's it cleaning up the definitions I'm still using?
The source code is at https://github.com/erhannis/minimodem/tree/feature/alternate_fft; the relevant file is src/fsk.h.
I think you're confusing yourself with this idea that the file is getting loaded twice. That doesn't seem to be the case, from the output you show.
Instead, the file is getting loaded one time each, in two different compile commands. Once when compiling minimodem.c and once when compiling fsk.c. Those are totally different compile operations.
In minimodem.c, the value of FFTMODE is 1. In fsk.c, FFTMODE is unset.
This is easily explained: in minimodem.c you #include "config.h" before you #include "fsk.h", and so when fsk.h is parsed you have a value for FFTMODE. In fsk.c you don't #include "config.h", so there is no value for FFTMODE.
If your fsk.h file needs values from config.h, then it may be best to #include "config.h" in fsk.h. If you don't want to do that you need to make sure it's included by all the .c files, before fsk.h.
I'm on a MacOS and when I try to make the file it throws an out of bounds possibility error is there a way to fix this error? I need it to build an os from the MIT OS class.
Source: https://pdos.csail.mit.edu/6.828/2009/tools.html
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I. -I./../include -DHAVE_bfd_elf32_i386_vec -DHAVE_i386coff_vec -DHAVE_bfd_elf32_little_generic_vec -DHAVE_bfd_elf32_big_generic_vec -DBINDIR='"/usr/local/bin"' -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -O2 -MT elf32-i386.lo -MD -MP -MF .deps/elf32-i386.Tpo -c -o elf32-i386.lo elf32-i386.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I. -I./../include -DHAVE_bfd_elf32_i386_vec -DHAVE_i386coff_vec -DHAVE_bfd_elf32_little_generic_vec -DHAVE_bfd_elf32_big_generic_vec -DBINDIR=\"/usr/local/bin\" -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -O2 -MT elf32-i386.lo -MD -MP -MF .deps/elf32-i386.Tpo -c elf32-i386.c -o elf32-i386.o
elf32-i386.c:326:15: error: array index 42 is past the end of the array (which contains 34 elements) [-Werror,-Warray-bounds]
return &elf_howto_table[R_386_IRELATIVE];
^ ~~~~~~~~~~~~~~~
elf32-i386.c:37:1: note: array 'elf_howto_table' declared here
static reloc_howto_type elf_howto_table[]=
^
1 error generated.
I'm building a package (vice 3.4) that uses GNU autoconf. Running ./configure fails with the following message:
checking size of time_t... 0
configure: error: can not figure type of time_t
error: Bad exit status from /var/tmp/rpm-tmp.wIgnPw (%build)
Examining config.log, this appears to be failing due to the following error:
/usr/bin/ld: /tmp/ccMTSdtB.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
I tried resolving this by adding -fPIC to the CFLAGS environment variable:
CFLAGS=-fPIC ./configure
But while this is clearly being used during other stages of ./configure...
configure:3657: checking whether the C compiler works
configure:3679: gcc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE=1 -fPIC -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld conftest.c >&5
It doesn't seem to be used in the feature tests related to time_t:
configure:9684: checking for time_t in time.h
configure:9700: gcc -c -g -O3 -Wall -Wformat -Wformat-signedness -Wshadow -Wpointer-arith -Wstrict-prototypes -Wuninitialized -Wunreachable-code -Wno-unused-parameter -Werror=implicit-function-declaration -Wfatal-errors conftest.c >&5
[...]
configure:9753: checking size of time_t
configure:9758: gcc -o conftest -g -O3 -Wall -Wformat -Wformat-signedness -Wshadow -Wpointer-arith -Wstrict-prototypes -Wuninitialized -Wunreachable-code -Wno-unused-parameter -Werror=implicit-function-declaration -Wfatal-errors -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld conftest.c >&5
Looking at configure.ac, the above code is generated from:
if test $bu_cv_decl_time_t_time_h = yes; then
AC_CHECK_SIZEOF([time_t],[],[#include <time.h>])
else
AC_CHECK_SIZEOF([time_t],[],[#include <sys/types.h>])
fi
I've been able to work around the problem by redefining CC instead:
CC="gcc -fPIC" ./configure
This works, but it's ugly (what if something wants to call gcc without -fPIC?). Is there a reason that AC_CHECK_SIZEOF is ignoring CFLAGS?
It looks like the suspicion I expressed in comments is confirmed. The VICE configure program intentionally substitutes its own choice of CFLAGS for the user's specified ones when it performs some of its checks, including the ones related to time_t. Thus, this is not a question of Autoconf ignoring your flags, but rather of VICE doing so.
I reiterate that I think it's a more significant issue that configuration doesn't work out of the box for you in the first place. I suggest raising that as an issue against the project. Although I don't like that VICE is so cavalier about ignoring the user's CFLAGS, that's a separate matter, and one that I suspect wouldn't get much traction with the devs.
John correctly identified the issue, and based on that information I did a little digging and I've figure out what's going on.
I'm building this under the control of rpm, which calls configure like this:
%configure --enable-native-gtk3ui $COMMON_FLAGS
That %configure expands into a chunk of shell code that looks like this:
CFLAGS="${CFLAGS:--O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection}" ; export CFLAGS ;
CXXFLAGS="${CXXFLAGS:--O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection}" ; export CXXFLAGS ;
FFLAGS="${FFLAGS:--O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I/usr/lib64/gfortran/modules}" ; export FFLAGS ;
FCFLAGS="${FCFLAGS:--O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I/usr/lib64/gfortran/modules}" ; export FCFLAGS ;
LDFLAGS="${LDFLAGS:--Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld}" ; export LDFLAGS;
[ "1" = 1 ] && for i in $(find $(dirname ./configure) -name config.guess -o -name config.sub) ; do
[ -f /usr/lib/rpm/redhat/$(basename $i) ] && /usr/bin/rm -f $i && /usr/bin/cp -fv /usr/lib/rpm/redhat/$(basename $i) $i ;
done ;
[ "1" = 1 ] && [ x != "x-Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld" ] &&
for i in $(find . -name ltmain.sh) ; do
/usr/bin/sed -i.backup -e 's~compiler_flags=$~compiler_flags="-Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld"~' $i
done ;
./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu \
--program-prefix= \
--disable-dependency-tracking \
\
--prefix=/usr \
--exec-prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--sysconfdir=/etc \
--datadir=/usr/share \
--includedir=/usr/include \
--libdir=/usr/lib64 \
--libexecdir=/usr/libexec \
--localstatedir=/var \
--sharedstatedir=/var/lib \
--mandir=/usr/share/man \
--infodir=/usr/share/info
Of particular interest is the fact that this is setting LDFLAGS. The failing config test is:
gcc -o conftest -g -O3 -Wall -Wformat -Wformat-signedness -Wshadow \
-Wpointer-arith -Wstrict-prototypes -Wuninitialized -Wunreachable-code \
-Wno-unused-parameter -Werror=implicit-function-declaration \
-Wfatal-errors -Wl,-z,relro -Wl,--as-needed -Wl,-z,now \
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld conftest.c
That -specs line points to a gcc spec file that looks like this:
*self_spec:
+ %{!static:%{!shared:%{!r:-pie}}}
That effectively adds the -pie option to the command line. We can reproduce the failure with a simple hello.c program:
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv) {
printf("hello world\n");
return(0);
}
Like this:
$ gcc -o hello -pie hello.c
/usr/bin/ld: /tmp/ccXRAu6r.o: relocation R_X86_64_32 against `.rodata' 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
But here's the thing:
A successful gcc invocation looks like this:
gcc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 \
-Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong \
-grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 \
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic \
-fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection \
-D_GNU_SOURCE=1 -fPIC -Wl,-z,relro -Wl,--as-needed -Wl,-z,now \
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld conftest.c
Note that there is a second -specs option there, that points to /usr/lib/rpm/redhat/redhat-hardened-cc1, which looks like:
*cc1_options:
+ %{!r:%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}}
This takes care of adding -fPIE to the command line, which results in a successful compile:
$ gcc -o hello -pie -fPIE hello.c
$
We're hitting this failure because the configure script is replacing CFLAGS during the tests, but preserving LDFLAGS. This results in a faulty command line.
For my own purposes, I'm just patching the configure script to not replace CFLAGS during the time_t related tests. This seems both expedient (it's a one-character diff if I just comment out the appropriate line) and effective (it results in a successful build).
I will probably report this upstream as a bug.
I am using NDK standalone toolchain to build a dynamic library(.so) on Mac OS.
I just migrate the C language compiler from GCC to clang.When using GCC the processes are all OK and so file is generated successfully. But when using clang,some errors happen when issue ./configure.The errors are as follows.
The picture error logs:
The text error logs,it is the same with the above picture error logs:
check_as
BEGIN /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
1 .altmacro
END /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
arm-linux-androideabi-clang -D_ISOC99_SOURCE -Dstrtod=avpriv_strtod -I$(SRC_PATH)/compat/float -DPIC -O3 -Wall -pipe -std=c99 -ffast-math -fstrict-aliasing -Werror=strict-aliasing -Wno-psabi -Wa,--noexecstack -DANDROID -DNDEBUG -I/Users/zexu/github/ijkplayer/android/contrib/build/openssl-armv7a/output/include -march=armv7-a -mcpu=cortex-a8 -mfpu=vfpv3-d16 -mfloat-abi=softfp -mthumb -mcpu=cortex-a8 -fPIC -c -o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.DIksqWpw.o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
warning: unknown warning option '-Wno-psabi' [-Wunknown-warning-option]
1 warning generated.
/var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S:1:1: error: unknown directive
.altmacro
^
check_gas using 'arm-linux-androideabi-clang' as AS
check_as
BEGIN /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
1 .macro m n, y:vararg=0
2 \n: .int \y
3 .endm
4 m x
END /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
arm-linux-androideabi-clang -D_ISOC99_SOURCE -Dstrtod=avpriv_strtod -I$(SRC_PATH)/compat/float -DPIC -O3 -Wall -pipe -std=c99 -ffast-math -fstrict-aliasing -Werror=strict-aliasing -Wno-psabi -Wa,--noexecstack -DANDROID -DNDEBUG -I/Users/zexu/github/ijkplayer/android/contrib/build/openssl-armv7a/output/include -march=armv7-a -mcpu=cortex-a8 -mfpu=vfpv3-d16 -mfloat-abi=softfp -mthumb -mcpu=cortex-a8 -fPIC -c -o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.DIksqWpw.o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
warning: unknown warning option '-Wno-psabi' [-Wunknown-warning-option]
1 warning generated.
check_as
BEGIN /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
1 .altmacro
END /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
arm-linux-androideabi-clang -D_ISOC99_SOURCE -Dstrtod=avpriv_strtod -I$(SRC_PATH)/compat/float -DPIC -O3 -Wall -pipe -std=c99 -ffast-math -fstrict-aliasing -Werror=strict-aliasing -Wno-psabi -Wa,--noexecstack -DANDROID -DNDEBUG -I/Users/zexu/github/ijkplayer/android/contrib/build/openssl-armv7a/output/include -march=armv7-a -mcpu=cortex-a8 -mfpu=vfpv3-d16 -mfloat-abi=softfp -mthumb -mcpu=cortex-a8 -fPIC -c -o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.DIksqWpw.o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
warning: unknown warning option '-Wno-psabi' [-Wunknown-warning-option]
1 warning generated.
/var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S:1:1: error: unknown directive
.altmacro
^
GNU assembler not found, install/update gas-preprocessor
The toolchain configurations in the configure file:
# toolchain
ar_default="ar"
cc_default="clang"
cxx_default="clang++"
host_cc_default="clang"
cp_f="cp -f"
doxygen_default="doxygen"
install="install"
ln_s_default="ln -s -f"
nm_default="nm -g"
objformat="elf"
pkg_config_default=pkg-config
ranlib_default="ranlib"
strip_default="strip"
version_script='--version-script'
yasmexe_default="yasm"
windres_default="windres"
The NDK version is r14b,and the clang version:
Android clang version 3.8.275480 (based on LLVM 3.8.275480)
Target: x86_64-apple-darwin17.2.0
Thread model: posix
I know that the error is not caused by the "gas-preprocessor",because GCC compiler also has this problem.The GCC logs with no errors:
check_cc
BEGIN /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.51pLIKDT.c
1 unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
END /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.51pLIKDT.c
arm-linux-androideabi-gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -O3 -Wall -pipe -std=c99 -ffast-math -fstrict-aliasing -Werror=strict-aliasing -Wno-psabi -Wa,--noexecstack -DANDROID -DNDEBUG -I/Users/zexu/github/ijkplayer/android/contrib/build/openssl-armv7a/output/include -march=armv7-a -mcpu=cortex-a8 -mfpu=vfpv3-d16 -mfloat-abi=softfp -mthumb -mcpu=cortex-a8 -std=c11 -fomit-frame-pointer -fPIC -c -o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.bcyz1Buv.o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.51pLIKDT.c
gas-preprocessor.pl -arch arm -as-type gas -- arm-linux-androideabi-gcc -v
./configure: line 883: gas-preprocessor.pl: command not found
check_gas using 'arm-linux-androideabi-gcc' as AS
check_as
BEGIN /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.QeTKRayl.S
1 .macro m n, y:vararg=0
2 \n: .int \y
3 .endm
4 m x
END /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.QeTKRayl.S
arm-linux-androideabi-gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -O3 -Wall -pipe -std=c99 -ffast-math -fstrict-aliasing -Werror=strict-aliasing -Wno-psabi -Wa,--noexecstack -DANDROID -DNDEBUG -I/Users/zexu/github/ijkplayer/android/contrib/build/openssl-armv7a/output/include -march=armv7-a -mcpu=cortex-a8 -mfpu=vfpv3-d16 -mfloat-abi=softfp -mthumb -mcpu=cortex-a8 -fPIC -c -o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.bcyz1Buv.o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.QeTKRayl.S
check_as
BEGIN /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.QeTKRayl.S
1 .altmacro
END /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.QeTKRayl.S
arm-linux-androideabi-gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -O3 -Wall -pipe -std=c99 -ffast-math -fstrict-aliasing -Werror=strict-aliasing -Wno-psabi -Wa,--noexecstack -DANDROID -DNDEBUG -I/Users/zexu/github/ijkplayer/android/contrib/build/openssl-armv7a/output/include -march=armv7-a -mcpu=cortex-a8 -mfpu=vfpv3-d16 -mfloat-abi=softfp -mthumb -mcpu=cortex-a8 -fPIC -c -o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.bcyz1Buv.o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.QeTKRayl.S
Anyone can give me some tips?
Issues with assembler when switching from GCC to Clang are usually fixed with -fno-integrated-as. Clang has a built in assembler that it uses for assembling generating code that is not 100% compatible with GNU's assembler. If you have any inline assembly, you will either need to update that assembly to be compatible with LLVM's assembler or pass -fno-integrated-as to instruct Clang to use GNU as instead.
I am trying to compile SVGA source to build for shared-library object.
while compiling i am getting this error
make[1]: Entering directory `/home/manmatha/Downloads/svgalib-1.9.25/utils'
gcc -I../include -I. -MM ../utils/restorefont.c ../utils/convfont.c ../utils/restoretextmode.c ../utils/restorepalette.c ../utils/dumpreg.c >.depend
cc -Wall -Wstrict-prototypes -fomit-frame-pointer -O2 -fno-strength-reduce -pipe -I../include -L../sharedlib -c -o restorefont.o restorefont.c
cc -Wall -Wstrict-prototypes -fomit-frame-pointer -O2 -fno-strength-reduce -pipe -I../include -L../sharedlib -s -o restorefont restorefont.o -lvga -lm
chmod 4755 restorefont
cc -Wall -Wstrict-prototypes -fomit-frame-pointer -O2 -fno-strength-reduce -pipe -I../include -L../sharedlib -c -o convfont.o convfont.c
cc -Wall -Wstrict-prototypes -fomit-frame-pointer -O2 -fno-strength-reduce -pipe -I../include -L../sharedlib -s -o convfont convfont.o -lvga -lm
cc -Wall -Wstrict-prototypes -fomit-frame-pointer -O2 -fno-strength-reduce -pipe -I../include -L../sharedlib -c -o restoretextmode.o restoretextmode.c
cc -Wall -Wstrict-prototypes -fomit-frame-pointer -O2 -fno-strength-reduce -pipe -I../include -L../sharedlib -s -o restoretextmode restoretextmode.o -lvga -lm
chmod 4755 restoretextmode
cc -Wall -Wstrict-prototypes -fomit-frame-pointer -O2 -fno-strength-reduce -pipe -I../include -L../sharedlib -c -o restorepalette.o restorepalette.c
cc -Wall -Wstrict-prototypes -fomit-frame-pointer -O2 -fno-strength-reduce -pipe -I../include -L../sharedlib -s -o restorepalette restorepalette.o -lvga -lm
chmod 4755 restorepalette
cc -Wall -Wstrict-prototypes -fomit-frame-pointer -O2 -fno-strength-reduce -pipe -I../include -L../sharedlib -c -o dumpreg.o dumpreg.c
cc -Wall -Wstrict-prototypes -fomit-frame-pointer -O2 -fno-strength-reduce -pipe -I../include -L../sharedlib -s -o dumpreg dumpreg.o -lvga -lm
chmod 4755 dumpreg
cc -Wall -Wstrict-prototypes -fomit-frame-pointer -O2 -fno-strength-reduce -pipe -I../include -L../sharedlib -s -o gtfcalc -DTESTING_GTF gtf/gtfcalc.c -lvga -lm
gtf/gtfcalc.c:67: error: static declaration of ‘round’ follows non-static declaration
make[1]: *** [gtfcalc] Error 1
make[1]: Leaving directory `/home/manmatha/Downloads/svgalib-1.9.25/utils'
make: *** [textutils] Error 2
Edit::Yes the patch works..But the compilation encounters the next error while compiling the svga_helper.ko module
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c:1:26: error: linux/config.h: No such file or directory
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c:20:35: error: linux/devfs_fs_kernel.h: No such file or directory
In file included from /home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c:42:
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/kernel26compat.h: In function ‘devfs_unregister_chrdev’:
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/kernel26compat.h:80: error: void value not ignored as it ought to be
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c: In function ‘svgalib_helper_ioctl’:
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c:237: warning: cast to pointer from integer of different size
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c:242: warning: cast to pointer from integer of different size
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c:247: warning: cast to pointer from integer of different size
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c:252: warning: cast to pointer from integer of different size
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c:258: warning: cast to pointer from integer of different size
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c:264: warning: cast to pointer from integer of different size
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c:358: error: ‘SA_SHIRQ’ undeclared (first use in this function)
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c:358: error: (Each undeclared identifier is reported only once
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c:358: error: for each function it appears in.)
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c:358: warning: passing argument 2 of ‘request_irq’ from incompatible pointer type
include/linux/interrupt.h:123: note: expected ‘irq_handler_t’ but argument is of type ‘enum irqreturn_t (*)(int, void *, struct pt_regs *)’
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c: In function ‘svgalib_helper_open’:
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c:446: error: ‘SA_SHIRQ’ undeclared (first use in this function)
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c:446: warning: passing argument 2 of ‘request_irq’ from incompatible pointer type
include/linux/interrupt.h:123: note: expected ‘irq_handler_t’ but argument is of type ‘enum irqreturn_t (*)(int, void *, struct pt_regs *)’
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c: In function ‘init_module’:
/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.c:651: error: implicit declaration of function ‘class_device_create’
make[3]: *** [/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper/main.o] Error 1
make[2]: *** [_module_/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper] Error 2
make[2]: Leaving directory `/usr/src/kernels/2.6.32-358.0.1.el6.x86_64'
make[1]: *** [default] Error 2
make[1]: Leaving directory `/home/manmatha/Downloads/svgalib-1.9.25/kernel/svgalib_helper'
make: *** [installmodule] Error 2
I think you want to go for a newer version of svgalib. 1.4.3 is pretty old and no longer maintained. If I remember correctly it needed to be patched to work with newer compilers as well.
Try one of the 1.9.x versions from http://svgalib.org/
For later versions, if you get the error:
error: static declaration of 'round' follows non-static declaration
Apply the following patch:
--- svgalib-1.9.25/utils/gtf/gtfcalc.c
+++ svgalib-1.9.25/utils/gtf/gtfcalc.c
## -68,5 +68,5 ##
-static double round(double v)
+double round(double v)
{
return floor(v + 0.5);
}
EDIT:
With your latest compile issue in the svga_helper.ko module, set the NO_HELPER variable to disable building svga_helper.ko. config.h etc. were removed form more recent kernels. From the Readme:
There is a compile time option to return to old behaviour, of using
root privileges to access /dev/mem, instead of svgalib helper. To
compile for this select the NO_HELPER option in Makefile.cfg.