Fixed compile errors when DEBUG is defined (#21656)
[mono-project.git] / README.md
blob0af0afc01d035f7b7062414ad13edf052c293070
1 Mono is a software platform designed to allow developers to easily
2 create cross platform applications.  It is an open source
3 implementation of Microsoft's .NET Framework based on the ECMA
4 standards for C# and the Common Language Runtime.
6 The Mono project is part of the [.NET Foundation](https://www.dotnetfoundation.org/)
8 Join us on [Discord](https://aka.ms/dotnet-discord) in the `#monovm` channel:
10 <a href="https://aka.ms/dotnet-discord">
11   <img src="https://img.shields.io/discord/732297728826277939?style=flat-square&label=Discord&logo=discord&logoColor=white&color=7289DA">
12 </a>
14 ### Contents
16 1. [Compilation and Installation](#compilation-and-installation)
17 2. [Using Mono](#using-mono)
18 3. [Directory Roadmap](#directory-roadmap)
19 4. [Contributing to Mono](#contributing-to-mono)
20 5. [Reporting bugs](#reporting-bugs)
21 6. [Configuration Options](#configuration-options)
22 7. [Working with Submodules](#working-with-submodules)
24 ### Build Status
26 Public CI: [![Azure Pipelines](https://dev.azure.com/dnceng/public/_apis/build/status/mono/mono-ci?branchName=main)](https://dev.azure.com/dnceng/public/_build/latest?definitionId=952&branchName=main)
28 Legacy Jenkins CI (no longer available publicly):
30 | OS           | Architecture       | Status                       |
31 |--------------|--------------------|------------------------------|
32 | Debian 9     | amd64              | [![debian-9-amd64][1]][2]    |
33 | Debian 9     | i386               | [![debian-9-i386][3]][4]     |
34 | Debian 9     | armel              | [![debian-9-armel][5]][6]    |
35 | Debian 9     | armhf              | [![debian-9-armhf][7]][8]    |
36 | Debian 9     | arm64              | [![debian-9-arm64][9]][10]   |
37 | OS X         | amd64              | [![osx-amd64][11]][12]       |
38 | OS X         | i386               | [![osx-i386][13]][14]        |
39 | Windows      | amd64              | [![windows-amd64][15]][16]   |
40 | Windows      | i386               | [![windows-i386][17]][18]    |
41 | CentOS       | s390x (cs)         | [![centos-s390x][19]][20]    |
42 | Debian 9     | ppc64el (cs)       | [![debian-9-ppc64el][21]][22]|
43 | AIX 6.1      | ppc64 (cs)         | [![aix-ppc64][23]][24]       |
44 | FreeBSD 12   | amd64 (cs)         | [![freebsd-amd64][25]][26]   |
46 _(cs) = community supported architecture_
48 [1]: https://jenkins.mono-project.com/job/test-mono-mainline-linux/label=debian-9-amd64/badge/icon
49 [2]: https://jenkins.mono-project.com/job/test-mono-mainline-linux/label=debian-9-amd64
50 [3]: https://jenkins.mono-project.com/job/test-mono-mainline-linux/label=debian-9-i386/badge/icon
51 [4]: https://jenkins.mono-project.com/job/test-mono-mainline-linux/label=debian-9-i386/
52 [5]: https://jenkins.mono-project.com/job/test-mono-mainline-linux/label=debian-9-armel/badge/icon
53 [6]: https://jenkins.mono-project.com/job/test-mono-mainline-linux/label=debian-9-armel/
54 [7]: https://jenkins.mono-project.com/job/test-mono-mainline-linux/label=debian-9-armhf/badge/icon
55 [8]: https://jenkins.mono-project.com/job/test-mono-mainline-linux/label=debian-9-armhf/
56 [9]: https://jenkins.mono-project.com/job/test-mono-mainline-linux/label=debian-9-arm64/badge/icon
57 [10]: https://jenkins.mono-project.com/job/test-mono-mainline-linux/label=debian-9-arm64/
58 [11]: https://jenkins.mono-project.com/job/test-mono-mainline/label=osx-amd64/badge/icon
59 [12]: https://jenkins.mono-project.com/job/test-mono-mainline/label=osx-amd64/
60 [13]: https://jenkins.mono-project.com/job/test-mono-mainline/label=osx-i386/badge/icon
61 [14]: https://jenkins.mono-project.com/job/test-mono-mainline/label=osx-i386/
62 [15]: https://jenkins.mono-project.com/job/z/label=w64/badge/icon
63 [16]: https://jenkins.mono-project.com/job/z/label=w64/
64 [17]: https://jenkins.mono-project.com/job/z/label=w32/badge/icon
65 [18]: https://jenkins.mono-project.com/job/z/label=w32/
66 [19]: https://jenkins.mono-project.com/job/test-mono-mainline-community/label=centos-s390x/badge/icon
67 [20]: https://jenkins.mono-project.com/job/test-mono-mainline-community/label=centos-s390x
68 [21]: https://jenkins.mono-project.com/job/test-mono-mainline-community-chroot/label=debian-9-ppc64el/badge/icon
69 [22]: https://jenkins.mono-project.com/job/test-mono-mainline-community-chroot/label=debian-9-ppc64el
70 [23]: https://jenkins.mono-project.com/job/test-mono-mainline-community/label=aix-ppc64/badge/icon
71 [24]: https://jenkins.mono-project.com/job/test-mono-mainline-community/label=aix-ppc64
72 [25]: https://jenkins.mono-project.com/job/test-mono-mainline-community/label=freebsd-12-amd64/badge/icon
73 [26]: https://jenkins.mono-project.com/job/test-mono-mainline-community/label=freebsd-12-amd64
75 Compilation and Installation
76 ============================
78 Building the Software
79 ---------------------
81 Please see our guides for building Mono on
82 [Mac OS X](https://www.mono-project.com/docs/compiling-mono/mac/),
83 [Linux](https://www.mono-project.com/docs/compiling-mono/linux/) and 
84 [Windows](https://www.mono-project.com/docs/compiling-mono/windows/).
86 Note that building from Git assumes that you already have Mono installed,
87 so please download and [install the latest Mono release](https://www.mono-project.com/download/)
88 before trying to build from Git. This is required because the Mono build
89 relies on a working Mono C# compiler to compile itself
90 (also known as [bootstrapping](https://en.wikipedia.org/wiki/Bootstrapping_(compilers))).
92 If you don't have a working Mono installation
93 ---------------------------------------------
95 If you don't have a working Mono installation, you can try a slightly
96 more risky approach: getting the latest version of the 'monolite' distribution,
97 which contains just enough to run the 'mcs' compiler. You do this with:
99     # Run the following line after ./autogen.sh
100     make get-monolite-latest
102 This will download and place the files appropriately so that you can then
103 just run:
105     make
107 The build will then use the files downloaded by `make get-monolite-latest`.
109 Testing and Installation
110 ------------------------
112 You can run the mono and mcs test suites with the command: `make check`.
114 Expect to find a few test suite failures. As a sanity check, you
115 can compare the failures you got with [https://jenkins.mono-project.com/](https://jenkins.mono-project.com/).
117 You can now install mono with: `make install`
119 You can verify your installation by using the mono-test-install
120 script, it can diagnose some common problems with Mono's install.
121 Failure to follow these steps may result in a broken installation. 
123 Using Mono
124 ==========
126 Once you have installed the software, you can run a few programs:
128 * `mono program.exe` runtime engine
130 * `mcs program.cs` C# compiler
132 * `monodis program.exe` CIL Disassembler
134 See the man pages for mono(1), mcs(1) and monodis(1) for further details.
136 Directory Roadmap
137 =================
139 * `acceptance-tests/` - Optional third party test suites used to validate Mono against a wider range of test cases.
141 * `data/` - Configuration files installed as part of the Mono runtime.
143 * `docs/` - Technical documents about the Mono runtime.
145 * `external/` - Git submodules for external libraries (Newtonsoft.Json, ikvm, etc).
147 * `ikvm-native/` - Glue code for ikvm.
149 * `libgc/` - The (deprecated) Boehm GC implementation.
151 * `llvm/` - Utility Makefiles for integrating the Mono LLVM fork.
153 * `m4/` - General utility Makefiles.
155 * `man/` - Manual pages for the various Mono commands and programs.
157 * `mcs/` - The class libraries, compiler and tools
159   * `class/` - The class libraries (like System.*, Microsoft.Build, etc.)
161   * `mcs/` - The Mono C# compiler written in C#
163   * `tools/` - Tools like gacutil, ikdasm, mdoc, etc.
165 * `mono/` - The core of the Mono Runtime.
167   * `arch/` - Architecture specific portions.
169   * `benchmark/` - A collection of benchmarks.
171   * `btls/` - Build files for the BTLS library which incorporates BoringSSL.
173   * `cil/` - Common Intermediate Representation, XML
174 definition of the CIL bytecodes.
176   * `dis/` - CIL executable Disassembler.
178   * `eglib/` - Independent implementation of the glib API.
180   * `metadata/` - The object system and metadata reader.
182   * `mini/` - The Just in Time Compiler.
184   * `profiler/` - The profiler implementation.
186   * `sgen/` - The SGen Garbage Collector implementation.
188   * `tests/` - The main runtime tests.
190   * `unit-tests/` - Additional runtime unit tests.
192   * `utils/` - Utility functions used across the runtime codebase.
194 * `msvc/` - Logic for the MSVC / Visual Studio based runtime and BCL build system.
195 The latter is experimental at the moment.
197 * `packaging/` - Packaging logic for the OS X and Windows Mono packages.
199 * `po/` - Translation files.
201 * `runtime/` - A directory that contains the Makefiles that link the
202 mono/ and mcs/ build systems.
204 * `samples/` - Some simple sample programs on uses of the Mono
205 runtime as an embedded library.
207 * `scripts/` - Scripts used to invoke Mono and the corresponding program.
209 * `support/` - Various support libraries.
211 * `tools/` - A collection of tools, mostly used during Mono development.
213 Contributing to Mono
214 ====================
216 Before submitting changes to Mono, please review the [contribution
217 guidelines](https://www.mono-project.com/community/contributing/).
218 Please pay particular attention to the [Important
219 Rules](https://www.mono-project.com/community/contributing/#important-rules)
220 section.
222 Reporting bugs
223 ==============
225 To submit bug reports, please [open an issue on the mono GitHub repo](https://github.com/mono/mono/issues/new).
227 Please use the search facility to ensure the same bug hasn't already
228 been submitted and follow our
229 [guidelines](https://www.mono-project.com/community/bugs/make-a-good-bug-report/)
230 on how to make a good bug report.
232 Configuration Options
233 =====================
235 The following are the configuration options that someone building Mono
236 might want to use:
238 * `--with-sgen=yes,no` - Generational GC support: Used to enable or
239 disable the compilation of a Mono runtime with the SGen garbage
240 collector.
242   * On platforms that support it, after building Mono, you will have
243 both a `mono-boehm` binary and a `mono-sgen` binary. `mono-boehm` uses Boehm,
244 while `mono-sgen` uses the Simple Generational GC.
246 * `--with-libgc=[included, none]` - Selects the default Boehm
247 garbage collector engine to use.
249   * *included*: (*slightly modified Boehm GC*) This is the default
250 value for the Boehm GC, and it's the most feature complete, it will
251 allow Mono to use typed allocations and support the debugger.
253   * *none*:
254 Disables the inclusion of a Boehm garbage collector.
256   * This defaults to `included`.
258 * `--enable-cooperative-suspend`
260   * If you pass this flag the Mono runtime is configured to only use
261   the cooperative mode of the garbage collector.  If you do not pass
262   this flag, then you can control at runtime the use of the
263   cooperative GC mode by setting the `MONO_ENABLE_COOP_SUSPEND` flag.
264   
265 * `--with-tls=__thread,pthread`
267   * Controls how Mono should access thread local storage,
268 pthread forces Mono to use the pthread APIs, while
269 __thread uses compiler-optimized access to it.
271   * Although __thread is faster, it requires support from
272 the compiler, kernel and libc. Old Linux systems do
273 not support with __thread.
275   * This value is typically pre-configured and there is no
276 need to set it, unless you are trying to debug a problem.
278 * `--with-sigaltstack=yes,no`
280   * **Experimental**: Use at your own risk, it is known to
281 cause problems with garbage collection and is hard to
282 reproduce those bugs.
284   * This controls whether Mono will install a special
285 signal handler to handle stack overflows. If set to
286 `yes`, it will turn stack overflows into the
287 StackOverflowException. Otherwise when a stack
288 overflow happens, your program will receive a
289 segmentation fault.
291   * The configure script will try to detect if your
292 operating system supports this. Some older Linux
293 systems do not support this feature, or you might want
294 to override the auto-detection.
296 * `--with-static_mono=yes,no`
298   * This controls whether `mono` should link against a
299 static library (libmono.a) or a shared library
300 (libmono.so). 
302   * This defaults to `yes`, and will improve the performance
303 of the `mono` program. 
305   * This only affects the `mono' binary, the shared
306 library libmono.so will always be produced for
307 developers that want to embed the runtime in their
308 application.
310 * `--with-xen-opt=yes,no` - Optimize code for Xen virtualization.
312   * It makes Mono generate code which might be slightly
313 slower on average systems, but the resulting executable will run
314 faster under the Xen virtualization system.
316   * This defaults to `yes`.
318 * `--with-large-heap=yes,no` - Enable support for GC heaps larger than 3GB.
320   * This only applies only to the Boehm garbage collector, the SGen garbage
321 collector does not use this configuration option.
323   * This defaults to `no`.
325 * `--enable-small-config=yes,no` - Enable some tweaks to reduce memory usage
326 and disk footprint at the expense of some capabilities.
328   * Typically this means that the number of threads that can be created
329 is limited (256), that the maximum heap size is also reduced (256 MB)
330 and other such limitations that still make mono useful, but more suitable
331 to embedded devices (like mobile phones).
333   * This defaults to `no`.
335 * `--with-ikvm-native=yes,no` - Controls whether the IKVM JNI interface library is
336 built or not.
338   * This is used if you are planning on
339 using the IKVM Java Virtual machine with Mono.
341   * This defaults to `yes`.
343 * `--with-profile4=yes,no` - Whether you want to build the 4.x profile libraries
344 and runtime.
346   * This defaults to `yes`.
348 * `--with-libgdiplus=installed,sibling,<path>` - Configure where Mono
349 searches for libgdiplus when running System.Drawing tests.
351   * It defaults to `installed`, which means that the
352 library is available to Mono through the regular
353 system setup.
355   * `sibling` can be used to specify that a libgdiplus
356 that resides as a sibling of this directory (mono)
357 should be used.
359  * Or you can specify a path to a libgdiplus.
361 * `--enable-minimal=LIST`
363   * Use this feature to specify optional runtime
364 components that you might not want to include.  This
365 is only useful for developers embedding Mono that
366 require a subset of Mono functionality.
367   * The list is a comma-separated list of components that
368 should be removed, these are:
370     * `aot`:
371 Disables support for the Ahead of Time compilation.
373     * `attach`:
374 Support for the Mono.Management assembly and the
375 VMAttach API (allowing code to be injected into
376 a target VM)
378     * `com`:
379 Disables COM support.
381     * `debug`:
382 Drop debugging support.
384     * `decimal`:
385 Disables support for System.Decimal.
387     * `full_messages`:
388 By default Mono comes with a full table
389 of messages for error codes. This feature
390 turns off uncommon error messages and reduces
391 the runtime size.
393     * `generics`:
394 Generics support.  Disabling this will not
395 allow Mono to run any 2.0 libraries or
396 code that contains generics.
398     * `jit`:
399 Removes the JIT engine from the build, this reduces
400 the executable size, and requires that all code
401 executed by the virtual machine be compiled with
402 Full AOT before execution.
404     * `large_code`:
405 Disables support for large assemblies.
407     * `logging`:
408 Disables support for debug logging.
410     * `pinvoke`:
411 Support for Platform Invocation services,
412 disabling this will drop support for any
413 libraries using DllImport.
415     * `portability`:
416 Removes support for MONO_IOMAP, the environment
417 variables for simplifying porting applications that 
418 are case-insensitive and that mix the Unix and Windows path separators.
420     * `profiler`:
421 Disables support for the default profiler.
423     * `reflection_emit`:
424 Drop System.Reflection.Emit support
426     * `reflection_emit_save`:
427 Drop support for saving dynamically created
428 assemblies (AssemblyBuilderAccess.Save) in
429 System.Reflection.Emit.
431     * `shadow_copy`:
432 Disables support for AppDomain's shadow copies
433 (you can disable this if you do not plan on 
434 using appdomains).
436     * `simd`:
437 Disables support for the Mono.SIMD intrinsics
438 library.
440     * `ssa`:
441 Disables compilation for the SSA optimization
442 framework, and the various SSA-based optimizations.
444 * `--enable-llvm`
446   * This enables the use of LLVM as a code generation engine
447 for Mono.  The LLVM code generator and optimizer will be 
448 used instead of Mono's built-in code generator for both
449 Just in Time and Ahead of Time compilations.
451   * See https://www.mono-project.com/docs/advanced/mono-llvm/ for the 
452 full details and up-to-date information on this feature.
454   * You will need to have an LLVM built that Mono can link
455 against.
457 * `--enable-big-arrays` - Enable use of arrays with indexes larger
458 than Int32.MaxValue.
460   * By default Mono has the same limitation as .NET on
461 Win32 and Win64 and limits array indexes to 32-bit
462 values (even on 64-bit systems).
464   * In certain scenarios where large arrays are required,
465 you can pass this flag and Mono will be built to
466 support 64-bit arrays.
468   * This is not the default as it breaks the C embedding
469 ABI that we have exposed through the Mono development
470 cycle.
472 * `--enable-parallel-mark`
474   * Use this option to enable the garbage collector to use
475 multiple CPUs to do its work.  This helps performance
476 on multi-CPU machines as the work is divided across CPUS.
478   * This option is not currently the default on OSX
479 as it runs into issues there.
481   * This option only applies to the Boehm GC.
483 * `--enable-dtrace`
485   * On Solaris and MacOS X builds a version of the Mono
486 runtime that contains DTrace probes and can
487 participate in the system profiling using DTrace.
489 * `--disable-dev-random`
491   * Mono uses /dev/random to obtain good random data for
492 any source that requires random numbers.   If your
493 system does not support this, you might want to
494 disable it.
496   * There are a number of runtime options to control this
497 also, see the man page.
499 * `--with-csc=roslyn,mcs,default`
501   * Use this option to configure which C# compiler to use.  By default
502     the configure script will pick Roslyn, except on platforms where
503     Roslyn does not work (Big Endian systems) where it will pick mcs.
505     If you specify "mcs", then Mono's C# compiler will be used.  This
506     also allows for a complete bootstrap of Mono's core compiler and
507     core libraries from source.
509     If you specify "roslyn", then Roslyn's C# compiler will be used.
510     This currently uses Roslyn binaries.
511   
512 * `--enable-nacl`
514   * This configures the Mono compiler to generate code
515 suitable to be used by Google's Native Client:
516 https://code.google.com/p/nativeclient/
518   * Currently this is used with Mono's AOT engine as
519 Native Client does not support JIT engines yet.
521 * `--enable-wasm`
523   * Use this option to configure mono to run on WebAssembly. It will
524     set both host and target to the WebAssembly triplet. This overrides
525     the values passed to `--host` or `--target` and ignored what config.sub guesses.
527     This is a workaround to enable usage of old automake versions that don't
528     recognize the wasm triplet.
531 Working With Submodules
532 =======================
534 Mono references several external git submodules, for example
535 a fork of Microsoft's reference source code that has been altered
536 to be suitable for use with the Mono runtime.
538 This section describes how to use it.
540 An initial clone should be done recursively so all submodules will also be
541 cloned in a single pass:
543         $ git clone --recursive git@github.com:mono/mono
545 Once cloned, submodules can be updated to pull down the latest changes.
546 This can also be done after an initial non-recursive clone:
548         $ git submodule update --init --recursive
550 To pull external changes into a submodule:
552         $ cd <submodule>
553         $ git pull origin <branch>
554         $ cd <top-level>
555         $ git add <submodule>
556         $ git commit
558 By default, submodules are detached because they point to a specific commit.
559 Use `git checkout` to move back to a branch before making changes:
561         $ cd <submodule>
562         $ git checkout <branch>
563         # work as normal; the submodule is a normal repo
564         $ git commit/push new changes to the repo (submodule)
566         $ cd <top-level>
567         $ git add <submodule> # this will record the new commits to the submodule
568         $ git commit
570 To switch the repo of a submodule (this should not be a common or normal thing
571 to do at all), first edit `.gitmodules` to point to the new location, then:
573         $ git submodule sync -- <path of the submodule>
574         $ git submodule update --recursive
575         $ git checkout <desired new hash or branch>
577 The desired output diff is a change in `.gitmodules` to reflect the
578 change in the remote URL, and a change in /<submodule> where you see
579 the desired change in the commit hash.
581 License
582 =======
584 See the LICENSE file for licensing information, and the PATENTS.TXT
585 file for information about Microsoft's patent grant.
587 Mono Trademark Use Policy
588 =========================
590 The use of trademarks and logos for Mono can be found [here](https://www.dotnetfoundation.org/legal/mono-tm).