「クロスコンパイラを一気に作る」を最近の環境で実行しようとしたら

最低限のクロスコンパイラの作り方
https://qiita.com/7shi/items/2d44e040bae930d11088
クロスコンパイラを一気に作る
https://gist.github.com/7shi/1048037

このcross1.mk
をなるべく変更しないで、最近の環境で編纂(compile)しようとしている。

その当時の環境での実現、
クロスコンパイラコンパイル　エラー集
https://qiita.com/kaizen_nagoya/items/85f5221ffecd02a7ee85


特定のチップ用のクロスコンパイラの構築
64bitCPUへの道 (1)V850 gcc 64bit
https://qiita.com/kaizen_nagoya/items/9934c0f9911ad29779b5

MPFR, gccエラー
https://qiita.com/kaizen_nagoya/items/5813a2784cebfda2568c

を実験中。

いずれの方法が、最初に構築できるか、競走中。


#binutils

```
$ apt-get install binutils-source
```

で導入すると、現在の版は
2.28

cross1.mkでは
BINUVER = 2.21.1 

2.28に書き換え。

/buildの下に、
binutils-2.28
というフォルダを作る。

```
# mkdir /build
# cd /build
# ln -s /usr/src/gcc/binutils-2.28 binutils-2.28
```

# gcc
現在の版は8.2.0
cross1.mkでは
 GCCVER  = 4.6.1 

```
# ln -s /usr/src/gcc gcc-8.2.0
```


