Recent

Author Topic: Cross compile Win32/i386 -> AIX/PowerPc  (Read 7543 times)

dextermd

  • New Member
  • *
  • Posts: 13
Cross compile Win32/i386 -> AIX/PowerPc
« on: January 20, 2016, 12:26:37 pm »
Hi,

I managed to cross compile Win32/i386 -> Linux/i386.
Now I'm trying buld fpc libraries for crosscompiling Win32/i386 -> AIX/PowerPc and getting the following error.

Is fpc\rtl\units\powerpc-aix\system.s file wrong?
FPC 3.0.0

make[5]: Entering directory `C:/development/fpc/rtl/aix'
C:/development/fpc/bin/i386-win32/gmkdir.exe -p C:/development/fpc/rtl/units/powerpc-aix
C:/development/fpc/compiler/ppcrossppc.exe -Ur -dFPC_USE_LIBC -dNOMOUSE -Taix -Ppowerpc -XPpowerpc-aix- -Xr -Ur -Xs -O2
-n -Fi../inc -Fi../powerpc -Fi../unix -FDC:\development\cross\bin\powerpc-aix -FE. -FUC:/development/fpc/rtl/units/power
pc-aix -vh- -g -gl -O1 -Xs -CX -XX -Xd -FlC:\development\cross\lib\powerpc-aix -XPpowerpc-aix- -dpowerpc -dRELEASE -XPpo
werpc-aix- -Us -Sg system.pp
system.inc(1824,8) Warning: Implicit string type conversion from "RawByteString" to "UnicodeString"
C:\development\fpc\rtl\units\powerpc-aix\system.s: Assembler messages:
C:\development\fpc\rtl\units\powerpc-aix\system.s:87914: Error: junk at end of line, first unrecognized character is `,'

C:\development\fpc\rtl\units\powerpc-aix\system.s:87918: Error: junk at end of line, first unrecognized character is `,'

C:\development\fpc\rtl\units\powerpc-aix\system.s:87922: Error: junk at end of line, first unrecognized character is `,'

C:\development\fpc\rtl\units\powerpc-aix\system.s:87926: Error: junk at end of line, first unrecognized character is `,'

C:\development\fpc\rtl\units\powerpc-aix\system.s:87930: Error: junk at end of line, first unrecognized character is `,'

C:\development\fpc\rtl\units\powerpc-aix\system.s:87934: Error: junk at end of line, first unrecognized character is `,'

C:\development\fpc\rtl\units\powerpc-aix\system.s:87938: Error: junk at end of line, first unrecognized character is `,'

C:\development\fpc\rtl\units\powerpc-aix\system.s:87942: Error: junk at end of line, first unrecognized character is `,'

C:\development\fpc\rtl\units\powerpc-aix\system.s:87946: Error: junk at end of line, first unrecognized character is `,'

