Kompilacja (przyspieszamy)

From FreeCAD Documentation
Revision as of 05:45, 21 July 2023 by Kaktus (talk | contribs) (Created page with "Na przykład, aby uniknąć budowy środowisk pracy MES i Siatka:")

Informacje ogólne

FreeCAD jest dużą aplikacją, której całkowita kompilacja ze źródła może zająć od 10 minut do godziny. Zależy to głównie od wydajności Twojego procesora i liczby rdzeni, które są wykorzystywane w procesie kompilacji. Oto kilka wskazówek, jak przyspieszyć ten proces i skrócić czas kompilacji.

CCache

Zainstaluj ccache, aby buforować kompilacje.

Ccache przyspiesza rekompilację poprzez buforowanie poprzednich kompilacji i wykrywanie, kiedy ta sama kompilacja jest wykonywana ponownie. Ccache jest wolnym oprogramowaniem, wydanym na licencji GPLv3 lub nowszej.

Wyłączanie modułów

Używając cmake do konfiguracji kompilacji, można wyłączyć kompilację niektórych środowisk roboczych, które mogą nie być potrzebne w danej chwili. Jest to przydatne, jeśli chcesz przetestować tylko kilka środowisk roboczych.

Na przykład, aby uniknąć budowy środowisk pracy MES i Siatka:

cmake -DBUILD_FEM=OFF -DBUILD_MESH=OFF ../freecad-source

Use cmake-gui, cmake-curses-gui, or cmake-qt-gui to display all the possible variables that can be edited in the configuration; using these interfaces you can easily switch on or off different workbenches.

Number of jobs in parallel

After configuring with cmake, the make program launches the actual C++ compiler to work on the source code files. You can speed up compilation by working on various files at the same time. This is achieved with the -j option of make, which denotes the number of "jobs" or compilation commands that are run simultaneously. This option is an integer number.

Run four compilation commands in parallel:

make -j4

Compile as many files in parallel as the number of CPU cores in your system. This is useful if you have many cores and want to use them all to compile the software.

make -j$(nproc)

Compile as many files in parallel as the number of CPU cores in your system, minus two. Use this so that your system is still responsive to do some other task; for example, two cores will allow you to use a browser, while the rest of the cores keep compiling the software on the background.

make -j$(nproc --ignore=2)

distcc

The distcc program can be used to perform distributed compilation of C and C++ code across several machines in a network.

Distcc should always generate the same results as a local compilation. It is free, simple to install and use, and often two or more times faster than compiling locally.

FreeCAD dev 'etrombly' has published a short explanation on how to install distcc to compile FreeCAD on a network of computers using Docker.