Avoid automatic file saving when starting program lazarus / 11-Options ---------------------------------------------------------------------- GLR · 2025-07-01 13:37 Hello! When I run the program from the IDE, all changed source files are saved automatically. How can I avoid this? Often I have to change back to an earlier version of the source. I did not find an IDE setting for this need. GLR ---------------------------------------------------------------------- Thaddy · 2025-07-01 13:45 The files are always compiled from disk, not memory. On Windows ctrl-z may help, or repeated ctrl-z's. So small changes may be corrected. I did not test it on Linux, because there I use a different editor. (Geany) but that does the same. Also ctrl-z. But frankly, I do not know the exact undo limit on both platforms. This works, though, as long as you do not close the ide. The undo stack IS in memory ( or swap) and won't survive restarts. ---------------------------------------------------------------------- GLR · 2025-07-01 15:15 Thank you for the clarification. I'm accustomed to another behavior from Delphi (no automatical saving; question to save yes/no before closing); if you have worked with their IDE for decades, it becomes a different deeply rooted routine. I have to get used to Ctrl+z. (Nevertheless it would be no bad addition to the Laz options to mirror the Delphi IDE behavior.) ---------------------------------------------------------------------- Thaddy · 2025-07-01 15:36 Delphi works EXACTLY the same on large projects, also compiles from disk. Tested 12.1 ---------------------------------------------------------------------- GLR · 2025-07-01 15:47 I have Delphi 2010. Under IDE options there are two options for "Auto save": - Editor files - Project desktop If the first is not activated, the files are not saved automatically when running the program. When the IDE ist closed, the question "Save Yes/No" is shown. If it is activated, the behavior is like Lazarus. ---------------------------------------------------------------------- Paolo · 2025-07-01 20:49 I agree, the two more annoying thing of IDE coming from delphi: - the one you described - the fact that the IDE cannot be opened without open a project. ---------------------------------------------------------------------- JuhaManninen · 2025-07-01 21:51 Quote from: GLR on July 01, 2025, 05:15:22 pm(Nevertheless it would be no bad addition to the Laz options to mirror the Delphi IDE behavior.) It cannot be mirrored because Lazarus uses an external compiler FPC and source files must be saved for it. Delphi has an integrated compiler and can do it in memory without saving. After a while this is a non-issue. It is only good that files get saved sometimes in case power goes out or something. And yes, Undo works also after saving. Quote- the fact that the IDE cannot be opened without open a project. Also a non-issue after some getting used to. You can keep a dummy project open and pretend there is no project. ---------------------------------------------------------------------- Thaddy · 2025-07-02 05:48 - Delphi does not have an integrated compiler for all platforms it supports. It does for win32 only afaik. - The FreePascal textmode IDE has an integrated compiler, so it is not completely unlikely this can be done for Lazarus. Even better, the Textmode IDE internally supports the platform compiler, so 64 bits 32 bits Unix and Windows depending on build. The compiler interface for the textmode ide is known, so that can possibly be re-used. (I can't imagine this has not been tried, although I agree with your remark that its usefulness is debatable) ---------------------------------------------------------------------- JuhaManninen · 2025-07-02 06:23 Quote from: Thaddy on July 02, 2025, 07:48:51 am- The FreePascal textmode IDE has an integrated compiler, so it is not completely unlikely this can be done for Lazarus. How is it done? The compiler must then be in a form of a library with an API and linked to the IDE. Actually it is a cool idea, I have thought about it in the past. Hard drives are fast so the speed difference is small but still exists. Before stating to compile, Lazarus checks some potentially changed files on disk. I don't remember what exactly it checks. Anyway that is a noticeable delay in a slow machine. It would be nice to be close to Delphi's compilation speed which is phenomenal. ---------------------------------------------------------------------- Thaddy · 2025-07-02 07:16 Yes, you can see that when you build it: the compiler is re-compiled and statically linked in fp. fp does not need a ppcxxxx available nor does it need shared libraries. This is the case on all the main platforms. See the make file for fp. Ask the core fpc developers for the ins and outs. I don't know if it is sufficiently documented,, I just know. (btw compile speed in Delphi is only superfast for win32. The llvm based compilers speed can compare to fpc already.) ---------------------------------------------------------------------- Nicole · 2025-07-02 08:13 This is indeed in many situations not wanted. I do this: I copy the whole folder, which contains my project with all its stuff including databases. Then I work on. In serval cases I closed Lazarus, renamed the backup copy back to the project-name, re-open Lazarus and worked on with my older version. From time to time, I delete the stuff not needed any more. All those tools and repositories are somehow tricky. I keep coming back to just "hold and may be use it later" for intraday work. ---------------------------------------------------------------------- Martin_fr · 2025-07-02 08:44 It's a known issue ... And probably an unsolvable issue (at least for quite some time to come). Currently the compiler can only compile the files if they are saved. And that wont change anytime soon (nor far). Files could be saved to an alternative location for compiling. However, that would mean the IDE would have to change any path specified in config or source. As that can be arbitrary complex, this would introduce a massive chance of getting errors. So that is not a good idea. Files could be saved, and then restored. That would work. Well as long as there are no file-monitoring tools watching, because they would be triggered. But for now, nothing of that sort exists. The previous version will be in the backup folder (if you haven't disabled backup saving). So it isn't lost. But for quick trial and error tests, and keeping your project as it is... There is no simple solution. Personally, I put projects under revision management (for me git, but svn or others work too). Then I can always revert them to the last commited revision. Of course, it adds the need for an extra tool... ---------------------------------------------------------------------- n7800 · 2025-07-02 08:47 Quote from: Thaddy on July 02, 2025, 09:16:19 amYes, you can see that when you build it: the compiler is re-compiled and statically linked in fp. fp does not need a ppcxxxx available nor does it need shared libraries. This is the case on all the main platforms. See the make file for fp. I didn't know that, interesting idea of ​​"integrated compiler"! Although, I don't know how relevant it is. I always waited for the implementation of the ability to transfer files via pipes, which should be more "portable". I wonder if it is also possible to "integrate" the compiler into Lazarus, as a package? ---------------------------------------------------------------------- Martin_fr · 2025-07-02 08:59 Quote from: n7800 on July 02, 2025, 10:47:45 amI wonder if it is also possible to "integrate" the compiler into Lazarus, as a package? In theory.... IIRC it was discussed long ago, but back then not considered for stability. (and IIRC then it also did not always release all memory / but I may remember that wrong). Calling an external tool avoids such issues. (If indeed they existed) And if you want cross compiling you would need to add all the targets. Which by the way wont work for compiling 32bit target on a 64bit host in a 64bit IDE (because there is no such cross compiler / the Lazarus addon is a disguised 32bit ppc, but that can't be linked into a 64bit IDE). ---------------------------------------------------------------------- Thaddy · 2025-07-02 09:05 I explained the latter limitation. But that is not what the majority of users do: they compile for one platform only. But as I wrote: it is possible. ---------------------------------------------------------------------- 440bx · 2025-07-02 09:06 I think it would be very nice to have a service that compiles. That way, the compiler doesn't need to be loaded for every compile.  The compiler could be "shoehorned" into being suitable as a service but, it would be much nicer if the compiler's code allowed for it to be installed as a service. That way, at least in theory, it would be possible to do multiple compilations in parallel.  For instance, if the project has multiple release modes, then "Run->Compile many modes" could conceivably use one service per mode.  One way to put those cores to good use. ---------------------------------------------------------------------- Thaddy · 2025-07-02 09:10 Quote from: n7800 on July 02, 2025, 10:47:45 amI wonder if it is also possible to "integrate" the compiler into Lazarus, as a package? Theoretically: yes, based on the same information I provided. About Delphi: the 32 bit compiler comes as a dll for the ide and dccXXX for the commandline. Both use the same dll (has not always been the case, though). All other platforms work through cross-compilers, just like Lazarus does now, and suffer therefor from the same limitations. The Delphi IDE itself is still firmly win32 windows although there is "being worked on". If you accept the same limitations Delphi has but minus the win32 tie(after all FPC does not suffer from that), there is otherwise no reason why it can't be done. It can be done and fp is proof. ---------------------------------------------------------------------- RayoGlauco · 2025-07-02 09:26 Quote from: 440bx on July 02, 2025, 11:06:30 amit would be much nicer if the compiler's code allowed for it to be installed as a service. I think it could be an option. I wouldn't want to be forced to install the debugger as a service. In my case, I use Lazarus on computers where I can't install software, and I need Lazarus to remain portable. ---------------------------------------------------------------------- Thaddy · 2025-07-02 09:28 I think that is a bad idea because services/daemons need controllers for all input/output and that would possibly be quite heavy. And defeats the purpose of a service/daemon. Possibly only feasable for win32 and older windows versions that do not rely on code signing for services or manual rights management. (What you already can do is run ppc as a cgi on a local or remote webserver) I think it is a good idea to split-up the thread. ---------------------------------------------------------------------- 440bx · 2025-07-02 09:51 Quote from: Thaddy on July 02, 2025, 11:28:22 amI think that is a bad idea because services/daemons need controllers for all input/output and that would possibly be quite heavy. Not if it's implemented correctly.  It would be extremely efficient, much, much faster than creating a new process for every compilation.  The communication with the services can be done using memory mapped files... everything in memory = very, very fast. ---------------------------------------------------------------------- Thaddy · 2025-07-02 10:35 Quote from: 440bx on July 02, 2025, 11:51:17 amThe communication with the services can be done using memory mapped files... everything in memory = very, very fast. Linux won't allow that and win64 won't allow that too afaik. Sometimes you are too win32 centric, although you have a huge bag of knowledge. The case is ownership of memory and execution ring. In modern OS's the mapped memory is isolated and you can not use it for communication. ---------------------------------------------------------------------- 440bx · 2025-07-02 11:15 I have no idea what can and cannot be done in Linux, therefore I'm staying away from that one. In Windows, there is no problem at all using memory mapped file in services.  No problem using them for communication with other processes. ---------------------------------------------------------------------- Thaddy · 2025-07-02 11:39 Unless I am mistaken, your development is still firmly rooted in Win32, not Win64 nor e.g. Linux? And that is a niche, nowadays. (And rather permissive) My point is that memory mapping can't be shared without explicit permissions in modern OS's of which 32 bit windows is not one. There is a reason for that: isolation. ---------------------------------------------------------------------- 440bx · 2025-07-02 11:43 I've left Delphi 2 behind.   I develop everything on Win64 but, whenever possible, I still make sure the code runs in 32 bit if needed. ---------------------------------------------------------------------- Thaddy · 2025-07-02 11:45 Fair enough. Then share code for a win64 service that shares memory with a user space app and does not need any raised permissions? Because that is what you are implying. If you can, I stand corrected, but you likely can't. And if you can't most others can't either....I will give you that.. Ah, I see, if the service defines that the user group can access defined shared memory, then the user can access that memory without elevation. (But the service needs to adapt SID and DACL for that so the memory doesn't have SYSTEM only.) BUT I would use pipes or sockets instead. So it is possible, but you may introduce a security violation. Although I found a C++ example, I won't use such code. That said: according to MS it does not violate its best practice. ---------------------------------------------------------------------- JuhaManninen · 2025-07-02 14:12 Quote from: 440bx on July 02, 2025, 11:06:30 amThat way, at least in theory, it would be possible to do multiple compilations in parallel.  For instance, if the project has multiple release modes, then "Run->Compile many modes" could conceivably use one service per mode.  One way to put those cores to good use. I think that starting parallel processes is more realistic. Actually it would be very realistic without this FPC feature/bug.   https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40986 Without the bug the "Compile many Modes ..." menu item in Lazarus could take care of it, instead of starting many LazBuild instances. ---------------------------------------------------------------------- Thaddy · 2025-07-02 14:23 Let's split the discussion in two: 1. avoiding saves 2. compiler integration like fp (the textmode ide) has into Lazarus. They are frankly only remotely related. ---------------------------------------------------------------------- JuhaManninen · 2025-07-02 15:28 Quote from: Thaddy on July 02, 2025, 04:23:55 pmLet's split the discussion in two: 1. avoiding saves 2. compiler integration like fp (the textmode ide) has into Lazarus. ... and 3. parallel compilation. ---------------------------------------------------------------------- Thaddy · 2025-07-02 15:52 fpc packages can already be compiled over multiple threads. Just in case you forgot... ---------------------------------------------------------------------- PascalDragon · 2025-07-03 19:31 Quote from: JuhaManninen on July 02, 2025, 08:23:46 amQuote from: Thaddy on July 02, 2025, 07:48:51 am- The FreePascal textmode IDE has an integrated compiler, so it is not completely unlikely this can be done for Lazarus. How is it done? The compiler must then be in a form of a library with an API and linked to the IDE. The text mode IDE directly uses the units of the compiler. And there isn't much API besides "compile file xyz" and some hooks for feedback. ---------------------------------------------------------------------- Martin_fr · 2025-07-03 20:18 Quote from: PascalDragon on July 03, 2025, 09:31:29 pmQuote from: JuhaManninen on July 02, 2025, 08:23:46 amQuote from: Thaddy on July 02, 2025, 07:48:51 am- The FreePascal textmode IDE has an integrated compiler, so it is not completely unlikely this can be done for Lazarus. How is it done? The compiler must then be in a form of a library with an API and linked to the IDE. The text mode IDE directly uses the units of the compiler. And there isn't much API besides "compile file xyz" and some hooks for feedback. Just for clarification... (for myself too). - If the compiler is "used" (via "Uses ...") then yes it can be called in memory. - An entrypoint like "compile file xyz" would still want a file? - Well, ok, it probably be possible to skip the loader, and say "compile_source(ASource_as_pchar_or_string)" (or some other format). But, when that source contains a "uses" then that used file needs to be compiled. The compiler would want to load that file from disk. To prevent that, there would need to be a hook to inject a custom file loader? So then any file can be "loaded" from memory (or where ever). ---------------------------------------------------------------------- PascalDragon · 2025-07-03 21:16 Quote from: Martin_fr on July 03, 2025, 10:18:22 pm- An entrypoint like "compile file xyz" would still want a file? The entry point takes a command line string containing the options and the involved source file. Quote from: Martin_fr on July 03, 2025, 10:18:22 pm- Well, ok, it probably be possible to skip the loader, and say "compile_source(ASource_as_pchar_or_string)" (or some other format). But, when that source contains a "uses" then that used file needs to be compiled. The compiler would want to load that file from disk. To prevent that, there would need to be a hook to inject a custom file loader? So then any file can be "loaded" from memory (or where ever). Looking at the compiler hooks one might even be able to cook something up using a virtual file system or something... 🤔 ---------------------------------------------------------------------- n7800 · 2025-07-03 21:51 For example, compile a project directly from a ZIP archive or any repository commit? )) ---------------------------------------------------------------------- Thaddy · 2025-07-04 15:04 Quote from: n7800 on July 03, 2025, 11:51:19 pmFor example, compile a project directly from a ZIP archive or any repository commit? )) Do you really have no clue: Streams. Compression streams and decompression streams are streams. ---------------------------------------------------------------------- n7800 · 2025-07-04 22:15 Quote from: Thaddy on July 04, 2025, 05:04:31 pmQuote from: n7800 on July 03, 2025, 11:51:19 pmFor example, compile a project directly from a ZIP archive or any repository commit? )) Do you really have no clue: Streams. Compression streams and decompression streams are streams. What do you mean? The file just needs to be unpacked into memory and passed to the compiler. Files from Git can also be obtained without using the file system (by reading the output stream of the process git show :).