IncrediBuild joint compilation

Posted by mourisj on Wed, 26 Jan 2022 02:01:35 +0100

01 basic information

Official website: https://www.incredibuild.com

To use IncrediBuild, you must have a license. You can apply for a trial version of the license for free.
Can arrive https://www.incredibuild.com/free-trial-2 To apply for a 30 day free license, you need a mobile phone number and email. After application, you can download the installation package. You can also directly use the incredibuild in the visual studio 2019 installation package.

01.01 installation method

01.01.01 installation using a separate installation package

As of 20210624, the latest version is 9.50(incredibuild9_50.exe). 

choice Custom Clients in[ Incredibuild Agent] And server[ IncrediBuild coordinator]. 

Incredibuild Agent is a client of joint compilation. It can participate in initiating joint compilation requests and contribute cpu computing power to other joint compilation requests.

Incredibuild Coordinator is a joint compilation server. Used to manage and coordinate joint compilation.

01.01.02 install with vs installation package (recommended)

Select vs installed individual components ⇒ compiler, build tool and runtime ⇒ IncrediBuild - build acceleration. This option directly includes [Incredibuild Agent] and [IncrediBuild coordinator].

Note that IncrediBuidl is installed with vs and needs to be uninstalled with vs.
When using vs single component installation, it is recommended to install English language pack.


Effect after installation:

02 configuration information

For detailed configuration information, please refer to Official documents:
https://incredibuild.atlassian.net/wiki/spaces/IUM/pages/11239495/Make+and+Other+Build+Tools+Samples

02.01 import license file

Select the [Coordinator Settings] menu and select the [License] list in the [Coordinator Settings] window. Click the [Load License File] button to import your own License file.

When the license file is not needed, click the [Unload License] button to unload the license file.

02.02 client and server configuration

Agent settings:
[Agent Settings] ==> [Newwork] ==> [Coordinator] ==> [Coordinator Location]
Set the Computer to the fixed IP address of [Coordinator] or the host name of [Coordinator], that is, specify the IP address or host name of the server.
Port port number: 31104 by default
Click the [Test] button to Test connectivity

Note: [initiator] = = > [general] = = > [enable standalone mode] should not be checked during joint compilation.

Coordinator side settings

The default port number is 31104.

As long as the License is set on the server.
[Coordinator Settings] set the License, mainly to import the License file applied to. Other items can use the default value.

03 compilation settings

03. 01 using the [IncrediBuild] menu in vs2019

Start vs2019 with administrator privileges and select [Extension] = = > [incredibuild] = = > [build solution] to compile.

03.02 using the command line

For example, compile with cygwin64:

::Official website references
:: https://incredibuild.atlassian.net/wiki/spaces/IUM/pages/11239495/Make+and+Other+Build+Tools+Samples
:: IncrediBuild References in the installation package
:: vs of nmake command
:: C:\Program Files (x86)\IncrediBuild\Samples\Make And Build Tools\Nmake
:: make command
:: C:\Program Files (x86)\IncrediBuild\Samples\Make And Build Tools\Make
set cygwindir=D:\cygwin64
set PATH=%cygwindir%\opt\lo\bin;%cygwindir%\bin;%cygwindir%\sbin;%cygwindir%\usr\bin;%cygwindir%\usr\sbin;%cygwindir%\usr\local\bin;%PATH%;
BuildConsole /command="make -rs -f Makefile build" /openmonitor /title="MakeXXXX"

03.03 setting agent attribute in Coordinator Monitor

You can set properties in the right-click menu above each agent, such as establishing a group (joint compilation in the same group), stopping subscription, canceling subscription, enabling, disabling, granting administrator permissions, etc.

04 some questions

reference resources: Accelerating NDK compilation with IncrediBuild

04.01 CompareStringA

IncrediBuild : Error: Attempt to call unsupported import function CompareStringA

Keep the status quo after removing -j200; After removing SHELL=cmd, there is no such mistake.
It is suspected that this is IB's own BUG... If the / COMMAND parameter passed in is marked with =, this problem will occur, which is mind quenching. It was verified as like as two peas in the end, because the introduction of NDK-DEBUG=1 is exactly the same.

04.02 job server

make: INTERNAL: Exiting with 64 jobserver tokens available; should be 1024!

Someone has encountered the same problem Make (Parallel Jobs) on Windows

I found this Danny Thorpe's blog entry that explains the problems with parallel make build on Windows. Basically what it suggests is to set the following environment variable first:
set SHELL=cmd.exe

I followed in all the way and read the general explanation, which is difficult to do... If SHELL=cmd is not set, parallel compilation cannot be performed, and if it is set, an error will be reported.

At first, I tried to find out if there were any other methods besides command-line parameters, but the official documents Choosing the Shell Very heartless:

Unlike most variables, the variable SHELL is never set from the environment.

Since you can't change the IB itself, you can only start with make - first look at the built-in make version information

D:\SDK\android-ndk-r21b\prebuilt\windows-x86_64\bin>make --version
GNU Make 4.2.1
Built for x86_64-w64-mingw32
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

OK, go to the official website to download the corresponding make 4.2.1 After decompression, run build in Developer Command Prompt for VS 2019_ w32. bat. No problem found in the replacement:

D:\SDK\android-ndk-r21b\prebuilt\windows-x86_64\bin>make --version
GNU Make 4.2.1
Built for Windows32
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Force set SHELL
After looking through the code, I found that the default shell uses sh.exe, which is directly changed to CMD Exe.

--- job.c	Sun May 22 04:22:32 2016
+++ job.c	Tue Mar  2 18:46:55 2021
@@-31,7+31,7@@
 #ifdef WINDOWS32
 #include <windows.h>
 
-const char *default_shell = "sh.exe";
+const char *default_shell = "cmd.exe";
 int no_default_sh_exe = 1;
 int batch_mode_shell = 1;
 HANDLE main_thread;

The IB incoming parameter should be - j1024, but the windows version uses semaphores, so it cannot exceed MAXIMUM_WAIT_OBJECTS is 64, which leads to the problem. Once you find the root cause, it's easy to do:

--- main.c	Tue May 31 15:17:26 2016
+++ main.c	Tue Mar  2 18:57:39 2021
@@-2058,6+2058,7@@
      submakes it's the token they were given by their parent.  For the top
      make, we just subtract one from the number the user wants.  */
 
+  if (job_slots >= MAXIMUM_WAIT_OBJECTS) job_slots = MAXIMUM_WAIT_OBJECTS - 1;
   if (job_slots > 1 && jobserver_setup (job_slots - 1))
     {
       /* Fill in the jobserver_auth for our children.  */

Topics: C++ Visual Studio