Possible internal corruption with i386-win32 -> x86_64-win64 cross compiler
Original Reporter info from Mantis: CuriousKit @CuriousKit
-
Reporter name: J. Gareth Moreton
Original Reporter info from Mantis: CuriousKit @CuriousKit
- Reporter name: J. Gareth Moreton
Description:
There seems to be some internal corruption at play during cross compilation that causes a cascade SIGSEGV. I have found a reproducible case with one of Lazarus' source files.
Steps to reproduce:
Compile FPC under i386-win32 and then the cross compiler for x86_64-win64. This is my personal script (change directories as appropriate):
set mybinutils=C:\Users\NLO-012\Documents\Programming\fpc\binw32<br/>
set builder=C:\lazarus\fpc\3.0.4\bin\i386-win32
set PATH=%mybinutils%;%builder%;%PATH%
cd /d C:\Users\NLO-012\Documents\Programming\fpc
make distclean all install DATA2INC=C:\Users\NLO-012\Documents\Programming\fpc\utils\bin\i386-win32\data2inc.exe OS_TARGET=win32 CPU_TARGET=i386
make crossinstall OS_TARGET=win64 CPU_TARGET=x86_64
cd /d C:\PP\bin\i386-win32
fpcmkcfg -d basepath=C:\PP\ -o C:\PP\bin\i386-win32\fpc.cfg
cd /d C:\Users\NLO-012\Documents\Programming
Using a 32-bit version of Lazarus linked to the 32-bit compiler that you've built, open fpc/compiler/pp.lpi and reconfigure it to compile for x86_64-win64 by changing the custom options to -dx86_64 and then change any paths that reference i386 to x86_64.
Now, in the Run Parameters settings, set the command line parameters to "components\lazutils\ttdebug.pas -g -gl -O3 -Xs -CX -XX -ddisableUTF8RTL -Mobjfpc" (ttdebug.pas has mode Delphi, but other units that it relies on will fail to compile unless -MObjfpc is specified) and the working directory to your lazarus source directory (mine is "C:\Users\NLO-012\Documents\Programming\lazarus")
Run the compiler in the debugger and observe a SIGSEGV as it tries to compile ttdebug (you might have to run it more than once, especially if you do a full build the first time - it doesn't always occur if you use -B, or -O2 instead of -O3)
Now, add "-a" to the command line parameters. This time there's an assembler error akin to "components\lazutils\ttdebug.s:974: Error: alignment not a power of 2". If you analyse ttdebug.s that's produced, you'll find the following on line 914: ".balign 119,0x90". There's nothing that should generate a value of 119 for this alignment field. A possible clue is that it's nestled among a couple of CMOV commands and unused labels.
Additional information:
I stumbled across this while attempting to fix issue #33909 (closed). Personally I cannot see how my changes would cause such a corruption, and I confess I need some help in getting to the bottom of this.
Mantis conversion info:
- Mantis ID: 33926
- OS: Microsoft Windows
- OS Build: 10 Enterprise
- Build: x86_64-win64-win32/win64
- Platform: win64
- Version: 3.1.1
- Target version: 3.1.1