編譯步驟

  • ----- 解壓 --------
  • cd toolchain
  • tar jxvf buildroot-gcc463-src.tar.bz2
  • cd buildroot-2012.11.1
  • ----- 修正 gcc bug --------
  • cd dl
  • tar jxvf gcc-4.6.3.tar.bz2
  • vi gcc-4.6.3/gcc/ira-int.h--- gcc-4.6.3-old/gcc/ira-int.h 2015-07-27 12:51:58.898656272 +0800 +++ gcc-4.6.3/gcc/ira-int.h 2015-07-27 12:53:33.644588455 +0800 @@ -1123,8 +1123,13 @@ ira_allocno_object_iter_cond (ira_allocno_object_iterator *i, ira_allocno_t a, ira_object_t *o) { - *o = ALLOCNO_OBJECT (a, i->n); - return i->n++ < ALLOCNO_NUM_OBJECTS (a); + int n = i->n++; + if (n < ALLOCNO_NUM_OBJECTS (a)) + { + *o = ALLOCNO_OBJECT (a, n); + return true; + } + return false; } /* Loop over all objects associated with allocno A. In each
  • rm gcc-4.6.3.tar.bz2
  • tar cjvf gcc-4.6.3.tar.bz2 gcc-4.6.3
  • cd ..
  • ----- 安裝所需套件 --------
  • sudo apt-get install make gcc g++ bison flex gettext unzip
  • wget http://ftp.gnu.org/gnu/texinfo/texinfo-4.13a.tar.gz
  • tar zxvf texinfo-4.13a.tar.gz
  • cd texinfo-4.13
  • ./configure
  • make
  • sudo make install
  • cd ..
  • ----- 開始編譯 --------
  • sudo make clean
  • sudo make
  • sudo mv /opt/buildroot-gcc463/usr /opt/buildroot-gcc342
  • cd ..
  • ----- build mksquash_lzma --------
  • vi mksquash_lzma-3.2/squashfs3.2-r2/squashfs-tools/Makefile--- mksquash_lzma-3.2-old/squashfs3.2-r2/squashfs-tools/Makefile 2015-07-27 15:22:39.617734535 +0800 +++ mksquash_lzma-3.2/squashfs3.2-r2/squashfs-tools/Makefile 2015-07-27 15:23:24.100545345 +0800 @@ -7,7 +7,7 @@ DebugFlags = -g -Wall -Wno-unused-variable -O0 -UNDEBUG endif CFLAGS += -I${Sqlzma} -D_REENTRANT -DNDEBUG ${DebugFlags} -LDLIBS += -lz -L${LzmaAlone} -L${LzmaC} +LDLIBS += -L${LzmaAlone} -L${LzmaC} Tgt = mksquashfs unsquashfs all: ${Tgt} @@ -21,14 +21,14 @@ ${Sqlzma}/sqlzma.h ${Sqlzma}/sqmagic.h \ ${LzmaAlone}/liblzma_r.a ${LzmaC}/libunlzma_r.a -mksquashfs: LDLIBS += -lpthread -lunlzma_r -llzma_r -lstdc++ +mksquashfs: LDLIBS += -lpthread -lunlzma_r -llzma_r -lstdc++ -lz -lm mksquashfs: mksquashfs.o read_fs.o sort.o unsquashfs.o: CFLAGS += -U_REENTRANT unsquashfs.o: unsquashfs.c squashfs_fs.h read_fs.h global.h \ ${Sqlzma}/sqlzma.h ${Sqlzma}/sqmagic.h ${LzmaC}/libunlzma.a -unsquashfs: LDLIBS += -lunlzma +unsquashfs: LDLIBS += -lunlzma -lz unsquashfs: unsquashfs.o clean:
  • cd mksquash_lzma-3.2
  • make
  • sudo make install
  • cd ..
  • ----- build lzma --------
  • tar zxvf lzma-4.32.7.tar.gz
  • cd lzma-4.32.7
  • ./configure --prefix=/opt/lzma
  • make
  • sudo make install
  • cd ..
  • ----- 修正 new lzma Makefile bug --------
  • cd ../source
  • vi vendors/Ralink/MT7620/Makefile--- vendors-old/Ralink/MT7620/Makefile 2015-07-30 16:18:43.458566161 +0800 +++ vendors/Ralink/MT7620/Makefile 2015-07-30 14:11:38.416326082 +0800 @@ -150,7 +150,7 @@ image: mkimage $(CROSS_COMPILE)objcopy -O binary -R .note -R .comment -S $(ROOTDIR)/$(LINUXDIR)/vmlinux $(KERNELZ) - cd $(IMAGEDIR) ; rm -f $(KERNELZ).*; $(COMP) -9 -f -S .$(COMP) $(KERNELZ) + cd $(IMAGEDIR) ; rm -f $(KERNELZ).*; /opt/lzma/bin/$(COMP) -9 -f -S .$(COMP) $(KERNELZ) ifeq ($(CONFIG_BLK_DEV_INITRD),) ifeq ($(CONFIG_ROOTFS_IN_FLASH_NO_PADDING),)
  • ----- 修正 busybox Makefile --------
  • vi user/busybox/Makefile--- user-old/busybox/Makefile 2015-07-27 13:47:37.904017728 +0800 +++ user/busybox/Makefile 2015-07-27 13:49:20.712446619 +0800 @@ -418,7 +418,7 @@ -include $(srctree)/arch/$(ARCH)/Makefile export KBUILD_DEFCONFIG -config %config: scripts_basic outputmakefile FORCE +%config: scripts_basic outputmakefile FORCE $(Q)mkdir -p include $(Q)$(MAKE) $(build)=scripts/kconfig $@ $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
  • ----- 修正 uClibc++ _associative_citer bug --------
  • vi uClibc++/include/associative_base--- uClibc++_old/include/associative_base 2015-07-27 14:34:10.973985418 +0800 +++ uClibc++/include/associative_base 2015-07-27 14:37:23.036954612 +0800 @@ -320,7 +320,7 @@ typedef std::list<ValueType> listtype; typename listtype::iterator base_iter; - typedef _associative_citer<ValueType, Compare, Allocator> _associative_citer; + typedef _associative_citer<ValueType, Compare, Allocator> __associative_citer; public: @@ -349,13 +349,13 @@ bool operator==(const _associative_iter & m) const{ return m.base_iter == base_iter; } - bool operator==(const _associative_citer & m) const{ + bool operator==(const __associative_citer & m) const{ return m.base_iter == base_iter; } bool operator!=(const _associative_iter & m) const{ return m.base_iter != base_iter; } - bool operator!=(const _associative_citer & m) const{ + bool operator!=(const __associative_citer & m) const{ return m.base_iter != base_iter; } _associative_iter & operator++(){ @@ -380,8 +380,8 @@ --base_iter; return temp; } - operator _associative_citer() const{ - return _associative_citer(base_iter); + operator __associative_citer() const{ + return __associative_citer(base_iter); } typename listtype::iterator base_iterator(){ return base_iter;

問題排解

  • $ make The program 'make' can be found in the following packages: * make * make-guile Try: sudo apt-get install <selected package> 解決方法: sudo apt-get install make
  • $ sudo make /bin/bash: gcc: command not found /bin/bash: line 0: test: -lt: unary operator expected mkdir -p /home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/target if ! [ -d "/home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/target/bin" ]; then \ if [ -d "/home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/system/skeleton" ]; then \ cp -fa /home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/system/skeleton/* /home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/target/; \ fi; \ fi cp support/misc/target-dir-warning.txt /home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/target/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM find /home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/target -type d -name CVS -print0 -o -name .svn -print0 | xargs -0 rm -rf find /home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/target -type f \( -name .empty -o -name '*~' \) -print0 | xargs -0 rm -rf touch /home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/build/.root You must install 'gcc' on your build machine support/dependencies/dependencies.mk:24: recipe for target 'core-dependencies' failed make: *** [core-dependencies] Error 1 解決方法: sudo apt-get install gcc
  • $ sudo make You may have to install 'g++' on your build machine You must install 'bison' on your build machine support/dependencies/dependencies.mk:24: recipe for target 'core-dependencies' failed make: *** [core-dependencies] Error 1 解決方法: sudo apt-get install g++ bison
  • $ sudo make You must install 'flex' on your build machine support/dependencies/dependencies.mk:24: recipe for target 'core-dependencies' failed make: *** [core-dependencies] Error 1 解決方法: sudo apt-get install flex
  • $ sudo make You must install 'msgfmt' on your build machine msgfmt is usually part of the gettext package in your distribution support/dependencies/dependencies.mk:24: recipe for target 'core-dependencies' failed make: *** [core-dependencies] Error 1 解決方法: sudo apt-get install gettext
  • $ sudo make You must install 'makeinfo' on your build machine makeinfo is usually part of the texinfo package in your distribution support/dependencies/dependencies.mk:24: recipe for target 'core-dependencies' failed make: *** [core-dependencies] Error 1 解決方法: sudo apt-get install texinfo
  • $ sudo make You must install 'unzip' on your build machine support/dependencies/dependencies.mk:24: recipe for target 'core-dependencies' failed make: *** [core-dependencies] Error 1 解決方法: sudo apt-get install unzip
  • /home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/toolchain/gcc-4.6.3/gcc/doc/service.texi:6: warning: node up `Service' in menu `Bugs' and in sectioning `Top' differ Makefile:4270: recipe for target 'doc/gcc.info' failed make[2]: *** [doc/gcc.info] Error 1 rm gcc.pod make[2]: Leaving directory '/home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/toolchain/gcc-4.6.3-initial/gcc' Makefile:5252: recipe for target 'all-gcc' failed make[1]: *** [all-gcc] Error 2 make[1]: Leaving directory '/home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/toolchain/gcc-4.6.3-initial' toolchain/gcc/gcc-uclibc-4.x.mk:318: recipe for target '/home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/toolchain/gcc-4.6.3-initial/.compiled' failed make: *** [/home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/toolchain/gcc-4.6.3-initial/.compiled] Error 2 這個主要是 apt-get install texinfo 的版本是 5.2.0,而 gcc 4.6.3 當時的環境是用 texinfo 4.x 的版本,但是很不幸的是 texinfo 4.x 跟 5.x 並不相容,所以只能安裝舊版本才能解決。
  • *** Error in `/home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/toolchain/gcc-4.6.3-intermediate/./gcc/cc1': double free or corruption (fasttop): 0x00000000028cf280 *** /home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/toolchain/gcc-4.6.3/libgcc/../gcc/libgcc2.c: In function '__muldi3': /home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/toolchain/gcc-4.6.3/libgcc/../gcc/libgcc2.c:558:1: internal compiler error: Aborted Please submit a full bug report, with preprocessed source if appropriate. See <http://bugs.buildroot.net/> for instructions. Makefile:377: recipe for target '_muldi3.o' failed make[2]: *** [_muldi3.o] Error 1 make[2]: *** Waiting for unfinished jobs.... /home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/toolchain/gcc-4.6.3/libgcc/../gcc/libgcc2.c: In function '__negdi2': /home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/toolchain/gcc-4.6.3/libgcc/../gcc/libgcc2.c:72:1: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://bugs.buildroot.net/> for instructions. Makefile:377: recipe for target '_negdi2.o' failed make[2]: *** [_negdi2.o] Error 1 make[2]: Leaving directory '/home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/toolchain/gcc-4.6.3-intermediate/mipsel-buildroot-linux-uclibc/libgcc' Makefile:12668: recipe for target 'all-target-libgcc' failed make[1]: *** [all-target-libgcc] Error 2 make[1]: Leaving directory '/home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/toolchain/gcc-4.6.3-intermediate' toolchain/gcc/gcc-uclibc-4.x.mk:383: recipe for target '/home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/toolchain/gcc-4.6.3-intermediate/.compiled' failed make: *** [/home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/output/toolchain/gcc-4.6.3-intermediate/.compiled] Error 2 解決方法: 修正 gcc bug
  • terminal.o:/home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/texinfo-4.13/info/terminal.c:272: more undefined references to `tputs' follow collect2: error: ld returned 1 exit status Makefile:556: recipe for target 'ginfo' failed make[3]: *** [ginfo] Error 1 make[3]: Leaving directory '/home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/texinfo-4.13/info' Makefile:496: recipe for target 'all' failed make[2]: *** [all] Error 2 make[2]: Leaving directory '/home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/texinfo-4.13/info' Makefile:516: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/home/enos/RT288x_SDK/toolchain/buildroot-2012.11.1/texinfo-4.13' Makefile:455: recipe for target 'all' failed make: *** [all] Error 2 解決方法: 重新做 ./configure make clean make 即可。
  • make[3]: Entering directory '/home/enos/RT288x_SDK/source/user/busybox' Makefile:1262: *** mixed implicit and normal rules: deprecated syntax /home/enos/RT288x_SDK/source/user/busybox/Makefile:421: *** mixed implicit and normal rules: deprecated syntax /home/enos/RT288x_SDK/source/user/busybox/Makefile:1262: *** mixed implicit and normal rules: deprecated syntax make[4]: *** No rule to make target 'silentoldconfig'. Stop. Makefile:497: recipe for target 'include/autoconf.h' failed make[3]: *** [include/autoconf.h] Error 2 make[3]: Leaving directory '/home/enos/RT288x_SDK/source/user/busybox' Makefile:177: recipe for target 'busybox' failed make[2]: *** [busybox] Error 2 make[2]: Leaving directory '/home/enos/RT288x_SDK/source/user' Makefile:169: recipe for target 'all' failed make[1]: *** [all] Error 2 make[1]: Leaving directory '/home/enos/RT288x_SDK/source/user' Makefile:427: recipe for target 'user_only' failed make: *** [user_only] Error 2 解決方法: 修正 busybox Makefile
  • /opt/buildroot-gcc342/bin/mipsel-linux-g++ -fno-builtin -nostdinc++ -DGCC_HASCLASSVISIBILITY -I../include -Wall -Wno-trigraphs -pedantic -ansi -O0 -g3 -fPIC -o map.o -c map.cpp In file included from ../include/map:26:0, from map.cpp:20: ../include/associative_base:323:60: error: declaration of 'typedef class std::_associative_citer<ValueType, Compare, Allocator> std::_associative_iter<ValueType, Compare, Allocator>::_associative_citer' [-fpermissive] ../include/associative_base:242:65: error: changes meaning of '_associative_citer' from 'class std::_associative_citer<ValueType, Compare, Allocator>' [-fpermissive] Makefile:74: recipe for target 'map.o' failed make[2]: *** [map.o] Error 1 make[2]: Leaving directory '/home/enos/RT288x_SDK/source/uClibc++/src' Makefile:16: recipe for target 'all' failed make[1]: *** [all] Error 2 make[1]: Leaving directory '/home/enos/RT288x_SDK/source/uClibc++' Makefile:427: recipe for target 'uClibc++_only' failed make: *** [uClibc++_only] Error 2 解決方法: 修正 uClibc++ _associative_citer bug
  • "/opt/buildroot-gcc342/bin"/mipsel-linux-gcc -Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc -Wl,-z,defs -nodefaultlibs -shared -Wl,-soname,libstdc++.so.0 `echo ""` -o libstdc++-0.2.2.so algorithm.o iomanip.o streambuf.o numeric.o map.o fstream.o bitset.o eh_alloc.o set.o new_op.o ostream.o char_traits.o limits.o associative_base.o stack.o stdexcept.o eh_globals.o string.o func_exception.o new_opv.o new_opnt.o deque.o exception.o new_handler.o iostream.o queue.o locale.o list.o ios.o del_opvnt.o valarray.o del_op.o complex.o del_opv.o utility.o iterator.o new_opvnt.o sstream.o vector.o istream.o del_opnt.o abi/abi.o abi/libsupc/eh_throw.o abi/libsupc/cp-demangle.o abi/libsupc/hash_bytes.o abi/libsupc/bad_alloc.o abi/libsupc/pmem_type_info.o abi/libsupc/tinfo.o abi/libsupc/eh_terminate.o abi/libsupc/eh_personality.o abi/libsupc/dyncast.o abi/libsupc/eh_type.o abi/libsupc/vec.o abi/libsupc/guard_error.o abi/libsupc/eh_exception.o abi/libsupc/eh_unex_handler.o abi/libsupc/atexit_arm.o abi/libsupc/class_type_info.o abi/libsupc/vterminate.o abi/libsupc/pointer_type_info.o abi/libsupc/si_class_type_info.o abi/libsupc/pbase_type_info.o abi/libsupc/bad_typeid.o abi/libsupc/guard.o abi/libsupc/bad_cast.o abi/libsupc/function_type_info.o abi/libsupc/eh_term_handler.o abi/libsupc/eh_arm.o abi/libsupc/eh_call.o abi/libsupc/tinfo2.o abi/libsupc/fundamental_type_info.o abi/libsupc/eh_ptr.o abi/libsupc/enum_type_info.o abi/libsupc/eh_aux_runtime.o abi/libsupc/array_type_info.o abi/libsupc/nested_exception.o abi/libsupc/eh_catch.o abi/libsupc/vmi_class_type_info.o -L/opt/buildroot-gcc342/bin/../lib/gcc/mipsel-buildroot-linux-uclibc/4.6.3/ -lc -lgcc -Wl,--as-needed -lgcc_s -Wl,--no-as-needed /opt/buildroot-gcc342/bin/../lib/gcc/mipsel-buildroot-linux-uclibc/4.6.3/../../../../mipsel-buildroot-linux-uclibc/bin/ld: abi/libsupc/eh_throw.o: relocation R_MIPS_HI16 against `__gnu_local_gp' can not be used when making a shared object; recompile with -fPIC abi/libsupc/eh_throw.o: could not read symbols: Bad value collect2: ld returned 1 exit status Makefile:64: recipe for target 'libstdc++-0.2.2.so' failed make[2]: *** [libstdc++-0.2.2.so] Error 1 make[2]: Leaving directory '/home/enos/RT288x_SDK/source/uClibc++/src' Makefile:16: recipe for target 'all' failed make[1]: *** [all] Error 2 make[1]: Leaving directory '/home/enos/RT288x_SDK/source/uClibc++' Makefile:427: recipe for target 'uClibc++_only' failed make: *** [uClibc++_only] Error 2 解決方法: cd uClibc++; make menuconfig 選項 Library Installation Options ---> Build static library 及 Build only static library 二個都打勾。
  • make[1]: Entering directory '/home/enos/RT288x_SDK/source/linux-2.6.36.x' CHK include/linux/version.h CHK include/generated/utsrelease.h CALL scripts/checksyscalls.sh CC init/main.o CHK include/generated/compile.h CC init/version.o CC init/do_mounts.o CC init/do_mounts_rd.o CC init/do_mounts_initrd.o LD init/mounts.o CC init/initramfs.o CC init/calibrate.o LD init/built-in.o HOSTCC usr/gen_init_cpio GEN usr/initramfs_data.cpio.lzma /home/enos/RT288x_SDK/source/linux-2.6.36.x/scripts/gen_initramfs_list.sh: line 300: /opt/buildroot-gcc342/bin/lzma_alone: No such file or directory /home/enos/RT288x_SDK/source/linux-2.6.36.x/usr/Makefile:65: recipe for target 'usr/initramfs_data.cpio.lzma' failed make[2]: *** [usr/initramfs_data.cpio.lzma] Error 1 Makefile:893: recipe for target 'usr' failed make[1]: *** [usr] Error 2 make[1]: Leaving directory '/home/enos/RT288x_SDK/source/linux-2.6.36.x' Makefile:346: recipe for target 'linux' failed make: *** [linux] Error 1 解決方法: 安裝 mksquash_lzma
  • cc mksquashfs.o read_fs.o sort.o -lz -L/home/enos/RT288x_SDK/toolchain/mksquash_lzma-3.2/lzma443/C/7zip/Compress/LZMA_Alone -L/home/enos/RT288x_SDK/toolchain/mksquash_lzma-3.2/lzma443/C/7zip/Compress/LZMA_C -lpthread -lunlzma_r -llzma_r -lstdc++ -o mksquashfs /usr/bin/ld: mksquashfs.o: undefined reference to symbol 'log10@@GLIBC_2.2.5' /lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status <builtin>: recipe for target 'mksquashfs' failed make[1]: *** [mksquashfs] Error 1 make[1]: Leaving directory '/home/enos/RT288x_SDK/toolchain/mksquash_lzma-3.2/squashfs3.2-r2/squashfs-tools' Makefile:28: recipe for target 'all' failed make: *** [all] Error 2 解決方法: 修正 mksquash_lzma Makefile bug

參考資料

台南小新 發表在 痞客邦 PIXNET 留言(0) 人氣()