Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Test for JSON before using it
[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 mandatory components (at least v1.48, v1.59 recommended)
94   - On Debian / Ubuntu: ``apt install libboost-dev``
95   - On CentOS / Fedora: ``dnf install boost-devel``
96   - On macOS with homebrew: ``brew install boost``
97 boost recommended components (optional).
98   - boost-context may be used instead of our own fast context switching code which only works on amd64.
99   - boost-stacktrace is used to get nice stacktraces on errors in SimGrid.
100   - On Debian / Ubuntu: ``apt install libboost-context-dev libboost-stacktrace-dev``
101 python bindings (optional):
102   - On Debian / Ubuntu: ``apt install pybind11-dev python3-dev``
103 Model-checking dependencies (optional)
104   - On Debian / Ubuntu: ``apt install libunwind-dev libdw-dev libelf-dev libevent-dev``
105 Eigen3 (optional)
106   - On Debian / Ubuntu: ``apt install libeigen3-dev``
107   - On CentOS / Fedora: ``dnf install eigen3-devel``
108   - On macOS with homebrew: ``brew install eigen``
109   - Use EIGEN3_HINT to specify where it's installed if cmake doesn't find it automatically.
110 JSON (optional, for the DAG wfcommons loader)
111   - On Debian / Ubuntu: ``apt install nlohmann-json3-dev``
112   - Use nlohmann_json_HINT to specify where it's installed if cmake doesn't find it automatically.
113
114 For platform-specific details, please see below.
115
116 Getting the Sources
117 ^^^^^^^^^^^^^^^^^^^
118
119 Grab the last **stable release** from `FramaGit
120 <https://framagit.org/simgrid/simgrid/-/releases>`_, and compile it as follows:
121
122 .. code-block:: console
123
124    $ tar xf simgrid-3-XX.tar.gz
125    $ cd simgrid-*
126    $ cmake -DCMAKE_INSTALL_PREFIX=/opt/simgrid -GNinja .
127    $ make
128    $ make install
129
130 If you want to stay on the **bleeding edge**, get the current git version,
131 and recompile it as with stable archives. You may need some extra
132 dependencies.
133
134 .. code-block:: console
135
136    $ git clone https://framagit.org/simgrid/simgrid.git
137    $ cd simgrid
138    $ cmake -DCMAKE_INSTALL_PREFIX=/opt/simgrid .
139    $ make
140    $ make install
141
142 .. _install_src_config:
143
144 Build Configuration
145 ^^^^^^^^^^^^^^^^^^^
146
147 This section is about **compile-time options**, which are very
148 different from :ref:`run-time options <options>`. Compile-time options
149 fall into two categories. **SimGrid-specific options** define which part
150 of the framework to compile while **Generic options** are provided by
151 cmake itself.
152
153 .. warning::
154
155    Our build system often gets mixed up if you change something on
156    your machine after the build configuration.  For example, if
157    SimGrid fails to detect your fortran compiler, it is not enough to
158    install a fortran compiler. You also need to delete all Cmake
159    files, such as ``CMakeCache.txt``. Since Cmake also generates some
160    files in the tree, you may need to wipe out your complete tree and
161    start with a fresh one when you install new dependencies.
162
163    A better solution is to :ref:`build out of the source tree <install_cmake_outsrc>`.
164
165 Generic build-time options
166 """"""""""""""""""""""""""
167
168 These options specify, for example, the path to various system elements (Python
169 path, compiler to use, etc). In most case, CMake automatically discovers the
170 right value for these elements, but you can set them manually as needed.
171 Notably, such variables include ``CC`` and ``CXX``, defining the paths to the C
172 and C++ compilers; ``CFLAGS`` and ``CXXFLAGS`` specifying extra options to pass
173 to the C and C++ compilers; and ``PYTHON_EXECUTABLE`` specifying the path to the
174 Python executable.
175
176 The best way to discover the exact name of the option that you need to
177 change is to press ``t`` in the ``ccmake`` graphical interface, as all
178 options are shown (and documented) in the advanced mode.
179
180 Once you know their name, there are several ways to change the values of
181 build-time options. You can naturally use the ccmake graphical
182 interface for that, or you can use environment variables, or you can
183 prefer the ``-D`` flag of ``cmake``.
184
185 For example, you can change the compilers by issuing these commands to set some
186 environment variables before launching cmake:
187
188 .. code-block:: console
189
190    $ export CC=gcc-5.1
191    $ export CXX=g++-5.1
192
193 The same can be done by passing ``-D`` parameters to cmake, as follows.
194 Note that the dot at the end is mandatory (see :ref:`install_cmake_outsrc`).
195
196 .. code-block:: console
197
198    $ cmake -DCC=clang -DCXX=clang++ .
199
200 SimGrid compilation options
201 """""""""""""""""""""""""""
202
203 Here is the list of all SimGrid-specific compile-time options (the
204 default choice is in upper case).
205
206 CMAKE_INSTALL_PREFIX (path)
207   Where to install SimGrid (/opt/simgrid, /usr/local, or elsewhere).
208
209 enable_compile_optimizations (ON/off)
210   Ask the compiler to produce efficient code. You probably want to
211   leave this option activated, unless you plan to modify SimGrid itself:
212   efficient code takes more time to compile, and appears mangled to some debuggers.
213
214 enable_compile_warnings (on/OFF)
215   Ask the compiler to issue error messages whenever the source
216   code is not perfectly clean. If you are a SimGrid developer, you
217   have to activate this option to enforce the code quality. As a
218   regular user, this option is of little use.
219
220 enable_debug (ON/off)
221   Disabling this option discards all log messages of severity
222   debug or below at compile time (see :ref:`outcome_logs`). The resulting
223   code is marginaly faster than if you discard these messages at
224   runtime, but it obviously becomes impossible to get any debug
225   info from SimGrid when things go wrong.
226
227 enable_documentation (on/OFF)
228   Generates the documentation pages. Building the documentation is not
229   as easy as it used to be, and you should probably use the online
230   version for now.
231
232 enable_lto (ON/off)
233   Enables the *Link Time Optimization* in the C++ compiler.
234   This feature really speeds up the code produced, but it is fragile
235   with older gcc versions.
236
237 enable_maintainer_mode (on/OFF)
238   (dev only) Regenerates the XML parsers whenever the DTD is modified (requires flex and flexml).
239
240 enable_mallocators (ON/off)
241   Activates our internal memory caching mechanism. This produces faster
242   code, but it may fool the debuggers.
243
244 enable_model-checking (on/OFF)
245   Activates the formal verification mode. This will hinder simulation speed even when the model checker is not activated at run
246   time, because some optimizations such as LTO must be disabled at compile time. You need to have the :ref:`required
247   build-dependencies <install_src_deps>` to activate this option.
248
249 enable_ns3 (on/OFF)
250   Activates the ns-3 bindings. See section :ref:`models_ns3`.
251
252 enable_smpi (ON/off)
253   Allows one to run MPI code on top of SimGrid.
254
255 enable_smpi_MBI_testsuite (on/OFF)
256   Adds many extra tests for the model checker module.
257
258 enable_smpi_MPICH3_testsuite (on/OFF)
259   Adds many extra tests for the MPI module.
260
261 minimal-bindings (on/OFF)
262   Take as few optional dependencies as possible, to get minimal
263   library bindings in Python.
264
265 NS3_HINT (empty by default)
266   Alternative path into which ns-3 should be searched for.
267
268 EIGEN3_HINT (empty by default)
269   Alternative path into which Eigen3 should be searched for.
270
271 SIMGRID_PYTHON_LIBDIR (auto-detected)
272   Where to install the Python module library. By default, it is set to the cmake Python3_SITEARCH variable if installing to /usr,
273   and a modified version of that variable if installing to another path. Just force another value if the auto-detected default
274   does not fit your setup.
275
276 SMPI_C_FLAGS, SMPI_CXX_FLAGS, SMPI_Fortran_FLAGS (string)
277   Default compiler options to use in smpicc, smpicxx, or smpiff.
278   This can be useful to set options like "-m32" or "-m64".
279
280 Reset the build configuration
281 """""""""""""""""""""""""""""
282
283 To empty the CMake cache (either when you add a new library or when
284 things go seriously wrong), simply delete your ``CMakeCache.txt``. You
285 may also want to directly edit this file in some circumstances.
286
287 .. _install_cmake_outsrc:
288
289 Out of Tree Compilation
290 ^^^^^^^^^^^^^^^^^^^^^^^
291
292 By default, the files produced during the compilation are placed in
293 the source directory. It is however often better to put them all in a
294 separate directory: cleaning the tree becomes as easy as removing this
295 directory, and you can have several such directories to test several
296 parameter sets or architectures.
297
298 For that, go to the directory where the files should be produced, and
299 invoke cmake (or ccmake) with the full path to the SimGrid source as
300 last argument.
301
302 .. code-block:: console
303
304   $ mkdir build
305   $ cd build
306   $ cmake [options] ..
307   $ make
308
309 Existing Compilation Targets
310 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
311
312 In most cases, compiling and installing SimGrid is enough:
313
314 .. code-block:: console
315
316   $ make
317   $ make install # try "sudo make install" if you don't have the permission to write
318
319 In addition, several compilation targets are provided in SimGrid. If
320 your system is well configured, the full list of targets is available
321 for completion when using the ``Tab`` key. Note that some of the
322 existing targets are not really for public consumption so don't worry
323 if some do not work for you.
324
325 - **make**: Build the core of SimGrid that gets installed, but not any example.
326 - **make tests**: Build the tests and examples.
327 - **make simgrid**: Build only the SimGrid library. Not any example nor the helper tools.
328 - **make s4u-comm-pingpong**: Build only this example (works for any example)
329 - **make python-bindings**: Build the Python bindings
330 - **make clean**: Clean the results of a previous compilation
331 - **make install**: Install the project (doc/ bin/ lib/ include/)
332 - **make dist**: Build a distribution archive (tar.gz)
333 - **make distcheck**: Check the dist (make + make dist + tests on the distribution)
334 - **make documentation**: Create SimGrid documentation
335
336 If you want to see what is really happening, try adding ``VERBOSE=1`` to
337 your compilation requests:
338
339 .. code-block:: console
340
341   $ make VERBOSE=1
342
343 .. _install_src_test:
344
345 Testing your build
346 ^^^^^^^^^^^^^^^^^^
347
348 Once everything is built, you may want to test the result. SimGrid
349 comes with an extensive set of regression tests (as described in the
350 @ref inside_tests "insider manual"). The tests are not built by
351 default, so you first have to build them with ``make tests``. You can
352 then run them with ``ctest``, that comes with CMake.  We run them
353 every commit and the results are on `our Jenkins <https://ci.inria.fr/simgrid/>`_.
354
355 .. code-block:: console
356
357   $ make tests                # Build the tests
358   $ ctest                     # Launch all tests
359   $ ctest -R s4u              # Launch only the tests whose names match the string "s4u"
360   $ ctest -j4                 # Launch all tests in parallel, at most 4 concurrent jobs
361   $ ctest --verbose           # Display all details on what's going on
362   $ ctest --output-on-failure # Only get verbose for the tests that fail
363
364   $ ctest -R s4u -j4 --output-on-failure # You changed S4U and want to check that you  \
365                                          # didn't break anything, huh?                 \
366                                          # That's fine, I do so all the time myself.
367
368 .. _install_cmake_mac:
369
370 macOS-specific instructions
371 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
372
373 SimGrid compiles like a charm with clang (version 3.0 or higher) on macOS:
374
375 .. code-block:: console
376
377   $ cmake -DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++ .
378   $ make
379
380
381 Troubleshooting your macOS build.
382
383 CMake Error: Parse error in cache file build_dir/CMakeCache.txt. Offending entry: /SDKs/MacOSX10.8.sdk
384   This was reported with the XCode version of clang 4.1. The work
385   around is to edit the ``CMakeCache.txt`` file directly, to change
386   the following entry:
387
388   ``CMAKE_OSX_SYSROOT:PATH=/Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer``
389
390   You can safely ignore the warning about "-pthread" not being used, if it appears.
391
392 /usr/include does not seem to exist
393   This directory does not exist by default on modern macOS versions,
394   and you may need to create it with ``xcode-select -install``
395
396 .. _install_cmake_windows:
397
398 Windows-specific instructions
399 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
400
401 The best solution to get SimGrid working on windows is to install the
402 Ubuntu subsystem of Windows 10. All of SimGrid (but the model checker)
403 works in this setting. Native builds never really worked, and they are
404 disabled starting with SimGrid v3.33.
405
406 Python-specific instructions
407 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
408
409 Once you have the Python development headers installed as well as a
410 recent version of the `pybind11 <https://pybind11.readthedocs.io/en/stable/>`_
411 module (version at least 2.4), recompiling the Python bindings from
412 the source should be as easy as:
413
414 .. code-block:: console
415
416   # cd simgrid-source-tree
417   $ python setup.py build install
418
419 Starting with SimGrid 3.13, it should even be possible to install
420 simgrid without downloading the source with pip:
421
422 .. code-block:: console
423
424   $ pip install simgrid