Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MC builds have specific dependencies
[simgrid.git] / docs / source / Installing_SimGrid.rst
1 .. Copyright 2005-2023
2
3 .. _install:
4
5 Installing SimGrid
6 ==================
7
8
9 SimGrid should work out of the box on Linux, macOS, FreeBSD, and
10 Windows (with WSL).
11
12 Pre-compiled Packages
13 ---------------------
14
15 Binaries for Linux
16 ^^^^^^^^^^^^^^^^^^
17
18 To get all of SimGrid on Debian or Ubuntu, simply type one of the
19 following lines, or several lines if you need several languages.
20
21 .. code-block:: console
22
23    $ apt install libsimgrid-dev  # if you want to develop in C or C++
24    $ apt install python3-simgrid # if you want to develop in Python
25
26 If you use the Nix_ package manager, the latest SimGrid release is packaged as ``simgrid`` in Nixpkgs_.
27 Previous SimGrid versions are maintained in `NUR-Kapack`_ and are available
28 pre-compiled in release and debug modes on the `capack cachix binary cache`_
29 — refer to `NUR-Kapack's documentation`_ for usage instructions.
30
31 If you use a pacman-based system (*e.g.*, Arch Linux and derived distributions),
32 the latest SimGrid is available in the `simgrid AUR package`_
33 — refer to `AUR official documentation`_ for installation instructions.
34
35 If you build pre-compiled packages for other distributions, drop us an
36 email.
37
38 .. _Nix: https://nixos.org/
39 .. _Nixpkgs: https://github.com/NixOS/nixpkgs
40 .. _NUR-Kapack: https://github.com/oar-team/nur-kapack
41 .. _capack cachix binary cache: https://app.cachix.org/cache/capack
42 .. _NUR-Kapack's documentation: https://github.com/oar-team/nur-kapack
43 .. _simgrid AUR package: https://aur.archlinux.org/packages/simgrid/
44 .. _AUR official documentation: https://wiki.archlinux.org/title/Arch_User_Repository
45
46 .. _deprecation_policy:
47
48 Version numbering and deprecation
49 ---------------------------------
50
51 SimGrid tries to be both a research instrument that you can trust, and
52 a vivid project targeting the future issues. We have 4 stable versions
53 per year, numbered 3.24 or 3.25. Backward compatibility is ensured for
54 one year: Code compiling without warning on 3.24 will still compile
55 with 3.28, but maybe with some deprecation warnings. You should update
56 your SimGrid installation at least once a year and fix those
57 deprecation warnings: the compatibility wrappers are usually removed
58 after 4 versions. Another approach is to never update your SimGrid
59 installation, but we don't provide any support to old versions.
60
61 Interim versions (also called pre-versions) may be released between
62 stable releases. They are numbered 3.X.Y, with even Y (for example,
63 3.23.2 was released on July 8. 2019 as a pre-version of 3.24). These
64 versions should be as usable as regular stable releases, even if they
65 may be somewhat less tested and documented. They play no role in our
66 deprecation handling, and they are not really announced to not spam
67 our users.
68
69 Version numbered 3.X.Y with odd Y are git versions. They often work,
70 but no guarantee is given whatsoever (all releases are given "as is",
71 but that's even more so for these unreleased versions).
72
73 .. _install_src:
74
75 Installing from the Source
76 --------------------------
77
78 .. _install_src_deps:
79
80 Getting the Dependencies
81 ^^^^^^^^^^^^^^^^^^^^^^^^
82
83 C++ compiler (either g++, clang, or icc).
84   We use the C++17 standard, and older compilers tend to fail on
85   us. It seems that g++ 7.0 or higher is required nowadays (because of
86   boost).  SimGrid compiles well with `clang` or `icc` too.
87 Python 3.
88   SimGrid should build without Python. That is only needed by our regression test suite.
89 cmake (v3.5).
90   ``ccmake`` provides a nicer graphical interface compared to ``cmake``.
91   Press ``t`` in ``ccmake`` if you need to see absolutely all
92   configuration options (e.g., if your Python installation is not standard).
93 boost (at least v1.48, v1.59 recommended)
94   - On Debian / Ubuntu: ``apt install libboost-dev libboost-context-dev``
95   - On CentOS / Fedora: ``dnf install boost-devel``
96   - On macOS with homebrew: ``brew install boost``
97 Eigen3 (optional)
98   - On Debian / Ubuntu: ``apt install libeigen3-dev``
99   - On CentOS / Fedora: ``dnf install eigen3-devel``
100   - On macOS with homebrew: ``brew install eigen``
101   - Use EIGEN3_HINT to specify where it's installed if cmake doesn't find it automatically.
102 Model-checking related dependencies (optional)
103   - On Debian / Ubuntu: ``apt install libunwind-dev libdw-dev libelf-dev libevent-dev``
104
105 For platform-specific details, please see below.
106
107 Getting the Sources
108 ^^^^^^^^^^^^^^^^^^^
109
110 Grab the last **stable release** from `FramaGit
111 <https://framagit.org/simgrid/simgrid/-/releases>`_, and compile it as follows:
112
113 .. code-block:: console
114
115    $ tar xf simgrid-3-XX.tar.gz
116    $ cd simgrid-*
117    $ cmake -DCMAKE_INSTALL_PREFIX=/opt/simgrid -GNinja .
118    $ make
119    $ make install
120
121 If you want to stay on the **bleeding edge**, get the current git version,
122 and recompile it as with stable archives. You may need some extra
123 dependencies.
124
125 .. code-block:: console
126
127    $ git clone https://framagit.org/simgrid/simgrid.git
128    $ cd simgrid
129    $ cmake -DCMAKE_INSTALL_PREFIX=/opt/simgrid .
130    $ make
131    $ make install
132
133 .. _install_src_config:
134
135 Build Configuration
136 ^^^^^^^^^^^^^^^^^^^
137
138 This section is about **compile-time options**, which are very
139 different from :ref:`run-time options <options>`. Compile-time options
140 fall into two categories. **SimGrid-specific options** define which part
141 of the framework to compile while **Generic options** are provided by
142 cmake itself.
143
144 .. warning::
145
146    Our build system often gets mixed up if you change something on
147    your machine after the build configuration.  For example, if
148    SimGrid fails to detect your fortran compiler, it is not enough to
149    install a fortran compiler. You also need to delete all Cmake
150    files, such as ``CMakeCache.txt``. Since Cmake also generates some
151    files in the tree, you may need to wipe out your complete tree and
152    start with a fresh one when you install new dependencies.
153
154    A better solution is to :ref:`build out of the source tree <install_cmake_outsrc>`.
155
156 Generic build-time options
157 """"""""""""""""""""""""""
158
159 These options specify, for example, the path to various system elements (Python
160 path, compiler to use, etc). In most case, CMake automatically discovers the
161 right value for these elements, but you can set them manually as needed.
162 Notably, such variables include ``CC`` and ``CXX``, defining the paths to the C
163 and C++ compilers; ``CFLAGS`` and ``CXXFLAGS`` specifying extra options to pass
164 to the C and C++ compilers; and ``PYTHON_EXECUTABLE`` specifying the path to the
165 Python executable.
166
167 The best way to discover the exact name of the option that you need to
168 change is to press ``t`` in the ``ccmake`` graphical interface, as all
169 options are shown (and documented) in the advanced mode.
170
171 Once you know their name, there are several ways to change the values of
172 build-time options. You can naturally use the ccmake graphical
173 interface for that, or you can use environment variables, or you can
174 prefer the ``-D`` flag of ``cmake``.
175
176 For example, you can change the compilers by issuing these commands to set some
177 environment variables before launching cmake:
178
179 .. code-block:: console
180
181    $ export CC=gcc-5.1
182    $ export CXX=g++-5.1
183
184 The same can be done by passing ``-D`` parameters to cmake, as follows.
185 Note that the dot at the end is mandatory (see :ref:`install_cmake_outsrc`).
186
187 .. code-block:: console
188
189    $ cmake -DCC=clang -DCXX=clang++ .
190
191 SimGrid compilation options
192 """""""""""""""""""""""""""
193
194 Here is the list of all SimGrid-specific compile-time options (the
195 default choice is in upper case).
196
197 CMAKE_INSTALL_PREFIX (path)
198   Where to install SimGrid (/opt/simgrid, /usr/local, or elsewhere).
199
200 enable_compile_optimizations (ON/off)
201   Ask the compiler to produce efficient code. You probably want to
202   leave this option activated, unless you plan to modify SimGrid itself:
203   efficient code takes more time to compile, and appears mangled to some debuggers.
204
205 enable_compile_warnings (on/OFF)
206   Ask the compiler to issue error messages whenever the source
207   code is not perfectly clean. If you are a SimGrid developer, you
208   have to activate this option to enforce the code quality. As a
209   regular user, this option is of little use.
210
211 enable_debug (ON/off)
212   Disabling this option discards all log messages of severity
213   debug or below at compile time (see :ref:`outcome_logs`). The resulting
214   code is marginaly faster than if you discard these messages at
215   runtime, but it obviously becomes impossible to get any debug
216   info from SimGrid when things go wrong.
217
218 enable_documentation (on/OFF)
219   Generates the documentation pages. Building the documentation is not
220   as easy as it used to be, and you should probably use the online
221   version for now.
222
223 enable_lto (ON/off)
224   Enables the *Link Time Optimization* in the C++ compiler.
225   This feature really speeds up the code produced, but it is fragile
226   with older gcc versions.
227
228 enable_maintainer_mode (on/OFF)
229   (dev only) Regenerates the XML parsers whenever the DTD is modified (requires flex and flexml).
230
231 enable_mallocators (ON/off)
232   Activates our internal memory caching mechanism. This produces faster
233   code, but it may fool the debuggers.
234
235 enable_model-checking (on/OFF)
236   Activates the formal verification mode. This may slightly hinder simulation speed even when the model checker is not activated
237   at run time. You need to have the :ref:`required build-dependencies <install_src_deps>` to activate this option.
238
239 enable_ns3 (on/OFF)
240   Activates the ns-3 bindings. See section :ref:`models_ns3`.
241
242 enable_smpi (ON/off)
243   Allows one to run MPI code on top of SimGrid.
244
245 enable_smpi_MBI_testsuite (on/OFF)
246   Adds many extra tests for the model checker module.
247
248 enable_smpi_MPICH3_testsuite (on/OFF)
249   Adds many extra tests for the MPI module.
250
251 minimal-bindings (on/OFF)
252   Take as few optional dependencies as possible, to get minimal
253   library bindings in Python.
254
255 NS3_HINT (empty by default)
256   Alternative path into which ns-3 should be searched for.
257
258 EIGEN3_HINT (empty by default)
259   Alternative path into which Eigen3 should be searched for.
260
261 SIMGRID_PYTHON_LIBDIR (auto-detected)
262   Where to install the Python module library. By default, it is set to the cmake Python3_SITEARCH variable if installing to /usr,
263   and a modified version of that variable if installing to another path. Just force another value if the auto-detected default
264   does not fit your setup.
265
266 SMPI_C_FLAGS, SMPI_CXX_FLAGS, SMPI_Fortran_FLAGS (string)
267   Default compiler options to use in smpicc, smpicxx, or smpiff.
268   This can be useful to set options like "-m32" or "-m64".
269
270 Reset the build configuration
271 """""""""""""""""""""""""""""
272
273 To empty the CMake cache (either when you add a new library or when
274 things go seriously wrong), simply delete your ``CMakeCache.txt``. You
275 may also want to directly edit this file in some circumstances.
276
277 .. _install_cmake_outsrc:
278
279 Out of Tree Compilation
280 ^^^^^^^^^^^^^^^^^^^^^^^
281
282 By default, the files produced during the compilation are placed in
283 the source directory. It is however often better to put them all in a
284 separate directory: cleaning the tree becomes as easy as removing this
285 directory, and you can have several such directories to test several
286 parameter sets or architectures.
287
288 For that, go to the directory where the files should be produced, and
289 invoke cmake (or ccmake) with the full path to the SimGrid source as
290 last argument.
291
292 .. code-block:: console
293
294   $ mkdir build
295   $ cd build
296   $ cmake [options] ..
297   $ make
298
299 Existing Compilation Targets
300 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
301
302 In most cases, compiling and installing SimGrid is enough:
303
304 .. code-block:: console
305
306   $ make
307   $ make install # try "sudo make install" if you don't have the permission to write
308
309 In addition, several compilation targets are provided in SimGrid. If
310 your system is well configured, the full list of targets is available
311 for completion when using the ``Tab`` key. Note that some of the
312 existing targets are not really for public consumption so don't worry
313 if some do not work for you.
314
315 - **make**: Build the core of SimGrid that gets installed, but not any example.
316 - **make tests**: Build the tests and examples.
317 - **make simgrid**: Build only the SimGrid library. Not any example nor the helper tools.
318 - **make s4u-comm-pingpong**: Build only this example (works for any example)
319 - **make python-bindings**: Build the Python bindings
320 - **make clean**: Clean the results of a previous compilation
321 - **make install**: Install the project (doc/ bin/ lib/ include/)
322 - **make dist**: Build a distribution archive (tar.gz)
323 - **make distcheck**: Check the dist (make + make dist + tests on the distribution)
324 - **make documentation**: Create SimGrid documentation
325
326 If you want to see what is really happening, try adding ``VERBOSE=1`` to
327 your compilation requests:
328
329 .. code-block:: console
330
331   $ make VERBOSE=1
332
333 .. _install_src_test:
334
335 Testing your build
336 ^^^^^^^^^^^^^^^^^^
337
338 Once everything is built, you may want to test the result. SimGrid
339 comes with an extensive set of regression tests (as described in the
340 @ref inside_tests "insider manual"). The tests are not built by
341 default, so you first have to build them with ``make tests``. You can
342 then run them with ``ctest``, that comes with CMake.  We run them
343 every commit and the results are on `our Jenkins <https://ci.inria.fr/simgrid/>`_.
344
345 .. code-block:: console
346
347   $ make tests                # Build the tests
348   $ ctest                     # Launch all tests
349   $ ctest -R s4u              # Launch only the tests whose names match the string "s4u"
350   $ ctest -j4                 # Launch all tests in parallel, at most 4 concurrent jobs
351   $ ctest --verbose           # Display all details on what's going on
352   $ ctest --output-on-failure # Only get verbose for the tests that fail
353
354   $ ctest -R s4u -j4 --output-on-failure # You changed S4U and want to check that you  \
355                                          # didn't break anything, huh?                 \
356                                          # That's fine, I do so all the time myself.
357
358 .. _install_cmake_mac:
359
360 macOS-specific instructions
361 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
362
363 SimGrid compiles like a charm with clang (version 3.0 or higher) on macOS:
364
365 .. code-block:: console
366
367   $ cmake -DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++ .
368   $ make
369
370
371 Troubleshooting your macOS build.
372
373 CMake Error: Parse error in cache file build_dir/CMakeCache.txt. Offending entry: /SDKs/MacOSX10.8.sdk
374   This was reported with the XCode version of clang 4.1. The work
375   around is to edit the ``CMakeCache.txt`` file directly, to change
376   the following entry:
377
378   ``CMAKE_OSX_SYSROOT:PATH=/Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer``
379
380   You can safely ignore the warning about "-pthread" not being used, if it appears.
381
382 /usr/include does not seem to exist
383   This directory does not exist by default on modern macOS versions,
384   and you may need to create it with ``xcode-select -install``
385
386 .. _install_cmake_windows:
387
388 Windows-specific instructions
389 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
390
391 The best solution to get SimGrid working on windows is to install the
392 Ubuntu subsystem of Windows 10. All of SimGrid (but the model checker)
393 works in this setting. Native builds never really worked, and they are
394 disabled starting with SimGrid v3.33.
395
396 Python-specific instructions
397 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
398
399 Once you have the Python development headers installed as well as a
400 recent version of the `pybind11 <https://pybind11.readthedocs.io/en/stable/>`_
401 module (version at least 2.4), recompiling the Python bindings from
402 the source should be as easy as:
403
404 .. code-block:: console
405
406   # cd simgrid-source-tree
407   $ python setup.py build install
408
409 Starting with SimGrid 3.13, it should even be possible to install
410 simgrid without downloading the source with pip:
411
412 .. code-block:: console
413
414   $ pip install simgrid