This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
GCC creates code having the wrong instruction set
- From: "onkel dot jack at t-online dot de" <onkel dot jack at t-online dot de>
- To: gcc-help mailing list <gcc-help at gcc dot gnu dot org>
- Date: Tue, 7 Mar 2017 20:28:00 +0100 (MET)
- Subject: GCC creates code having the wrong instruction set
- Authentication-results: sourceware.org; auth=none
- Reply-to: "onkel dot jack at t-online dot de" <onkel dot jack at t-online dot de>
I try to build an arm tool chain based on GCC 6.3.0 with newlib 2.5.0.
Almost everything went fine, except for thumb mode some code in thumb/libgcc.a is generated with the wrong instruction set.
Affected are i.e.
__aeabi_uidiv
__aeabi_uidivmod
__aeabi_idiv
__aeabi_idivmod
and some more, while most of the symbols has correct thumb instructions.
code which has ARM instructions instead of thumb.
I use the default multilib config, but tried aprofile too, with same result.
Here is the Makefile containing all config options I use:
BINUTILS_VERSION = 2.27
GCC_VERSION = 6.3.0
NEWLIB_VERSION = 2.5.0
GDB_VERSION = 7.12.1
BINUTILS = binutils-$(BINUTILS_VERSION)
GCC = gcc-$(GCC_VERSION)
NEWLIB = newlib-$(NEWLIB_VERSION)
GDB = gdb-$(GDB_VERSION)
TARGET=arm-nanix-eabi
PREFIX=$(PWD)/$(TARGET)-$(GCC_VERSION)
PATH:=$(PREFIX)/bin:$(PATH)
PLATFORM=$(shell uname -s)
#ifeq ($(PLATFORM), MINGW64_NT-6.1)
# BUILD=--build=x86_64-w64-mingw32
#endif
default : all
clean:
rm -rf *-build
rm -rf $(PREFIX)
binutils: binutils-build/build-done
gcc-boot: gcc-build/build-boot-done
newlib: newlib-build/build-done
gcc: gcc-build/build-done
gdb: gdb-build/build-done
#all: binutils gcc-boot newlib gcc gdb
all: gcc-boot newlib gcc gdb
$(BINUTILS).tar.bz2:
echo "Grabbing $@"
curl ftp://ftp.gnu.org/gnu/binutils/$@ -o $@
$(GCC).tar.bz2:
echo "Grabbing $@"
curl ftp://ftp.gnu.org/gnu/gcc/$(GCC)/$@ -o $@
$(NEWLIB).tar.gz:
echo "Grabbing $@"
curl ftp://sources.redhat.com/pub/newlib/$@ -o $@
$(GDB).tar.gz:
echo "Grabbing $@"
curl ftp://ftp.gnu.org/gnu/gdb/$@ -o $@
$(BINUTILS) : $(BINUTILS).tar.bz2
echo -n "extracting $< : "
tar -jxf $<
touch $@
$(GCC) : $(GCC).tar.bz2
echo -n "extracting $< : "
tar -jxf $<
touch $@
$(NEWLIB) : $(NEWLIB).tar.gz
echo -n "extracting $< : "
tar -zxf $<
patch -p 1 -d $(NEWLIB) < $(NEWLIB)-nanix.patch
touch $@
$(GDB) : $(GDB).tar.gz
echo -n "extracting $< : "
tar -zxf $<
touch $@
%-build:
mkdir -p $@
$(GCC)/gmp: | $(GCC)
cd $(GCC); ./contrib/download_prerequisites
touch $@
$(GCC)/mpfr:| $(GCC)
cd $(GCC); ./contrib/download_prerequisites
touch $@
$(GCC)/mpc: | $(GCC)
cd $(GCC); ./contrib/download_prerequisites
touch $@
# Build a set of compatible Binutils for this architecture. Need this before
# we can build GCC.
binutils-build/config-done: $(BINUTILS)
rm -f $@
mkdir -p binutils-build
cd binutils-build ;\
../$(BINUTILS)/configure $(BUILD) LDFLAGS="-static" --target=$(TARGET) --prefix=$(PREFIX) --disable-nls\
&& touch config-done
binutils-build/build-done: binutils-build/config-done
rm -f $@
make -C binutils-build all install 2>&1 | tee binutils-build/make.log; test $${PIPESTATUS[0]} = 0 && touch $@
# Build and configure GCC with the Newlib C runtime.
gcc-build/config-boot-done: binutils-build/build-done $(GCC) $(GCC)/gmp $(GCC)/mpfr $(GCC)/mpc
rm -f $@
mkdir -p gcc-build
cd gcc-build ; ../$(GCC)/configure $(BUILD) LDFLAGS="-static" --target=$(TARGET) --prefix=$(PREFIX) \
--with-newlib \
--disable-nls \
--disable-libssp \
--disable-gomp \
--disable-libstcxx-pch \
--enable-threads \
--disable-shared \
--enable-static \
--disable-libmudflap
--enable-languages=c,c++\
--without-libiconv-prefix\
&& touch config-boot-done
gcc-build/build-boot-done: gcc-build/config-boot-done
rm -f $@
make -C gcc-build all-gcc install-gcc 2>&1 | tee -a gcc-build/boot-make.log; test $${PIPESTATUS[0]} = 0 && touch $@
newlib-build/config-done: gcc-build/build-boot-done $(NEWLIB)
rm -f $@
mkdir -p newlib-build
cd newlib-build ; ../$(NEWLIB)/configure CFLAGS_FOR_TARGET=-fstack-usage LDFLAGS="-static" $(BUILD) --target=$(TARGET) --prefix=$(PREFIX) \
--enable-multilib \
--enable-shared=no --enable-static=yes \
--enable-newlib-nano-malloc \
--enable-target-optspace\
--enable-lite-exit \
--enable-newlib-global-atexit \
--enable-newlib-reent-small \
--enable-newlib-multithread\
--enable-newlib-nano-formatted-io
--disable-newlib-unbuf-stream-opt\
--disable-newlib-fvwrite-in-streamio \
--disable-newlib-wide-orient \
&& touch config-done
newlib-build/build-done: newlib-build/config-done
rm -f $@
make -C newlib-build all install INCLUDE=$(pwd)/$(NEWLIB)/include 2>&1 | tee -a newlib-build/make.log; test $${PIPESTATUS[0]} = 0 && touch $@
gcc-build/build-done: newlib-build/config-done
rm -f $@
make -C gcc-build all install 2>&1 | tee -a gcc-build/make.log; test $${PIPESTATUS[0]} = 0 && touch $@
gdb-build/config-done: gcc-build/build-done $(GDB)
rm -f $@
mkdir -p gdb-build
cd gdb-build ; ../$(GDB)/configure $(BUILD) LDFLAGS="-static" --target=$(TARGET) --prefix=$(PREFIX) \
&& touch config-done
gdb-build/build-done: gdb-build/config-done
rm -f $@
make -C gdb-build all install 2>&1 | tee -a ../make.log; test $${PIPESTATUS[0]} = 0 && touch $@
So, how I can build that toolchain supporting multiple targets having correct generated code ?