C:\development\fpc\rtl\units\powerpc-aix\system.s:87950: Error: junk at end of line, first unrecognized character is `,'

system.pp(299) Error: Error while assembling exitcode 1
system.pp(299) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted
make[5]: *** [system.ppu] Error 1
make[5]: Leaving directory `C:/development/fpc/rtl/aix'
make[4]: *** [aix_all] Error 2
make[4]: Leaving directory `C:/development/fpc/rtl'
make[3]: ***
Error 2
make[3]: Leaving directory `C:/development/fpc/compiler'
make[2]: *** [cycle] Error 2
make[2]: Leaving directory `C:/development/fpc/compiler'
make[1]: *** [compiler_cycle] Error 2
make[1]: Leaving directory `C:/development/fpc'
make: *** [build-stamp.powerpc-aix] Error 2
make: Leaving directory `C:/development/fpc'

Laksen

  • Hero Member
  • *****
  • Posts: 734
    • J-Software
Re: Cross compile Win32/i386 -> AIX/PowerPc
« Reply #1 on: January 20, 2016, 01:01:03 pm »
What version of binutils are you using?

And what's at line 87914 of system.s?

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: Cross compile Win32/i386 -> AIX/PowerPc
« Reply #2 on: January 20, 2016, 04:00:00 pm »
I managed to cross compile Win32/i386 -> Linux/i386.
Now I'm trying buld fpc libraries for crosscompiling Win32/i386 -> AIX/PowerPc and getting the following error.

Is fpc\rtl\units\powerpc-aix\system.s file wrong?
FPC 3.0.0
Unfortunately, due to a local modification in the checkout of the machine that performs our nightly testsuite runs for AIX, FPC 3.0 got released with a bug that breaks compiling for AIX (the local modification contained the fix for that problem). As a result, you have to apply the patch from http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&revision=29471 to your FPC 3.0 sources to make it work.

dextermd

  • New Member
  • *
  • Posts: 13
Re: Cross compile Win32/i386 -> AIX/PowerPc
« Reply #3 on: January 21, 2016, 02:07:43 pm »
I have updated updated aasmbase.pas file (by replacing "string[23]" -> "string" in asmsymbindname definition), run
fpclazup.exe --ostarget="aix" --cputarget="powerpc" --only="FPCCleanOnly,FPCBuildOnly" --verbose

but error is still the same.

If  I just replace the aasmbase.pas file with the one from the patch - there will be another error about missing "Createstatic" method, and it's logic, since this method is missing from the aasmbase.pas file located in the patch.

I'm using FPC 3.1.1 / trunk.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: Cross compile Win32/i386 -> AIX/PowerPc
« Reply #4 on: January 21, 2016, 02:17:22 pm »
I have updated updated aasmbase.pas file (by replacing "string[23]" -> "string" in asmsymbindname definition), run
fpclazup.exe --ostarget="aix" --cputarget="powerpc" --only="FPCCleanOnly,FPCBuildOnly" --verbose

but error is still the same.
The diff shows that string is replaced with ansistring in the declaration of ReplaceForbiddenAsmSymbolChars (click on the "Text changed" link). Where does the above change come from?

Quote
If  I just replace the aasmbase.pas file with the one from the patch - there will be another error about missing "Createstatic" method, and it's logic, since this method is missing from the aasmbase.pas file located in the patch.

I'm using FPC 3.1.1 / trunk.
In your original message you said you used FPC 3.0? The above change is already in FPC 3.1.1/trunk, so there no changes should be necessary at all. Do you mean that you are compiling FPC 3.1.1 with FPC 3.0? In that case, how did you build your binutils? And as Laksen asked, please also post one of the erroring lines of system.s

dextermd

  • New Member
  • *
  • Posts: 13
Re: Cross compile Win32/i386 -> AIX/PowerPc
« Reply #5 on: January 21, 2016, 03:04:29 pm »
Regarding aasmbase.pas - you are right, I understood wrongly what I have to patch.

Anyway, originally I used FPC 3.0.0.
Now I upgraded to FPC 3.1.1 hoping the issue is fixed and it's NOT :(
Still same error (see below)
BinUtils I'm using the ones suggested on http://wiki.freepascal.org/FPC_AIX_Port

Line 89565 in file system.s contains:   .lcomm U_.SYSTEM_.._EXCEPTADDRSTACK,8,_data.bss_,2


C:/development/fpc/compiler/ppcrossppc.exe -Ur -dFPC_USE_LIBC -dNOMOUSE -Taix -Ppowerpc -XPpowerpc-aix- -Xr -Ur -Xs -O2
-n -Fi../inc -Fi../powerpc -Fi../unix -FDC:\development\cross\bin\powerpc-aix -FE. -FUC:/development/fpc/rtl/units/power
pc-aix -vh- -g -gl -O1 -Xs -CX -XX -Xd -FlC:\development\cross\lib\powerpc-aix -XPpowerpc-aix- -dpowerpc -dRELEASE -XPpo
werpc-aix- -Us -Sg system.pp
C:\development\fpc\rtl\units\powerpc-aix\system.s: Assembler messages:
C:\development\fpc\rtl\units\powerpc-aix\system.s:89565: Error: junk at end of line, first unrecognized character is `,'

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: Cross compile Win32/i386 -> AIX/PowerPc
« Reply #6 on: January 21, 2016, 03:13:10 pm »
You will have to compile newer binutils. Those binutils are from 2012, and the "align" specifier for .lcomm directives was only added to binutils in 2013: https://sourceware.org/ml/binutils/2013-08/msg00098.html

We need it in FPC to be able to guarantee the alignment of the emitted data.

dextermd

  • New Member
  • *
  • Posts: 13
Re: Cross compile Win32/i386 -> AIX/PowerPc
« Reply #7 on: January 21, 2016, 03:29:26 pm »
The linux binutils I compiled using Fedora.
I have no access to AIX.

Does anyone have the fresh powerpc-aix-win32 binutils (please) ?

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: Cross compile Win32/i386 -> AIX/PowerPc
« Reply #8 on: January 21, 2016, 03:43:55 pm »
I compiled those Win32 binutils back then also on either Linux or Mac OS X, but I don't remember the exact details. You first have to install a cross-compilation tool chain for Win32 (installing mingw32-gcc via yum is probably enough). Then run the installed gcc binary (mingw32-gcc?) with the "-v" option at see how it identifies its target. Finally, use the configure line from the wiki, but add --host=<target from gcc>

In case you want to google for more info, this kind of compilation (building a tool chain while you are on platform X, where the tools will have to run on platform Y and generate code for platfor Z) is called a "Canadian cross tool chain". canadian cross mingw32 binutils or something like that should provide extra info. You can also have a look at the configure script of binutils and search for win32 or mingw32 to see how it expects you to specify the name of the target. See also the output for "./configure --help"

