mqt-core icon indicating copy to clipboard operation
mqt-core copied to clipboard

🚸 Building Shared Libraries

Open burgholzer opened this issue 1 year ago • 7 comments

Description

This PR started out as a PR that should "just" improve the project installation before top-level projects eventually switch to the new mqt-core version. As part of that, it tried to address #530 by switching the library to build dynamic libraries by default. This considerably decreases the binary size and would, in general, be nice to support.

The corresponding changes need appropriate testing across all different projects to make sure that nothing is missed. I will open corresponding PRs in all top-level projects that use mqt-core to make sure that the new library structure works for all those projects.

In particular:

  • mqt-qcec: cda-tum/mqt-qcec#355
  • mqt-qmap: cda-tum/mqt-qmap#418
  • mqt-ddsim: cda-tum/mqt-ddsim#336

Checklist:

  • [ ] The pull request only contains commits that are related to it.
  • [ ] I have added appropriate tests and documentation.
  • [ ] I have made sure that all CI jobs on GitHub pass.
  • [ ] The pull request introduces no new warnings and follows the project's style guidelines.

burgholzer avatar Jan 24 '24 18:01 burgholzer

Ok. Getting shared libraries to work properly is more work than anticipated. I am going to split this PR apart and will focus on getting the changes that are not related to shared libraries merged as soon as possible so that development in the top-level projects can resume.

burgholzer avatar Jan 26 '24 11:01 burgholzer

Just rebased this PR on top of main and cleaned up the commits a little bit. This should be a solid start once there is more time to look into this.

burgholzer avatar Jan 27 '24 12:01 burgholzer

Ok. Further progress here. To keep the history of this PR, I just squashed the previous commits and added another commit that reverts the respective changes. It turns out, that it might actually not be as hard as expected to get this working since hidden symbol visibility apparently is not a must.

The current state of the PR just changes very few things and, at least locally, that was enough to allow building all of our top-level Python packages based on the installed mqt.core package.

burgholzer avatar Feb 08 '24 22:02 burgholzer

Adding some interesting articles on C++ ABI compatibility here:

  • https://uwekorn.com/2019/09/15/how-we-build-apache-arrows-manylinux-wheels.html
  • https://discuss.python.org/t/how-to-set-glibcxx-use-cxx11-abi-for-manylinux2014-and-manylinux2010-wheels/10551

burgholzer avatar Feb 09 '24 11:02 burgholzer

The Python errors on Windows are interesting as I can't quite make sense of them. This needs some further investigation. It has something to do with the mqt-core-python target. So maybe (finally) removing that resolves the error. Interestingly, the C++ tests work just fine on Windows.

The package check failure is due to the SONAME and Version symlinks as well as the shared libraries in a non-importable location. I am fairly sure it is fine to simply ignore these, but this also needs further investigation.

burgholzer avatar Feb 09 '24 13:02 burgholzer

Alright. The C++ tests working under Windows were simply because no shared libraries were built there. The reason for the failure in the Python module was symbol visibility, which is hidden by default on Windows. However, there is a convenient CMAKE option to export all symbols under Windows. Once that was working, Python could not finde the mqt-core DLLs, which was fixed by adding the bin directory of the package installation to the DLL path.

burgholzer avatar Feb 12 '24 11:02 burgholzer

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 91.6%. Comparing base (7eb0ab7) to head (dc4f55c).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #538   +/-   ##
=====================================
  Coverage   91.6%   91.6%           
=====================================
  Files        148     148           
  Lines      14738   14745    +7     
  Branches    2365    2365           
=====================================
+ Hits       13506   13514    +8     
+ Misses      1232    1231    -1     
Flag Coverage Δ
cpp 91.4% <ø> (+<0.1%) :arrow_up:
python 99.7% <100.0%> (+<0.1%) :arrow_up:
Files Coverage Δ
include/mqt-core/dd/RealNumber.hpp 100.0% <ø> (ø)
src/mqt/core/__init__.py 100.0% <100.0%> (ø)

... and 1 file with indirect coverage changes

codecov[bot] avatar Jun 05 '24 15:06 codecov[bot]

Closing in favor of #662

burgholzer avatar Aug 06 '24 14:08 burgholzer