```Makefile
TARGET1 = alpha-elf arc-elf arm-elf avr-elf h8300-elf i386-elf m32r-elf \
          m68k-elf pdp11-aout powerpc-elf sh-elf sparc-elf v850-elf xtensa-elf
TARGET2 = mips-elf mips64-elf
TARGET3 = hppa-linux ia64-elf x86_64-linux
TARGET4 = m6811-elf
TARGET5 = strongarm-elf xscale-elf
TARGETS = $(TARGET1) $(TARGET2) $(TARGET3) $(TARGET4) $(TARGET5)
BLDROOT = /build
GMAKE   = make
GTAR    = tar
BINUVER = 2.28
GCCVER  = 8.2.0
GCCVER4 = 4.0.4
GCCVER5 = 4.2.4

all: $(TARGETS)

$(TARGET1):
	if [ ! -f /usr/local/bin/$@-as ]; then \
		mkdir -p $(BLDROOT)/$@/binutils && \
		cd $(BLDROOT)/$@/binutils && \
		(if [ ! -f Makefile ]; then ../../binutils-$(BINUVER)/configure --target=$@; fi) && \
		$(GMAKE) && $(GMAKE) install; \
	fi
	if [ ! -f $(BLDROOT)/gcc-$(GCCVER)-msys-cross-$@.tar.xz ]; then \
		mkdir -p $(BLDROOT)/$@/gcc && \
		cd $(BLDROOT)/$@/gcc && \
		(if [ ! -f Makefile ]; then CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ../../gcc-$(GCCVER)/configure --target=$@; fi) && \
		CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib $(GMAKE) all-target-libgcc && \
		rm -rf $(BLDROOT)/$@/dest && \
		cd $(BLDROOT)/$@/binutils && $(GMAKE) prefix=$(BLDROOT)/$@/dest install && \
		cd $(BLDROOT)/$@/gcc && $(GMAKE) prefix=$(BLDROOT)/$@/dest install-gcc install-target-libgcc && \
		(find $(BLDROOT)/$@/dest -name "*.exe" | xargs strip) && \
		cd $(BLDROOT)/$@/dest && $(GTAR) cvJf $(BLDROOT)/gcc-$(GCCVER)-msys-cross-$@.tar.xz *; \
	fi

$(TARGET2):
	if [ ! -f /usr/local/bin/$@-as ]; then \
		mkdir -p $(BLDROOT)/$@/binutils && \
		cd $(BLDROOT)/$@/binutils && \
		(if [ ! -f Makefile ]; then ../../binutils-$(BINUVER)/configure --target=$@; fi) && \
		$(GMAKE) && $(GMAKE) install; \
	fi
	if [ ! -f $(BLDROOT)/gcc-$(GCCVER)-msys-cross-$@.tar.xz ]; then \
		mkdir -p $(BLDROOT)/$@/gcc && \
		cd $(BLDROOT)/$@/gcc && \
		(if [ ! -f Makefile ]; then CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ../../gcc-$(GCCVER)/configure --target=$@; fi) && \
		CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib $(GMAKE) all-gcc && \
		rm -rf $(BLDROOT)/$@/dest && \
		cd $(BLDROOT)/$@/binutils && $(GMAKE) prefix=$(BLDROOT)/$@/dest install && \
		cd $(BLDROOT)/$@/gcc && $(GMAKE) prefix=$(BLDROOT)/$@/dest install-gcc && \
		tar xvJfm $(BLDROOT)/gcc-$(GCCVER)-libgcc-$@.tar.xz -C $(BLDROOT)/$@/dest && \
		(find $(BLDROOT)/$@/dest -name "*.exe" | xargs strip) && \
		cd $(BLDROOT)/$@/dest && $(GTAR) cvJf $(BLDROOT)/gcc-$(GCCVER)-msys-cross-$@.tar.xz *; \
	fi

$(TARGET3):
	if [ ! -f /usr/local/bin/$@-as ]; then \
		mkdir -p $(BLDROOT)/$@/binutils && \
		cd $(BLDROOT)/$@/binutils && \
		(if [ ! -f Makefile ]; then ../../binutils-$(BINUVER)/configure --target=$@; fi) && \
		$(GMAKE) && $(GMAKE) install; \
	fi
	if [ ! -f $(BLDROOT)/gcc-$(GCCVER)-msys-cross-$@.tar.xz ]; then \
		mkdir -p $(BLDROOT)/$@/gcc && \
		cd $(BLDROOT)/$@/gcc && \
		(if [ ! -f Makefile ]; then CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ../../gcc-$(GCCVER)/configure --target=$@; fi) && \
		CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib $(GMAKE) all-gcc && \
		rm -rf $(BLDROOT)/$@/dest && \
		cd $(BLDROOT)/$@/binutils && $(GMAKE) prefix=$(BLDROOT)/$@/dest install && \
		cd $(BLDROOT)/$@/gcc && $(GMAKE) prefix=$(BLDROOT)/$@/dest install-gcc && \
		(find $(BLDROOT)/$@/dest -name "*.exe" | xargs strip) && \
		cd $(BLDROOT)/$@/dest && $(GTAR) cvJf $(BLDROOT)/gcc-$(GCCVER)-msys-cross-$@.tar.xz *; \
	fi

$(TARGET4):
	if [ ! -f /usr/local/bin/$@-as ]; then \
		mkdir -p $(BLDROOT)/$@/binutils && \
		cd $(BLDROOT)/$@/binutils && \
		(if [ ! -f Makefile ]; then ../../binutils-$(BINUVER)/configure --target=$@; fi) && \
		$(GMAKE) && $(GMAKE) install; \
	fi
	if [ ! -f $(BLDROOT)/gcc-$(GCCVER4)-msys-cross-$@.tar.xz ]; then \
		mkdir -p $(BLDROOT)/$@/gcc && \
		cd $(BLDROOT)/$@/gcc && \
		(if [ ! -f Makefile ]; then ../../gcc-$(GCCVER4)/configure --target=$@; fi) && \
		$(GMAKE) && \
		rm -rf $(BLDROOT)/$@/dest && \
		cd $(BLDROOT)/$@/binutils && $(GMAKE) prefix=$(BLDROOT)/$@/dest install && \
		cd $(BLDROOT)/$@/gcc && $(GMAKE) prefix=$(BLDROOT)/$@/dest install && \
		(find $(BLDROOT)/$@/dest -name "*.exe" | xargs strip) && \
		cd $(BLDROOT)/$@/dest && $(GTAR) cvJf $(BLDROOT)/gcc-$(GCCVER4)-msys-cross-$@.tar.xz *; \
	fi

$(TARGET5):
	if [ ! -f /usr/local/bin/$@-as ]; then \
		mkdir -p $(BLDROOT)/$@/binutils && \
		cd $(BLDROOT)/$@/binutils && \
		(if [ ! -f Makefile ]; then ../../binutils-$(BINUVER)/configure --target=$@; fi) && \
		$(GMAKE) && $(GMAKE) install; \
	fi
	if [ ! -f $(BLDROOT)/gcc-$(GCCVER5)-msys-cross-$@.tar.xz ]; then \
		mkdir -p $(BLDROOT)/$@/gcc && \
		cd $(BLDROOT)/$@/gcc && \
		(if [ ! -f Makefile ]; then ../../gcc-$(GCCVER5)/configure --target=$@; fi) && \
		$(GMAKE) gcc && \
		rm -rf $(BLDROOT)/$@/dest && \
		cd $(BLDROOT)/$@/binutils && $(GMAKE) prefix=$(BLDROOT)/$@/dest install && \
		cd $(BLDROOT)/$@/gcc && $(GMAKE) prefix=$(BLDROOT)/$@/dest install-gcc && \
		(find $(BLDROOT)/$@/dest -name "*.exe" | xargs strip) && \
		cd $(BLDROOT)/$@/dest && $(GTAR) cvJf $(BLDROOT)/gcc-$(GCCVER5)-msys-cross-$@.tar.xz *; \
	fi

clean:
	for target in $(TARGETS); do \
		rm -rf $(BLDROOT)/$$target $(BLDROOT)/gcc-$(GCCVER)-msys-cross-$$target.tar.xz /usr/local/bin/$$target-* /usr/local/$$target; \
	done
```

```
for file in $parts; do					\
  rm -f /build/v850-elf/dest/lib/gcc/v850-elf/8.2.0/8byte/gcc-abi/soft-float/v850e3v5/$file;		\
  /usr/bin/install -c -m 644 $file /build/v850-elf/dest/lib/gcc/v850-elf/8.2.0/8byte/gcc-abi/soft-float/v850e3v5/;	\
  case $file in 					\
    *.a)						\
      /usr/local/v850-elf/bin/ranlib ../../../../../.././gcc/8byte/gcc-abi/soft-float/v850e3v5/$file ;;	\
  esac;							\
done
/bin/bash ../../../../../../../../gcc-8.2.0/libgcc/../mkinstalldirs /build/v850-elf/dest/lib/gcc/v850-elf/8.2.0/include
/usr/bin/install -c -m 644 unwind.h /build/v850-elf/dest/lib/gcc/v850-elf/8.2.0/include
/bin/bash ../../../../../../../../gcc-8.2.0/libgcc/../mkinstalldirs /build/v850-elf/dest/lib/gcc/v850-elf/8.2.0/include
/usr/bin/install -c -m 644 ../../../../../../../../gcc-8.2.0/libgcc/gcov.h /build/v850-elf/dest/lib/gcc/v850-elf/8.2.0/include
make[4]: Leaving directory '/build/v850-elf/gcc/v850-elf/8byte/gcc-abi/soft-float/v850e3v5/libgcc'
make[3]: Leaving directory '/build/v850-elf/gcc/v850-elf/libgcc'
make[2]: Leaving directory '/build/v850-elf/gcc/v850-elf/libgcc'
make[1]: Leaving directory '/build/v850-elf/gcc'
Usage: strip <option(s)> in-file(s)
 Removes symbols and sections from files
 The options are:
  -I --input-target=<bfdname>      Assume input file is in format <bfdname>
  -O --output-target=<bfdname>     Create an output file in format <bfdname>
  -F --target=<bfdname>            Set both input and output format to <bfdname>
  -p --preserve-dates              Copy modified/access timestamps to the output
  -D --enable-deterministic-archives
                                   Produce deterministic output when stripping archives (default)
  -U --disable-deterministic-archives
                                   Disable -D behavior
  -R --remove-section=<name>       Also remove section <name> from the output
     --remove-relocations <name>   Remove relocations from section <name>
  -s --strip-all                   Remove all symbol and relocation information
  -g -S -d --strip-debug           Remove all debugging symbols & sections
     --strip-dwo                   Remove all DWO sections
     --strip-unneeded              Remove all symbols not needed by relocations
     --only-keep-debug             Strip everything but the debug information
  -N --strip-symbol=<name>         Do not copy symbol <name>
  -K --keep-symbol=<name>          Do not strip symbol <name>
     --keep-file-symbols           Do not strip file symbol(s)
  -w --wildcard                    Permit wildcard in symbol comparison
  -x --discard-all                 Remove all non-global symbols
  -X --discard-locals              Remove any compiler-generated symbols
  -v --verbose                     List all object files modified
  -V --version                     Display this program's version number
  -h --help                        Display this output
     --info                        List object formats & architectures supported
  -o <file>                        Place stripped output into <file>
strip: supported targets: elf64-x86-64 elf32-i386 elf32-iamcu elf32-x86-64 a.out-i386-linux pei-i386 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big pe-x86-64 pe-bigobj-x86-64 pe-i386 plugin srec symbolsrec verilog tekhex binary ihex
Makefile:13: recipe for target 'v850-elf' failed
make: *** [v850-elf] Error 123
```
# 文書履歴(document history)
ver. 0.01 初稿 20230226
ver. 0.04 URL追記　20230226

### 最後までおよみいただきありがとうございました。

いいね　💚、フォローをお願いします。

####  Thank you very much for reading to the last sentence.

Please press the like icon 💚　and follow me for your happy life.

zve