The following steps represent the quickest and most reliable way to build the Microsoft® Shared Source CLI implementation:
On the Microsoft® Windows® operating system:
On the FreeBSD operating system:
The SSCLI build process is designed in a modular manner. You can build all of the SSCLI or only parts of the SSCLI, however there are strict sequential dependencies between elements of the source tree. In all cases the build process requires that your environment variables be set correctly before building. See env.html for more information on correctly configuring your environment prior to building.
Note: the path and directory to the location where the Shared Source CLI is installed cannot contain spaces. Some tools that the build process depends on do not work correctly on paths containing spaces.
Elements of the Shared Source CLI implementation depend on other elements in a strict sequential order. The best way to start modifying elements of the source tree is to build the entire tree using the buildall batch file or script which will build the required dependencies in the correct order and have them placed in the path. After that it is possible to selectively rebuild specific elements of the source tree.
The SSCLI source tree has the following major elements:
In general each major element depends on the preceding element having been built and the output of the build in the path. There are more complicated dependencies within each of the major elements. The dependency order of the major elements can be determined by reading buildall.bat or the buildall script. Dependency orders within the large elements such as the CLI, C#, and base class libraries or the FX class libraries can be determined by reading the order of the files in the dirs file at the root of the relevant source tree.
You should always use the buildall.cmd or buildall script to build the entire source tree before attempting to work with separate elements. The scenarios below describe the necessary procedures for modifying and building specific portions of the SSCLI source tree.
The SSCLI build process works off of relative path location. You must change into the correct directory where the sources files or makefiles are and then execute the required command.
In the following tables if the same build commands will work for both the Microsoft Windows and FreeBSD operating systems the commands will be specified using the Windows syntax. Similarly, if both the location for source or output is the same only the path to the Windows location is specified and the path on FreeBSD should be inferred.
Available build options for the build utility are specified in buildutility.html. Builds that use make.cmd support only -c or clean option to indicate that existing object files are to be deleted.
The primary bootstrap element of the SSCLI source tree uses makefiles during the initial build rather than build.exe because the build utility and the other supporting build tools haven't been built yet. On Windows the build process uses make.cmd batch files which call nmake.exe (provided in the path by Microsoft® Visual Studio® .NET) to process the required makefiles. On the FreeBSD the build process uses BSD to process the makefiles.
The primary build bootstrap sub-elements are:
The PAL must be built before any other builds are attempted.
| Build Scenario | OS | Source Location | Build Commands | Build Output |
|---|---|---|---|---|
| Build the Platform Adaptation Layer (PAL) | Windows | %ROTOR_DIR%\pal\win32 | cd %ROTOR_DIR%\pal\win32 build [options] (If build.exe isn't built yet then you can use make.cmd) |
%TARGETCOMPLUS%\rotor_pal.dll |
| FreeBSD | %ROTOR_DIR%/pal/unix | cd ${ROTOR_DIR}/pal/unix make |
${TARGETCOMPLUS}/librotor_pal.so | |
| Build the nmake makefile utility.
The Rotor version of nmake is used only on FreeBSD because the Rotor build process on Windows assumes nmake.exe is in the path. |
FreeBSD |
${ROTOR_DIR}/tools/nmake | cd ${ROTOR_DIR}/tools/nmake make |
${TARGETCOMPLUS}/nmake |
| Build the binplace binary output manager utility | Windows | %ROTOR_DIR%\tools\binplace | cd %ROTOR_DIR%\tools\nmake make [options] The "make" command executes make.cmd |
%TARGETCOMPLUS%\binplace.exe |
| FreeBSD | cd ${ROTOR_DIR}/tools/nmake make |
${TARGETCOMPLUS}/binplace | ||
| Build the build utility | Windows | %ROTOR_DIR%\tools\build | cd %ROTOR_DIR%\tools\build make [options] The "make" command executes make.cmd |
%TARGETCOMPLUS%\build.exe |
| FreeBSD | cd ${ROTOR_DIR}/tools/build make |
${TARGETCOMPLUS}/binplace |
In the secondary bootstrap portion of the source tree it is assumed that the build tools are sufficiently complete to enable using them to build. This means that that the build directives are specified in a sources file (see buildutility.html) and not in a makefile or make.cmd file.
Sub-elements of the primary bootstrap are:
For the following tools and the PAL RT, all the primary bootstrap utilities and the PAL must be built, functional, and in the path. The build utility using sources and dirs files in the same way on both the Windows and FreeBSD operating systems.
| Build Scenario | OS | Source Location | Build Commands | Build Output |
|---|---|---|---|---|
| Build the resource compiler utility. | Windows | %ROTOR_DIR%\tools\ resourcecompiler |
cd %ROTOR_DIR%\tools\resourcecompiler build [options] |
%TARGETCOMPLUS%\ resourcecompiler.exe |
| FreeBSD | ${TARGETCOMPLUS}/ resourcecompiler |
|||
| Build the PAL RT common shared utility infrastructure. | Windows | %ROTOR_DIR%\palrt\src | cd %ROTOR_DIR%\palrt\src build [options] |
%TARGETCOMPLUS%\rotor_palrt.dll |
| FreeBSD | ${TARGETCOMPLUS}/ librotor_palrt.so |
Note: For all further build scenarios the build commands are:
cd <source_location>
build [options]
See buildutility.html for more details on the build utility options. The most common options are -c for clean build and -z to skip calculating dependencies.
After the primary and secondary bootstrap elements are built, it is possible to proceed with building the core SSCLI Shared Source CLI implementation, C# compiler, and base class libraries. This section of the build is very complex due to complicated interdependencies between the core CLI code, C#, and the base class libraries. When making changes across sub-elements of this tree, you should rebuild the entire tree starting at %ROTOR_DIR%\clr\src.
There are numerous sub elements of this tree. Some critical sub-elements are:
| Build Scenario | OS | Source Location | Build Output |
|---|---|---|---|
| Modify any CLI, C#, or base class library file and rebuild the entire tree. | All | %ROTOR_DIR%\clr\src | Most of the contents of the %TARGETCOMPLUS% directory and subdirectories are produced from this build command. |
| Build the main CLI execution engine directory: VM The .lib file produced from this step is used to link the sscoree.dll/libsscoree.so library. After successfully building the execution engine, you must relink the resulting file (cee_wks.lib) into the sscoree.dll/libsscoree.so library in order to incorporate your change. Do this by building the mscoree directory, as detailed further down in this table. Changing .asm/.s files requires either a clean-build using -c, or manual deletion of the .obj file from under wks/obj{d|df|}/rotor_x86/ The src\vm directory contains the dirs file, and src\vm\wks directory contains the sources file |
All | %ROTOR_DIR%\clr\src\vm | %ROTOR_DIR%\clr\bin\rotor_x86\ %DDKBUILDENV%\cee_wks.lib |
| Build the C# compiler and alink assembly linker. | Windows | %ROTOR_DIR%\clr\src\csharp | %TARGETCOMPLUS%\csc.exe %TARGETCOMPLUS%\cscomp.dll %TARGETCOMPLUS%\al.exe %TARGETCOMPLUS%\alink.dll |
| FreeBSD | ${TARGETCOMPLUS}/csc ${TARGETCOMPLUS}/libcscomp.so ${TARGETCOMPLUS}/al ${TARGETCOMPLUS}/libalink.so |
||
| Build the C# compiler. | Windows | %ROTOR_DIR%\clr\src\csharp\csharp | %TARGETCOMPLUS%\csc.exe %TARGETCOMPLUS%\cscomp.dll |
| FreeBSD | ${TARGETCOMPLUS}/csc ${TARGETCOMPLUS}/libcscomp.so |
||
| Build the base class libraries (BCL). Note: all of the BCL is built via one call to the C# compiler, passing all .cs files via a response file. There is no partial build of the BCL. See note below on
multistage build of mscorlib.dll. |
All | %ROTOR_DIR%\clr\src\bcl | %TARGETCOMPLUS%\mscorlib.dll %TARGETCOMPLUS%\*.nlp |
Build core CLI dynamic libraries and .lib files. These can also be
built individually in each subdirectory.
|
All | %ROTOR_DIR%\clr\src\dlls | (See individual components sources file.) |
| Build the mscoree directory. This directory
builds the dynamic library that is loaded first when the SSCLI CLI execution
engine starts up. This library is a merged combination of the mscoree.dll and mscorwks.dll/mscorsvr.dll in the Windows .NET Frameworks implementation. |
Windows | %ROTOR_DIR%\clr\src\dlls\mscoree | %TARGETCOMPLUS%\sscoree.dll |
| FreeBSD | ${TARGETCOMPLUS}/libsscoree.so | ||
| Build the C++ common code shared between many
components To incorporate changes to these libraries you should rebuild the entire tree starting at clr\src |
%ROTOR_DIR%\src\utilcode | %ROTOR_DIR%\clr\bin\ROTOR_X86\ %DDKBUILDENV%\utilcode.lib %ROTOR_DIR%\clr\bin\ROTOR_X86\ |
|
| Build the just-in-time (JIT) compiler implementation | Windows | %ROTOR_DIR%\src\fjit | %TARGETCOMPLUS%\mscorejt.dll |
| FreeBSD | ${TARGETCOMPLUS}/libmscorejt.so | ||
| Build the assembly searching and binding code that implements the global assembly cache (GAC) | Windows | %ROTOR_DIR%\src\fusion | %TARGETCOMPLUS%\fusion.dll |
| FreeBSD | ${TARGETCOMPLUS}/libfusion.so | ||
| Build the ilasm IL assembler | Windows | %ROTOR_DIR%\src\ilasm | %TARGETCOMPLUS%\sdk\bin\ilasm.exe |
| FreeBSD | ${TARGETCOMPLUS}/sdk/bin/ilasm | ||
| Build the ildasm assembly disassembler | Windows | %ROTOR_DIR%\src\ildasm | %TARGETCOMPLUS%\sdk\bin\ildasm.exe |
| FreeBSD | ${TARGETCOMPLUS}/sdk/bin/ildasm | ||
| Build the managed debugger. Part is built into the CLI execution engine and part into the cordbg application. | Windows | %ROTOR_DIR%\src\debug |
%TARGETCOMPLUS%\sdk\bin\cordbg |
| FreeBSD | ${TARGETCOMPLUS}/sdk/bin/cordbg | ||
| Build the metadata reader/writer To incorporate changes to this libraries you should rebuild the entire tree starting at clr\src |
All | %ROTOR_DIR%\src\md | %ROTOR_DIR%\clr\bin\ROTOR_X86\ %DDKBUILDENV%\ceefgen.lib |
Miscellaneous unmanaged tools. Each of these
tools can be built individually as well.
|
All | %ROTOR_DIR%\src\tools | (See individual tool sources file.) |
The FX class libraries provide basic runtime class library support. Interesting sub-elements include:
To build the FX class libraries change into the source location directory and run the build utility.
| Build Scenario | Source Location | Build Output |
|---|---|---|
| Build the System.dll and System.Xml.dll assemblies. Note: there is a circular dependency between System.dll and System.Xml.dll assemblies. If you delete one of these assemblies you must build both from this location. |
%ROTOR_DIR%\fx\src | %TARGETCOMPLUS%\System.dll %TARGETCOMPLUS%\System.Xml.dll These are also installed to |
| Build System.dll assembly. | %ROTOR_DIR%\fx\src\sys | %TARGETCOMPLUS%\System.dll |
| Build System.Xml.dll assembly. | %ROTOR_DIR%\fx\src\xml | %TARGETCOMPLUS%\System.Xml.dll |
Additional managed class libraries:
To build the managed class libraries change into the source location directory and run the build utility.
| Build Scenario | Source Location | Build Output |
|---|---|---|
| Build the System.Runtime.Remoting.dll assembly |
%ROTOR_DIR%\managedlibraries\ remoting |
%TARGETCOMPLUS%\ System.Runtime.Remoting.dll |
| Build the System.Runtime.Serialization.Formatters.Soap.dll assembly | %ROTOR_DIR%\managedlibraries\ soapserializer |
%TARGETCOMPLUS%\ System.Runtime.Serialization.Formatters.Soap.dll |
The Microsoft JScript® compiler is implemented as a managed application. It also builds managed applications.
To build the managed compilers change into the source location directory and run the build utility.
| Build Scenario | Source Location | Build Output |
|---|---|---|
| Modify and rebuild the JScript managed compiler | %ROTOR_DIR%\jscript | %TARGETCOMPLUS%\jsc.exe The files below are also installed to %TARGETCOMPLUS%\Microsoft.Vsa.dll %TARGETCOMPLUS%\Microsoft.JScript.dll |
When you build the Shared Source CLI a large volume of information is output to the console window during the build. Many people assume that this is important build log output but it actually it generally isn't useful except for the final summary output which indicates if there were build errors or warnings. The build utility emits its useful information to build log files.
Build log file names are annotated with the type of build and have an extension that indicates whether they contain error, warning, or general log information. Log file names are annotated to prevent build logs from one build type from overwriting the logs from another build type. Subsequent build runs with the same build type will overwrite the previous log file.
Build log file names are annotated using the value of the BUILD_ALT_DIR environment variable. The extension of the log file will be .log for the complete log output, .err for a build error output subset, and .wrn for a build warning output subset.
| Build Type | BUILD_ALT_DIR env var | Full Log Filename (always created) |
Error Log Filename (only created if build errors) |
Warning Log Filename (only created if build warnings) |
|---|---|---|---|---|
| checked | d | buildd.log | buildd.err | buildd.wrn |
| fastchecked | df | builddf.log | builddf.err | builddf.wrn |
| free on Windows | [not set] | build.log | build.err | build.wrn |
| free on FreeBSD | r | buildr.log | buildr.err | buildr.wrn |
Build log files will be generated at the root directory where the build utility finds a dirs file and begins recursively building the source tree. When you execute the buildall script or batch file several different builds are sequentially performed. After a typical buildall the following build files will be generated:
sscli\clr\src\builddf.log
sscli\clr\src\bcl\builddf.log
sscli\clr\src\toolbox\secdbedit\builddf.log
sscli\fx\src\builddf.log
sscli\jscript\builddf.log
sscli\managedlibraries\builddf.log
sscli\pal\win32\builddf.log
sscli\palrt\src\builddf.log
sscli\samples\builddf.log
sscli\tools\binplace\builddf.log
sscli\tools\build\builddf.log
sscli\tools\ildbconv\builddf.log
sscli\tools\resourcecompiler\builddf.log
If you explicitly change into a directory and run build then log files will be generated in that directory. For the build utility to work you must be in a directory with either a dirs or sources file.
For example, following a buildall you change into the sscli\samples\grep
directory where the sources file for the grep sample resides and type build -c
then a builddf.log file will be created in the sscli\samples\grep directory.
If there are build errors or warnings then the other specific output files will
also be generated in that directory.
If you encounter an error during build then you should look for build error log files (e.g. builddf.err) to obtain more information. However, the build error log files will often only contain incomplete error output resulting from a previous error which didn't get output to the error log file. For example, many errors that occur when building managed code using the Rotor C# compiler are not emitted correctly to the error log file. For complete diagnostics you should read the full build log file. This will show the initial build error which may have cascaded into subsequent output in the build error log file.
Note that some files in the SSCLI source tree are autogenerated before being placed in the SSCLI source tree due to the requirement to interoperate with other build environments within Microsoft and the decision not to port some internal Microsoft tools to run on top of the SSCLI PAL. For example:
If you want to do a quick rebuild after changing a C/C++ file use:
build -z
The -z option skips recalculations of file dependencies.
However, if you are changing a C/C++ header file don't use -z because it will not evaluate the dependency between the header file and the source code.In any directory that contains a sources file, you can have the build process preprocess a file for you:
cd %ROTOR_DIR%\clr\src\vm\wks
nmake assembly.pp ROTOR_X86=1
This will create %ROTOR_DIR%\clr\src\vm\wks\assembly.pp, the C-preprocessed version of assembly.cpp. This is useful for understanding the include process and macro expansion.
The security attributes built into mscorlib need to be serialized using code that also resides in mscorlib. To solve the self-referential dependency, mscorlib.dll is built in several phases:
The code that handles this multistage process can be found in in sscli\clr\src\vm\permset.cpp (especially TranslateSecurityAttributesMSCORLIB) and sscli\clr\src\vm\securitydb.cpp.
Under normal circumstances code should not both define and use security attibutes in the same assembly. The secdbedit tool is only meant to support this by necessity in mscorlib.dll and is narrowly targeted for that purpose. For example, the tool only supports code access security permissions and not the full set of security permissions.
Copyright (c) 2002 Microsoft Corporation