Which bitness first ? lazarus / 21-General ---------------------------------------------------------------------- 440bx · 2024-06-25 07:43 Basically, the question is: do you normally start developing the 64 bit version first and then "port" it to 32 bit or do you normally develop the 32 bit version first and then "port" it to 64 bit ? ---------------------------------------------------------------------- marcov · 2024-06-25 07:54 I usually only have one. I start with 32-bit on Windows unless it really is clear up front it uses a lot of memory, and 64-bit on *nix. Reasons for 32-bit on Windows is that both IDEs that I use are more stable (Delphi 10.0, Lazarus)  with debugging 32-bit binaries. ---------------------------------------------------------------------- 440bx · 2024-06-25 08:12 Quote from: marcov on June 25, 2024, 09:54:04 amReasons for 32-bit on Windows is that both IDEs that I use are more stable (Delphi 10.0, Lazarus)  with debugging 32-bit binaries. Interesting... your choice is determined by the debugger being more stable in one bitness than the other.  I guess you should vote "32 bit first" then, if you are amenable to voting, of course. I haven't noticed any difference in stability in Lazarus as far as the debugger's stability (fpdebug) but, I do well over 95% of my debugging in 64 bit. ---------------------------------------------------------------------- Thaddy · 2024-06-25 08:33 On Windows, I guess you mean just Windows, I only use 32 bit for audio programming. Everywhere else I use the maximum bitness of the OS/CPU so I can't answer the question. ---------------------------------------------------------------------- marcov · 2024-06-25 08:37 That experience is still based on gdb debugging. Also I should say many larger production programs are 64-bit, both because of memory and quite often because coding SSE2 is easier.  Most of them were changed in the Windows 8 era (when Microsoft allowed cheap upgrades to windows 8 from older versions and at the same time switch the license from 32-bit to 64-bit) The largest however is still 32-bit, partially because it heavily relies on FPU performance (and SSE2 fpu seemed slower for non elemental (gonio) operations, though I did those tests a decade ago and I'm about to revisit them), and because it uses a different camera API that is not tested for 64-bit. I don't have any commercial programming on *nix though. ---------------------------------------------------------------------- domasz · 2024-06-25 09:05 For Windows I almost only do 64 bits now. 64 bit Windows systems are now on the market for 20 years. If someone still has a 32 bit version then this person must have a really old computer with lots of hardware, software and drivers no longer supported by manufactures. I don't care about people reporting that my app crashes because they don't have 100 MB of free RAM or something similar. If you can't afford a 10 year old PC then you should stick to ancient software. If I were paid by the hour then I would port my programs to pretty much anything. But I am not so I must be realistic. Why don't I just make 32 bits? Because they can access 2 GB of RAM and that's often not enough. ---------------------------------------------------------------------- Martin_fr · 2024-06-25 10:10 Quote from: marcov on June 25, 2024, 09:54:04 amReasons for 32-bit on Windows is that both IDEs that I use are more stable (Delphi 10.0, Lazarus)  with debugging 32-bit binaries.Quote from: marcov on June 25, 2024, 10:37:14 amThat experience is still based on gdb debugging. A bit off topic, so if the reply is longer, maybe start a new thread. What gdb feature do you need, that prevents using FpDebug? ---------------------------------------------------------------------- TRon · 2024-06-25 10:21 Can't answer because it depends on the OS bitness I'm working on. In practice it doesn't matter much if you code platform agnostic though it might occur to prefer a certain bitness if the application requires it (but basically and in my eyes that is kinda of a defeat if you can't work around the limitations). ---------------------------------------------------------------------- marcov · 2024-06-25 10:48 Quote from: Martin_fr on June 25, 2024, 12:10:08 pmA bit off topic, so if the reply is longer, maybe start a new thread. What gdb feature do you need, that prevents using FpDebug? In this case it was simply a matter of when those applications were created. fpdebug was not yet a factor then. I do however have need for a SIMD register (SSE2/AVX2) assembler CPU window though ---------------------------------------------------------------------- VisualLab · 2024-06-25 12:36 Is your question only about developing Windows/Linux on x86/AMD64? Or maybe it also covers 32-bit ARM microcontrollers (e.g. RPi Pico)? ---------------------------------------------------------------------- 440bx · 2024-06-25 13:20 Quote from: VisualLab on June 25, 2024, 02:36:24 pmIs your question only about developing Windows/Linux on x86/AMD64? Or maybe it also covers 32-bit ARM microcontrollers (e.g. RPi Pico)? The question is meant to cover CPUs and O/Ss that support both bitnesses, e.g, on Windows it is possible (given the right O/S version) to run either a 32 bit program or a 64 bit program.   Since both options are available, I wanted to know if programmers had a preference as to which version to develop first given those possibilities. ---------------------------------------------------------------------- Thaddy · 2024-06-25 13:29 On linux that is also possible. Some distro's have multi-arch support as default, like Ubuntu. Preference is highest available unless drivers are missing (ASIO/VST, ODBC) ---------------------------------------------------------------------- BeniBela · 2024-06-25 15:29 Quote from: domasz on June 25, 2024, 11:05:09 amIf you can't afford a 10 year old PC then you should stick to ancient software. That is why I use Pascal! Although I now develop for 64-bit. I got a free laptop from my university ---------------------------------------------------------------------- PascalDragon · 2024-06-25 18:18 Quote from: 440bx on June 25, 2024, 09:43:32 amBasically, the question is: do you normally start developing the 64 bit version first and then "port" it to 32 bit or do you normally develop the 32 bit version first and then "port" it to 64 bit ? For me it depends on the system I'm on... on my home PC it would be 64-bit cause that's my default compiler on that system, on my work PC it would be 32-bit cause that's my default there. Mainly so that at least someone still checks whether i386-win32 of 3.3.1 is working correctly ---------------------------------------------------------------------- marcov · 2024-06-25 20:04 Quote from: PascalDragon on June 25, 2024, 08:18:58 pm Mainly so that at least someone still checks whether i386-win32 of 3.3.1 is working correctly I build a snapshot several times a week. ---------------------------------------------------------------------- Bart · 2024-06-25 21:59 On Windows I mainly use 32-bit (because the compiler is natively 32 bit). I only cross-compile to win64 if I see an advantage (or to check it compiles at all). I maybe just too lazy to rebuild Lazarus to 64-bit and build all by default to 64-bit. My hardware surely should not be a  problem. Bart ---------------------------------------------------------------------- Scoops · 2024-06-26 05:26 I only install 32 bit for now, in the readme file for 64bit windows download page its written. The Lazarus team recommends to use the 32bit Version of Lazarus, even for working on 64bit platforms, or for generating 64 bit applications. Is this advice still recommended or is it outdated ? ---------------------------------------------------------------------- Martin_fr · 2024-06-26 05:37 Quote from: Scoops on June 26, 2024, 07:26:54 amI only install 32 bit for now, in the readme file for 64bit windows download page its written. The Lazarus team recommends to use the 32bit Version of Lazarus, even for working on 64bit platforms, or for generating 64 bit applications. Is this advice still recommended or is it outdated ? https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2064% 20bits/Lazarus%203.4/ Where is that written? I would say it is outdated. Especially since the 32bit IDE version can debug 64bit apps only with gdb, but not with FpDebug. While the 64bit IDE can debug both bitnesses (with FpDebug). ---------------------------------------------------------------------- Martin_fr · 2024-06-26 05:40 I found it. https://sourceforge.net/projects/lazarus/files/Lazarus%20W indows%2064%20bits/ It is outdated. That was SEH related. Only fpc 2.x. ---------------------------------------------------------------------- Thaddy · 2024-06-26 06:35 And everybody still adheres to it since it still shows up everywhere without reason. I have been cross compiling from 64 to 32 for many years against all advice to do it the other way around. ---------------------------------------------------------------------- Thaddy · 2024-06-26 10:07 To everybody: let's fix this. It does not need code (well, fpcupdeluxe needs a warning to remove), just a couple of doc maintainers. ---------------------------------------------------------------------- marcov · 2024-06-26 11:02 (FPC still has an issue afaik, when 64-bit to 32-bit cross-compilation on x86 doesn't yield the same results because the constants in the compiler are rounded differently (64 vs 80-bit I assume)) ---------------------------------------------------------------------- Thaddy · 2024-06-26 12:21 For a cross compiler that should never be an issue. Extended should end up as 80 bits. ---------------------------------------------------------------------- marcov · 2024-06-26 12:35 Quote from: Thaddy on June 26, 2024, 02:21:33 pmFor a cross compiler that should never be an issue. Extended should end up as 80 bits. WIndows 64-bit doesn't have extended. So a 80-bit soft float need to be developed and valdiated. ---------------------------------------------------------------------- Thaddy · 2024-06-26 13:03 Which is perfecrly possible with softfloat.... and that is supported. It is also possible with some Florian specific tricks on x86_86-win64.(this is hardly documented, but works) It is developed. ---------------------------------------------------------------------- Martin_fr · 2024-06-26 17:43 Quote from: marcov on June 26, 2024, 01:02:34 pm(FPC still has an issue afaik, when 64-bit to 32-bit cross-compilation on x86 doesn't yield the same results because the constants in the compiler are rounded differently (64 vs 80-bit I assume)) Maybe, but the add on on the lazarus download side, actually is a 32 bit ppc, marketed as cross compiler from 64 to 32 bit. ---------------------------------------------------------------------- madref · 2024-06-26 18:38 I don't have a choice. I am on a Mac... so 64 it is ---------------------------------------------------------------------- Mr.Madguy · 2024-06-26 19:06 Both. High level languages like Pascal or C++ can produce fully 32bit<->64bit portable code, if some simple rules are followed. It's not ASM. I usually create both 32bit and 64bit building configurations right when I create new project and then compile and test them both. It's actually good idea, because some memory access issues don't show up on one bitness, but do on other. For example 32bit code can work properly, but 64bit one wouldn't. ---------------------------------------------------------------------- VisualLab · 2024-06-27 12:17 Quote from: 440bx on June 25, 2024, 03:20:50 pmQuote from: VisualLab on June 25, 2024, 02:36:24 pmIs your question only about developing Windows/Linux on x86/AMD64? Or maybe it also covers 32-bit ARM microcontrollers (e.g. RPi Pico)? The question is meant to cover CPUs and O/Ss that support both bitnesses, e.g, on Windows it is possible (given the right O/S version) to run either a 32 bit program or a 64 bit program.   Since both options are available, I wanted to know if programmers had a preference as to which version to develop first given those possibilities. On my home computer (typical PC) running Winows 10 64-bit, I use Lazarus 64-bit. On 2 small computers for experiments I use: Up Squared (Intel Celeron, 4 GB RAM) - Windows 10 64-bit and Linux Kubuntu 23.04 64-bit are installed - Lazarus 64-bit is installed in both OSes,on Raspberry Pi 3B - Raspberry Pi OS Bullseye 32-bit - Lazarus 32-bit are installed. On Raspberry Pi 3B I tried to use Raspberry Pi OS Bookworm 64-bit, but the OS is slow. ---------------------------------------------------------------------- PascalDragon · 2024-06-27 19:24 Quote from: Thaddy on June 26, 2024, 03:03:00 pmWhich is perfecrly possible with softfloat.... and that is supported. It is also possible with some Florian specific tricks on x86_86-win64.(this is hardly documented, but works) It is developed. Softfloat is still missing a few basic math routines like exp or ld that are necessary for complete coverage and thus consistent compilation from non-Extended targets to those that have Extended. Also the compiler currently does not support softfloat inside itself correctly, so it wouldn't work either currently. ---------------------------------------------------------------------- BrunoK · 2024-06-28 10:35 Quote from: PascalDragon on June 27, 2024, 09:24:15 pmQuote from: Thaddy on June 26, 2024, 03:03:00 pmWhich is perfecrly possible with softfloat.... and that is supported. It is also possible with some Florian specific tricks on x86_86-win64.(this is hardly documented, but works) It is developed. Softfloat is still missing a few basic math routines like exp or ld that are necessary for complete coverage and thus consistent compilation from non-Extended targets to those that have Extended. Also the compiler currently does not support softfloat inside itself correctly, so it wouldn't work either currently. Even if it existed for the x86_64, softfloat for extended would probably be much slower than FPU. As far as I know, i386 using the FPU for the Currency type doesn't overflow registers when the result of the multiplication is wihin the Currency domain but x86_64 gives wrong results when Currency*Currency overflows 64 bit during the Gaussian division by 10'000. The fact that x86_64 does not use the FPU in windows implies that mathematics for which the Extended FPU was created cannot be done with FPC x86_64. Maybe that's the type of math marcov mentionned.  See https://en.wikipedia.org/wiki/IEEE_754#Design_rationale ---------------------------------------------------------------------- Thaddy · 2024-06-28 10:42 Of course it is slower, but it is being worked on and the compiler can not even be compiled with softfloat disabled. PascalDragon's answer was therefor a surpise to me. BTW for historical reasons: TP already supported softfloat, as did TB, Bob Zale wrote that..for both. (and you can always compile with extended enabled hardware for Windows64, although that is a bit of a trick and not officially supported) It is basically only win64 that is affected because of the abi. But there are more platforms, just mentioned win64. It will always be slower because it is an emulation, so that part of your argument makes no sense. ---------------------------------------------------------------------- BrunoK · 2024-06-28 10:53 Quote from: Thaddy on June 28, 2024, 12:42:32 pm(and you can always compile with extended enabled hardware for Windows64, although that is a bit of a trick and not officially supported) How ? I would like to test if it solves the bad out of domain errors for Currency's during multiplication. ---------------------------------------------------------------------- avra · 2024-06-28 11:29 Quote from: PascalDragon on June 27, 2024, 09:24:15 pmQuote from: Thaddy on June 26, 2024, 03:03:00 pmWhich is perfecrly possible with softfloat.... and that is supported. It is also possible with some Florian specific tricks on x86_86-win64.(this is hardly documented, but works) It is developed. Softfloat is still missing a few basic math routines like exp or ld that are necessary for complete coverage and thus consistent compilation from non-Extended targets to those that have Extended. Also the compiler currently does not support softfloat inside itself correctly, so it wouldn't work either currently. Long time ago I have done exp() and ldexp() in my fast fix64 (s31.32 fixed point library) implementation for AvrCo embedded pascal. Easy calculations but I can share code if that could help. Even had an idea to adapt fix64 for FreePascal and basic math worked but did not have time yet to proceed further. ---------------------------------------------------------------------- Thaddy · 2024-06-28 11:49 Quote from: BrunoK on June 28, 2024, 12:53:08 pmQuote from: Thaddy on June 28, 2024, 12:42:32 pm(and you can always compile with extended enabled hardware for Windows64, although that is a bit of a trick and not officially supported) How ? I would like to test if it solves the bad out of domain errors for Currency's during multiplication. the exact instructions are on the fpc-devel mailing list archives. It is about 5-6 years old and the instructions are from Florian himself.. Warning: the compiler is then not  Windows ABI standards compliant so it may cause many other problems. It is just for number crunching maniacs that need 80 bit precision instead of 64 for extended on win64. I do not use it any longer but I did try it and it works. Just in case: you need to know how to build from source and there is no support whatever for it. So not even ask for support. It can be done, but if it is wise is another matter. (there is not a release of that anywhere, not even a preview, just build instructions.) And no, it won't solve your currency problem, although I would like to see where it errors for you because the currency type is a well defined standard to which fpc (and delphi) complies. Otherwise I would have to give at least 25 years of my pension plan back.. I suppose you never heared of banker's rounding? That can explain it. the difference between plain floating point operations and currency operations can be quite substantial but should even out eventually. Both types of calculations are inaccurate.. ---------------------------------------------------------------------- dbannon · 2024-06-28 12:37 On my 6 year old linux 64bit laptop, of course I develop 64 bit first. Later I cross compile to Linux 32bit, Windows 32 and 64, Arm 32 and 64 and then test each (except Win32) on a real platform.  My Windows package has both 32 and 64 bit binaries so I cannot tell who downloads what but not had a win32 specific complaint yet ! In Windows, I have an only occasionally used 64 bit fpc/lazarus install, have never needed 32bit windows development platform, I guess ignorance is bliss ! Mind you, I'd have a pink fit if my app used even a significant part of 2G ram, its intended to run in the background so minimizing memory consumption is important to me. Davo ---------------------------------------------------------------------- Thaddy · 2024-06-28 12:51 Davo, remember writing TSR's? ---------------------------------------------------------------------- BrunoK · 2024-06-28 14:50 Quote from: Thaddy on June 28, 2024, 01:49:27 pmQuote from: BrunoK on June 28, 2024, 12:53:08 pmQuote from: Thaddy on June 28, 2024, 12:42:32 pm(and you can always compile with extended enabled hardware for Windows64, although that is a bit of a trick and not officially supported) How ? I would like to test if it solves the bad out of domain errors for Currency's during multiplication. [/quote} Quotethe exact instructions are on the fpc-devel mailing list archives. It is about 5-6 years old and the instructions are from Florian himself..Never found them. QuoteAnd no, it won't solve your currency problem, although I would like to see where it errors for you because the currency type is a well defined standard to which fpc (and delphi) complies.On Windows, the code below does not give the same results  on i386 and x86_64. 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 program Project1;uses  Math;var  vSqrRootDbl: double;  vCur, vCurRes: currency;begin  vSqrRootDbl := Sqrt(High(Currency));  vCur := Trunc(vSqrRootDbl); // vCur^2 result is in Currency domain !  vCurRes := vCur * vCur;     // but vCur*vCur is wrong due to gaussian division                              // overflow for the divide by 10000. This works on                              // I386 platform because of  the use of the FPU.  WriteLn(High(Currency), ' ', vSqrRootDbl, ' ', vCur, ' vCur * vCur=', vCurRes );  if Trunc(vSqrRootDbl*vSqrRootDbl) <= High(Currency) then    WriteLn('vSqrRootDbl*vSqrRootDbl=',Trunc(vSqrRootDbl*vSqrRootDbl),' is <= High(Currency)', High(Currency));  ReadLn;end. ---------------------------------------------------------------------- dbannon · 2024-06-28 23:51 Quote from: Thaddy on June 28, 2024, 02:51:32 pmDavo, remember writing TSR's? Indeed. I remember writing one from scratch with the help of a book on assembler. I was so pleased with it that I made a framework around it for "general use". But it used so much memory, almost useless. But to my surprise it kept popping up on the lists.  I am very glad those days are gone ! ("640K should be enough for any application .....") Davo ---------------------------------------------------------------------- PascalDragon · 2024-06-30 21:16 Quote from: BrunoK on June 28, 2024, 12:35:24 pmQuote from: PascalDragon on June 27, 2024, 09:24:15 pmQuote from: Thaddy on June 26, 2024, 03:03:00 pmWhich is perfecrly possible with softfloat.... and that is supported. It is also possible with some Florian specific tricks on x86_86-win64.(this is hardly documented, but works) It is developed. Softfloat is still missing a few basic math routines like exp or ld that are necessary for complete coverage and thus consistent compilation from non-Extended targets to those that have Extended. Also the compiler currently does not support softfloat inside itself correctly, so it wouldn't work either currently. Even if it existed for the x86_64, softfloat for extended would probably be much slower than FPU. That's not relavant, cause the choice is either accurate compilation for targets supporting Extended from targets not supporting it (which is what we desire), inaccurate compilation (which we want to avoid) and no compilation (which is the current situation). Quote from: Thaddy on June 28, 2024, 12:42:32 pmOf course it is slower, but it is being worked on and the compiler can not even be compiled with softfloat disabled. PascalDragon's answer was therefor a surpise to me. It's not that it can't be compiled, it's that constants in cross compiled code will have inaccurate values and thus essentially a cross compiled binary will behave differently from a natively compiled one which is a no-go. Quote from: Thaddy on June 28, 2024, 12:42:32 pmIt is basically only win64 that is affected because of the abi. But there are more platforms, just mentioned win64. It affects all targets that don't support Extended to compile to targets supporting to Extended. The set of targets that don't support Extended is in fact larger than the set that does. Quote from: avra on June 28, 2024, 01:29:41 pmQuote from: PascalDragon on June 27, 2024, 09:24:15 pmQuote from: Thaddy on June 26, 2024, 03:03:00 pmWhich is perfecrly possible with softfloat.... and that is supported. It is also possible with some Florian specific tricks on x86_86-win64.(this is hardly documented, but works) It is developed. Softfloat is still missing a few basic math routines like exp or ld that are necessary for complete coverage and thus consistent compilation from non-Extended targets to those that have Extended. Also the compiler currently does not support softfloat inside itself correctly, so it wouldn't work either currently. Long time ago I have done exp() and ldexp() in my fast fix64 (s31.32 fixed point library) implementation for AvrCo embedded pascal. Easy calculations but I can share code if that could help. Even had an idea to adapt fix64 for FreePascal and basic math worked but did not have time yet to proceed further. 64-bit fixed point does not help. We need 80-bit floating point support routines.