Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What means the "Using shared compilation with compiler from directory .." message and what's shared compilation?

Tags:

c#

.net

msbuild

Since the upgrade from VS2010 to VS2015 we see the following message on the compilation output that wasn't present before:

"using shared compilation with compiler from directory"

What does it mean and what is the Shared Compilation concept?

Googling for it I found almost nothing.

like image 668
Ignacio Soler Garcia Avatar asked Dec 01 '17 09:12

Ignacio Soler Garcia


People also ask

How do I compile a shared library with GCC?

Now let’s compile our library with GCC: The command above compiles shared.cpp to a shared library ( -shared) with position independent code ( -fPIC ). The compiler output ( -o) is written to libshared.so . Let’s take a quick look external symbols of our library. We can use “nm” for this purpose:

What is a shared library?

In this article I focus on shared libraries and give a practical overview on how to create and use shared libraries with various compilers on various operating systems, with the goal of portable source code and a unified build process. “A shared library or shared object is a file that is shared by executable files and further shared objects files.”

Where is the compiler output (-O) written?

The compiler output ( -o) is written to libshared.so . Let’s take a quick look external symbols of our library. We can use “nm” for this purpose:

What is the Linux equivalent of a shared library?

A shared library on Linux is called “ dynamically linked shared object”, and has the file extension .so. The windows equivalent is the “ dynamic link library” usually with file extension .dll. 1 At first we create and use a minimal shared library on Linux with GCC.


1 Answers

That is not very clear from documentation I read, but there is a clue in the source code documentation:

/// If this property is true then the task will take every C# or VB
/// compilation which is queued by MSBuild and send it to the
/// VBCSCompiler server instance, starting a new instance if necessary.
/// If false, we will use the values from ToolPath/Exe.

It seems that reusing the same service minimizes build time since the compiler can use past build intermediates and results, and compilation results from other related projects.

Some more clues from someone on the project (Jared Parsons, Microsoft):

What's happening is the MSBuild property UseSharedCompilation is being set to false. As such we are not using the compiler server and you're paying the JIT cost for CSC on every build. That is the reason for the slow down.

like image 143
Patrick Hofman Avatar answered Sep 26 '22 10:09

Patrick Hofman