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