Cross compiler (from 32-bit linux to 32-bit Windows) SEH problem. lazarus / 64-FPC development ---------------------------------------------------------------------- Cyrax · 2018-10-05 23:24 I'm using FPC trunk. In short; when building a cross compiler for 32-bit Windows, there is no support for SEH exception handling even -dTEST_WIN32_SEH is added at make build options. This will cause e.g 32-bit DoubleCommander to quit unexpectedly shortly after it is executed under 32-bit Wine environment. No error messages are displayed. ---------------------------------------------------------------------- PascalDragon · 2018-10-07 08:44 How did you build the cross compiler? A "make clean all OS_TARGET=win32 CPU_TARGET=i386 OPT=-dTEST_WIN32_SEH" should be the way to do it. Does a simple test application raising and catching an exception work? Does it work on Windows? ---------------------------------------------------------------------- Cyrax · 2018-10-07 14:54 I use this make command line to build the cross compiler: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i make all OS_TARGET=win32 CPU_TARGET=i386 OPT="-gw2 -godwarfsets -godwarfmethodclassprefix -gl -O- -Xs- -Si- -vbq -Sew- -dEXTDEBUG -Xd -Fl/usr/lib32 -dTEST_WIN32_SEH" COMPILER_OPTIONS="-gw2 -godwarfsets -godwarfmethodclassprefix -gl -O- -Xs- -Si- -vbq -dEXTDEBUG -Sew- -Xd -Fl/usr/lib32 -dTEST_WIN32_SEH" FPC=fpc REVSTR=39872 UPXPROG=echo NOWPOCYCLE=1 ALLOW_WARNINGS=1 ---------------------------------------------------------------------- Cyrax · 2018-10-07 15:55 In attached file (project1.zip) you will find test project. Under Wine 32-bit it will output following text : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i An unhandled exception occurred at $004016ED:EDivByZero: Division by zero  $004016ED  main,  line 20 of project1.lpr Under Wine 64-bit it will output following text : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Windows 32/64-bit SEH is used.Division by zero I also attached project1.s assembler file for respective OSes. ---------------------------------------------------------------------- PascalDragon · 2018-10-07 16:58 Your Win32 assembly code does not show that it has been compiled with a SEH-enabled compiler. You should see accesses to %fs:(x) instead of fpc_setjmp in the assembly output. Your output however should already have told you that however as the "Windows 32/64-bit SEH is used" line is missing. I also compiled a cross compiler from Linux to Windows locally (though only with -dTEST_WIN32_SEH as option) and your example came out without any problems. So you should probably check whether something in your building went wrong. Also a few notes regarding your build line: - COMPILER_OPTIONS is only needed if you want to add options *only* for the compiler; however the options passed to OPT are passed to the compiler as well, so passing the same values is superfluous - UPXPROG is not required anymore as we've removed UPX support some time ago already - passing ALLOW_WARNINGS and -Sew- is essentially the same as well ---------------------------------------------------------------------- Cyrax · 2018-10-07 23:52 If I leave ALLOW_WARNINGS=1 out, compilation process will stop with this error : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpc -Ur -Xs -O2 -n -Fui386 -Fusystems -Fu/mnt/UUSI_OHJELMOINTI/ ohjelmointi/pascal/binaries/fpc/source/git_source/rtl/units/i386-linux -Fii386 -FE. -FUi386/units/i386-linux -dRELEASE -gw2 -godwarfsets -godwarfmethodclassprefix -gl -O- -Xs- -Si- -vbq -Sew- -dEXTDEBUG -Xd -Fl/usr/lib32   -di386 -dGDB -dBROWSERLOG -Fux86 -Sew pp.pasCompiling Release VersionFree Pascal Compiler version 3.0.4-r37149 [2018/02/11] for i386Copyright (c) 1993-2017 by Florian Klaempfl and others(1002) Target OS: Linux for i386(3104) Compiling pp.pas(3104) Compiling catch.pas(3104) Compiling verbose.pas(3104) Compiling cutils.pas(3104) Compiling constexp.pas(3104) Compiling globtype.pas(3104) Compiling finput.pas(3104) Compiling cclasses.pas(3104) Compiling cstreams.pas/m nt/UUSI_OHJELMOINTI/ohjelmointi/pascal/binaries/fpc/source/git_source/ compiler/cclasses.pas(1141,10) Warning: Location (LOC_REG) not equal to expectloc (LOC_CREG): temprefn/mnt/UUSI_OHJELMOINTI/ohjelmointi/pas cal/binaries/fpc/source/git_source/compiler/cclasses.pas(1141,10) Warning: Location (LOC_REG) not equal to expectloc (LOC_CREG): blockn/ mnt/UUSI_OHJELMOINTI/ohjelmointi/pascal/binaries/fpc/source/git_source /compiler/cclasses.pas(1141,18) Warning: Location (LOC_REG) not equal to expectloc (LOC_CREG): temprefn/mnt/UUSI_OHJELMOINTI/ohjelmointi/pas cal/binaries/fpc/source/git_source/compiler/cclasses.pas(1141,18) Warning: Location (LOC_REG) not equal to expectloc (LOC_CREG): blockn/ mnt/UUSI_OHJELMOINTI/ohjelmointi/pascal/binaries/fpc/source/git_source /compiler/cclasses.pas(1140,14) Warning: Location (LOC_REG) not equal to expectloc (LOC_CREG): temprefn/mnt/UUSI_OHJELMOINTI/ohjelmointi/pas cal/binaries/fpc/source/git_source/compiler/cclasses.pas(1140,14) Warning: Location (LOC_REG) not equal to expectloc (LOC_CREG): blockn/ mnt/UUSI_OHJELMOINTI/ohjelmointi/pascal/binaries/fpc/source/git_source /compiler/cclasses.pas(1147,10) Warning: Location (LOC_REG) not equal to expectloc (LOC_CREG): temprefn/mnt/UUSI_OHJELMOINTI/ohjelmointi/pas cal/binaries/fpc/source/git_source/compiler/cclasses.pas(1147,10) Warning: Location (LOC_REG) not equal to expectloc (LOC_CREG): blockn/ mnt/UUSI_OHJELMOINTI/ohjelmointi/pascal/binaries/fpc/source/git_source /compiler/cclasses.pas(1146,14) Warning: Location (LOC_REG) not equal to expectloc (LOC_CREG): temprefn/mnt/UUSI_OHJELMOINTI/ohjelmointi/pas cal/binaries/fpc/source/git_source/compiler/cclasses.pas(1146,14) Warning: Location (LOC_REG) not equal to expectloc (LOC_CREG): blockncclasses.pas(3186) Fatal: (10026) There were 10 errors compiling module, stoppingFatal: (1018) Compilation abortedError: /mnt/UUSI_OHJE LMOINTI/ohjelmointi/pascal/binaries/fpc/i386/release/3.0.4/binary/rele ase/bin/i386-linux/ppc386 returned an error exitcodemake[5]: *** [Makefile:4329: ppc386] Error 1make[4]: *** [Makefile:4375: next] Error 2make[3]: *** [Makefile:4379: ppc1] Error 2make[2]: *** [Makefile:4391: cycle] Error 2make[1]: *** [Makefile:2824: compiler_cycle] Error 2make: *** [Makefile:2856: build- stamp.i386-linux] Error 2make[5]: Leaving directory '/mnt/UUSI_OHJELMO INTI/ohjelmointi/pascal/binaries/fpc/source/git_source/compiler'make[4 ]: Leaving directory '/mnt/UUSI_OHJELMOINTI/ohjelmointi/pascal/binarie s/fpc/source/git_source/compiler'make[3]: Leaving directory '/mnt/UUSI _OHJELMOINTI/ohjelmointi/pascal/binaries/fpc/source/git_source/compile r'make[2]: Leaving directory '/mnt/UUSI_OHJELMOINTI/ohjelmointi/pascal /binaries/fpc/source/git_source/compiler'make[1]: Leaving directory '/ mnt/UUSI_OHJELMOINTI/ohjelmointi/pascal/binaries/fpc/source/git_source ' ---------------------------------------------------------------------- PascalDragon · 2018-10-08 05:42 Then disable -dEXTDEBUG. That define is only really needed when debugging nasty problems inside the compiler. ---------------------------------------------------------------------- Cyrax · 2018-10-08 05:49 Okay, now I know what was wrong. I didn't pass -dTEST_WIN32_SEH to build environment when targeting solely linux i386 .  I did pass that option only when trying to build the cross compiler. That was the reason why it didn't work at first place.  Now everything works when I use -dTEST_WIN32_SEH in both cases.  Thanks PascalDragon for trying to help me, but it was an user error. ---------------------------------------------------------------------- PascalDragon · 2018-10-08 14:13 To be fair I had already thought that it's a user error after I tested it myself  Maybe it's time to switch trunk to Win32 SEH by default... ---------------------------------------------------------------------- marcov · 2018-10-08 15:20 Quote from: PascalDragon on October 08, 2018, 04:13:41 pmMaybe it's time to switch trunk to Win32 SEH by default... PLEASE YES! :-)