Forum > Linux

Build lazarus and fpc in linux is not support multi thread.

<< < (2/3) > >>

PascalDragon:

--- Quote from: gasensor on May 15, 2022, 05:32:37 am ---But, as a Linux user, use"-j" is a habitual operation to build a large software.
--- End quote ---

And the way FPC builds programs is simply not compatible with -j. Where it works for example is while the RTL is compiled on Linux cause FPC is invoked for each unit separately. If you cross compile from Linux to Windows it wouldn't provide any benefit, because a build unit is used there (and those fewer compiler invocations are done). Similar for building the packages: fpmake is what does the real work, the make related part is essentially only a wrapper around fpmake. And Lazarus in contrast uses lazbuild which also deals with parallelism (though I don't know if it needs to be enabled explicitly using some parameter or if it does parallelism by itself).

And again: one can't query the -j parameter from within a Makefile, so we can't hook up to that parameter.

marcov:

--- Quote from: gasensor on May 15, 2022, 05:32:37 am ---But, as a Linux user, use"-j" is a habitual operation to build a large software.

--- End quote ---

It is a habitual system for C that doesn't have any form of automatically finding files, requiring every file to be listed on the compiler commandline, or make to handle its dependencies.

FPC, if you ever used it on the commandline, recursively finds files itself. This means that there is only one FPC invocation per package. IOW make -j  (and -T) is only used to parallel compile whole directories rather than on an individual file level.

The makefiles also only contain dependency information on a whole package/directory level.

gasensor:
OK, I see.

Maybe, using ".NOTPARALLEL" is a good idea. I find it in make's manual 5.4 line4.
https://www.gnu.org/software/make/manual/html_node/Parallel.html#Parallel

And... PascalDragon,

makefile can query the -j parameter just read var "MAKEFLAGS". like this:

--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---all:        @echo $(MAKEFLAGS)
It retruns:
-j2 --jobserver-auth=3,4

Hope that helps.

MarkMLl:

--- Quote from: gasensor on May 15, 2022, 05:32:37 am ---But, as a Linux user, use"-j" is a habitual operation to build a large software.

--- End quote ---

As a Linux user, you should know better than to try to build a large software system other than by hewing closely to the maintainers' documentation.

This is something that I raised on the ML ten years or more ago, and was content then with much the same answers as you are being given now: it might work on a package-level basis, but not at the level of individual object files.

In practice, the real bottleneck is at the linkage stage, and I'm not aware of a linker that can benefit heavily from multiple CPUs/cores.

Of course, if you contributed any patches which improved build efficiency the core developers would probably look favourably on them...

MarkMLl

PascalDragon:

--- Quote from: MarkMLl on May 16, 2022, 04:32:59 pm ---In practice, the real bottleneck is at the linkage stage, and I'm not aware of a linker that can benefit heavily from multiple CPUs/cores.
--- End quote ---

Microsoft's MSVC linker makes use of multithreading (one can see that in TaskManager when compiling a large C++ program) and the improvement with that is definitely noticeable.

In general a linker could parallelize the reading of the object files. Most everything else is probably too serialized...


--- Quote from: gasensor on May 16, 2022, 04:32:37 pm ---And... PascalDragon,

makefile can query the -j parameter just read var "MAKEFLAGS". like this:

--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---all:        @echo $(MAKEFLAGS)
It retruns:
-j2 --jobserver-auth=3,4

--- End quote ---

The problem is not only reading it, but also handling it, because make handles that parallelism by itself. Hooking that up to the parallelism provided by fpmake is the problem.

TL;DR: the current way works. It's documented. We don't intend to change it.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version