FPK

  • Moderator
  • Full Member
  • *****
  • Posts: 118
Re: Cross compile Win32/i386 -> AIX/PowerPc
« Reply #9 on: January 21, 2016, 08:48:04 pm »
I uploaded freshly built binutils powerpc-aix-win32 to ftp://ftp.freepascal.org/pub/fpc/contrib/aix/binutils%202.25.1-powerpc-aix-win32.zip They aren't tested fully but at least the rtl and the compiler assemble.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: Cross compile Win32/i386 -> AIX/PowerPc
« Reply #10 on: January 21, 2016, 08:50:39 pm »
Thanks! I've linked them from the wiki page.

dextermd

  • New Member
  • *
  • Posts: 13
Re: Cross compile Win32/i386 -> AIX/PowerPc
« Reply #11 on: January 21, 2016, 09:13:00 pm »
Cool, thanks a lot FPK!

dextermd

  • New Member
  • *
  • Posts: 13
Re: Cross compile Win32/i386 -> AIX/PowerPc
« Reply #12 on: January 21, 2016, 10:14:28 pm »
With new binutils the previous issue is gone.

Now I'm facing the next error:
===========================
C:/development/fpc/compiler/ppcrossppc.exe -Ur -dFPC_USE_LIBC -dNOMOUSE -Taix -Ppowerpc -XPpowerpc-aix- -Xr -Ur -Xs -O2
-n -Fi../inc -Fi../powerpc -Fi../unix -FDC:\development\cross\bin\powerpc-aix -FE. -FUC:/development/fpc/rtl/units/power
pc-aix -vh- -g -gl -O1 -Xs -CX -XX -Xd -FlC:\development\cross\lib\powerpc-aix -XPpowerpc-aix- -dpowerpc -dRELEASE -XPpo
werpc-aix- -Us -Sg system.pp
make[5]: Leaving directory `C:/development/fpc/rtl/aix'
make[5]: *** No rule to make target `uuchar.ppu', needed by `fpc_units'.  Stop.
make[4]: *** [aix_all] Error 2
===========================

fpc.cfg file from binutils folder is:
===========================
# select AIX target
-Taix
# adjust next two lines to point to the install directory (but leave in the $fpctarget!)
-FuC:\development\cross\units\$fpctarget\*
-FuC:\development\cross\\units\$fpctarget\rtl
# adjust the next line to point to the directory containing the usr and lib directories as mentioned above
-XRc:\development\cross\lib\$fpctarget\*

-l
-O2
# prefix for cross-assembler and cross-linker
-XPpowerpc-aix-
===========================

c:\development\cross\lib\$fpctarget\* points to lib\... and usr\lib with the libraries from AIX.

Do I have to copy uuchar.pp from d:\Prog\FreePascal\dev\fpc\rtl\inc to C:/development/fpc/rtl/aix ?


Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: Cross compile Win32/i386 -> AIX/PowerPc
« Reply #13 on: January 21, 2016, 10:31:20 pm »
You are probably using make 3.82, which has special requirements regarding specifying the dependencies in the Makefile. Try updating to the latest svn trunk revision, Florian updated the AIX Makefile so it's compatible with make 3.82.

dextermd

  • New Member
  • *
  • Posts: 13
Re: Cross compile Win32/i386 -> AIX/PowerPc
« Reply #14 on: January 22, 2016, 09:42:28 am »
Thanks Jonas,
I managed to bypass the "no rule" issue and faced the next one :) (see below)
I think it's configuration related.

=====================================================
C:/development/fpc/compiler/ppcrossppc.exe -Taix -Ppowerpc -XPpowerpc-aix- -Xr -Ur -Xs -O2 -n -Fupowerpc -Fusystems -FuC
:/development/fpc/rtl/units/powerpc-aix -Fipowerpc -FDC:\development\cross\bin\powerpc-aix -FE. -FUpowerpc/units/powerpc
-aix -dRELEASE -XPpowerpc-aix- -vh- -g -gl -O1 -Xs -CX -XX -Xd -FlC:\development\cross\lib\powerpc-aix -dpowerpc -dGDB -
dBROWSERLOG -Fuppcgen -Sew -XPpowerpc-aix-    -dpowerpc -dGDB -dBROWSERLOG -Fuppcgen -Sew pp.pas
pp.pas(219,36) Warning: Object /lib/crt0.o not found, Linking may fail !
=====================================================

The fpc.cfg file (located in binutils folder) points to lib folder (inside the lib/crt0.o is located)
-XRc:\development\cross\lib\$fpctarget\*
-XRc:\development\cross\lib\$fpctarget

How to pass to ppcrossppc.exe the right -XR parameter?




 

TinyPortal © 2005-2018