Skip to content
Snippets Groups Projects
Commit 5cb7a295 authored by Oliver Sander's avatar Oliver Sander
Browse files

Build dynamic library by default

Using a statically linked dune-uggrid together with the Python bindings
leads to hard-to-diagnose crashes and other bugs.  This patch therefore
enables shared libraries, and adds a lengthy explanation of why
this is necessary.
parent 86bf3133
No related tags found
1 merge request!242Build dynamic library by default
Pipeline #73156 failed
......@@ -5,6 +5,9 @@ SPDX-License-Identifier: LGPL-2.1-or-later
# dune-uggrid 2.10 (unreleased)
- `dune-uggrid` now builds a dynamic library by default, because using a shared library
together with the Python just-in-time compilation lead to hard-to-diagnose crashes.
* Remove deprecated `AllocEnvMemory` and `FreeEnvMemory`. They were
wrappers of standard `malloc` and `free`.
......
......@@ -9,6 +9,27 @@ project("dune-uggrid" C CXX)
#circumvent not building docs
set(BUILD_DOCS 1)
# Build shared libraries by default.
#
# Rationale: When using Dune via its C++ interface you can use static
# or dynamic libraries as you like. However, for the Python bindings
# you have to use dynamic libraries. That is because dune-uggrid
# contains a few global variables. The just-in-time compiler that builds
# the Dune Python bindings produces a collection of dynamic libraries.
# If dune-uggrid is built as a static library, then a copy of this
# static library is included in each of the JIT-compiled dynamic libraries.
# As a consequence, the global variables of dune-uggrid exist not once,
# but once in every JIT-compiled dynamic library. However, only one
# of the copies gets actually initialized, but eventually the process
# will access one of the other copies, which leads to hard-to-diagnose
# crashes and wrong results.
#
# In dune-uggrid, this happens in particular with the 'element_descriptors'
# array in the file 'elements.h'. As that array is merely a C-style
# reimplementation of virtual functions it may disappear from dune-uggrid
# eventually. When that happens the situation may be reassessed.
set(BUILD_SHARED_LIBS 1)
# Guess the dune-common build directory if it is not yet set
if(NOT (dune-common_DIR OR dune-common_ROOT OR
"${CMAKE_PREFIX_PATH}" MATCHES ".*dune-common.*"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment