Recent

Author Topic: Bootstrapping a "host compiler"  (Read 4310 times)

Laphicet

  • New member
  • *
  • Posts: 8
Bootstrapping a "host compiler"
« on: May 02, 2021, 01:19:28 am »
I've been wanting to bootstrap FPC for the MSYS2/MinGW-w64 ecosystem for a while now and I tried earlier, using a regular Win32 installation of FPC. However, what I want to build is not a cross compiler, but a host compiler, using another host compiler. There is no documentation on how to do this. Sure, there's a cross compiler bootstrap-but a cross compiler still depends on the FPC installation it was built from. This needs to be independent of another FPC installation. I have the proper binutils and stuff, but that's it.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9531
  • FPC developer.
Re: Bootstrapping a "host compiler"
« Reply #1 on: May 02, 2021, 12:22:27 pm »
We called the target x86_64-win64. Straight forward FPC use is mingw(64) free as FPC has internal assemblers and linkers though.

The key is to use known good binutils from the "fpcbuild" release building repository.  (directories install/bin*), and then just following regular crossbuilding procedures. 

I attach my 64-bit build script, but it assumes the binw64 files have been set up in the path.  Please rename it back to a .CMD extension. I changed it to .txt to suit the forum software.

The start compiler is the regular win32 3.2.0 release :

set FPCSTART=c:\fpc\3.2.0\bin\i386-win32\ppc386.exe

but the result is entirely 64-bit.


Make sure your %PATH% is free of other development tools. (mingw,cygwin, but also commercials like Delphi and Visual studio that might package non standard tools, most notably make and sh)

Just give it a try, and report back here with detail and we figure it out. It is not hard, and once you have a working setup, very repeatable.
« Last Edit: May 02, 2021, 12:25:41 pm by marcov »

Laphicet

  • New member
  • *
  • Posts: 8
Re: Bootstrapping a "host compiler"
« Reply #2 on: May 02, 2021, 09:30:58 pm »
I tried running your commands, however, I still get the same error output:

Code: Pascal  [Select][+][-]
  1. C:/Users/admin/Documents/GitHub/MINGW-packages/mingw-w64-fpc/src/app/bin/i386-win32/ppc386.exe -Ur -Xs -O2 -n -Fui386 -Fusystems -Fu../rtl/units/i386-win32 -Fii386 -FE. -FUi386/units/i386-win32 -dRELEASE -di386 -dGDB -dBROWSERLOG -Fux86 -Sew pp.pas
  2. D:/msys64/usr/bin/mv.exe -f ./pp.exe ppc.exe
  3. mingw32-make[4]: Leaving directory 'C:/Users/admin/Documents/GitHub/MINGW-packages/mingw-w64-fpc/src/fpcbuild-3.2.0/fpcsrc/compiler'
  4. D:/msys64/mingw64/bin/mingw32-make.exe 'FPC=/c/Users/admin/Documents/GitHub/MINGW-packages/mingw-w64-fpc/src/fpcbuild-3.2.0/fpcsrc/compiler/ppc.exe' OS_TARGET=win32 CPU_TARGET=i386 CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 rtlclean rtl CYCLELEVEL=2
  5. mingw32-make[4]: Entering directory 'C:/Users/admin/Documents/GitHub/MINGW-packages/mingw-w64-fpc/src/fpcbuild-3.2.0/fpcsrc/compiler'
  6. Makefile:135: *** Compiler /c/Users/admin/Documents/GitHub/MINGW-packages/mingw-w64-fpc/src/fpcbuild-3.2.0/fpcsrc/compiler/ppc.exe not found.  Stop.
  7.  

For reference, this is the bootstrap script I did for MSYS2:
Code: Bash  [Select][+][-]
  1. prepare() {
  2.   cd $srcdir
  3.   ./innoextract fpc-$pkgver.i386-win32.exe # MinGW-w64 `innoextract` is busted
  4. }
  5.  
  6. build() {
  7.   cd "fpcbuild-${pkgver}"
  8.  
  9.   declare -a extra_config
  10.   if [ "$CARCH" = "x86_64" ]; then
  11.     extra_config+=("CPU_TARGET=x86_64")
  12.     extra_config+=("OS_TARGET=win64")
  13.   else
  14.     extra_config+=("CPU_TARGET=i386")
  15.     extra_config+=("OS_TARGET=win32")
  16.   fi
  17.  
  18.   BINUTILSPREFIX=${MINGW_CHOST}- ${MINGW_PREFIX}/bin/mingw32-make \
  19.         -j1 NOGDB=1 all crossinstall FPC="$srcdir/app/bin/i386-win32/ppc386.exe" \
  20.         PREFIX="$srcdir/tmp_install-$CARCH" ${extra_config[@]}
  21. }
« Last Edit: May 02, 2021, 10:08:01 pm by Laphicet »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9531
  • FPC developer.
Re: Bootstrapping a "host compiler"
« Reply #3 on: May 02, 2021, 11:10:49 pm »
As said, using msys is not supported, nor its emulated path conventions like the  /c/Users/admin/Documents... (clearly visible in your error messages). If some tool passes that to a FPC compiled binary, as a native windows program, it wouldn't know what to do with it, and the makefiles are also not meant for it.

The FPC tools are msysless mingw tools (and usually older, since except for make and gdb not very critical anymore)

Unless you know what you are doing, use the provided bin and coretools from the fpcbuild repository, and not msys or other emulations (like cygwin).

« Last Edit: May 02, 2021, 11:12:40 pm by marcov »

Laphicet

  • New member
  • *
  • Posts: 8
Re: Bootstrapping a "host compiler"
« Reply #4 on: May 03, 2021, 04:10:06 am »
Oh! I feel silly. It was the path names all this time! Okay, well, yeah, I've been doing that. However, I wanted to see if I could use MSYS and integrate it.

Nevertheless, thanks!

PascalDragon

  • Hero Member
  • *****
  • Posts: 3324
  • Compiler Developer
Re: Bootstrapping a "host compiler"
« Reply #5 on: May 03, 2021, 09:05:09 am »
Oh! I feel silly. It was the path names all this time! Okay, well, yeah, I've been doing that. However, I wanted to see if I could use MSYS and integrate it.

Why would you want to? FPC natively uses the Windows API and does not need MSYS, Cygwin or whatever.

 

TinyPortal © 2005-2018