Logo AND Algorithmique Numérique Distribuée

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