Skip to content

Explicit symbol visibility - #2140

Open
jschueller wants to merge 9 commits into
symengine:masterfrom
jschueller:export
Open

Explicit symbol visibility#2140
jschueller wants to merge 9 commits into
symengine:masterfrom
jschueller:export

Conversation

@jschueller

@jschueller jschueller commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

This generalizes the use of SYMENGINE_EXPORT visibility macro to export all symbols for all windows compilers instead of using CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS in order to allow shared builds with mingw.

@jschueller
jschueller force-pushed the export branch 5 times, most recently from ed7f7c7 to 3966938 Compare April 18, 2026 19:13
@jschueller
jschueller force-pushed the export branch 9 times, most recently from 1326432 to 34442de Compare June 14, 2026 08:41
@jschueller
jschueller marked this pull request as ready for review June 14, 2026 08:57
@jschueller

Copy link
Copy Markdown
Contributor Author

@isuruf hello, I got to a more suitable solution where the same dllimport/dllexport mecanism is used for both msvc and mingw compilers, with a few changes about polys and GaloisField for which I'm not sure (due to subtle template export differences between the two compilers)

@jschueller

Copy link
Copy Markdown
Contributor Author

maybe someone else could review this, maybe @rikardn @lkeegan ?

@lkeegan

lkeegan commented Jul 2, 2026

Copy link
Copy Markdown
Member

@jschueller thanks for the PR - I pushed one small bugfix (4851205) and extended our tests to reproduce the bug (05ddd7d).
Also restored sparse iteration for UPoly with the dense fallback only used for GaloisField (83b57bc)
Otherwise lgtm!

@mergify

mergify Bot commented Jul 2, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@jschueller

Copy link
Copy Markdown
Contributor Author

great, thanks!

@jschueller jschueller mentioned this pull request Jul 3, 2026
Comment thread symengine/expression.h
return pow(base.get_basic(), exp.get_basic());
}

inline void mp_pow_ui(Expression &res, const Expression &base,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mp_pow_ui seems like a weird name for Expression class. pow name seems enough.

@jschueller jschueller Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is needed in usymenginepoly, else I get an error:
D:\a\symengine\symengine\symengine\polys\usymenginepoly.h(14,5): error C2665: 'SymEngine::mp_pow_ui': no overloaded function could convert all the argument types [D:\a\symengine\symengine\build\symengine\symengine.vcxproj]

Comment thread symengine/basic-inl.h
return true;
}

static bool _symengine_constants_initialized = _symengine_init_constants();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this is needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, thats tricky, as we need constants to be explicitly exported now, this guarantees the initialization order of the constants storage: the _symengine_constants_initialized triggers the instanciation of the ConstantInitializer across all TUs which in turns allocates the constants (see also constants.cpp)

@jschueller
jschueller force-pushed the export branch 2 times, most recently from 0abfcc8 to cfa0a11 Compare July 6, 2026 07:35
@bjodah

bjodah commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

I think it would be great to get this in, you all have more experience dealing with symbol hiding on these platforms than me so I'll leave the technicalities to you. One question though: would it be feasible to add a (or replace an existent) CI job which exercises these changes? (and guards against regressions)

@jschueller

jschueller commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

ok, done, there was already a msvc job with shared libs, and I modified one mingw job to build shared libs too

@jschueller
jschueller force-pushed the export branch 2 times, most recently from dce8c9c to 88b47c0 Compare July 18, 2026 06:00
@mergify

mergify Bot commented Jul 18, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@mergify

mergify Bot commented Jul 29, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@jschueller
jschueller marked this pull request as draft July 29, 2026 14:38
@jschueller
jschueller force-pushed the export branch 2 times, most recently from 7c12367 to 94b2fce Compare July 29, 2026 15:08
@jschueller
jschueller marked this pull request as ready for review July 29, 2026 15:08
@jschueller

jschueller commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

@isuruf your changes to set default visibility to hidden exposed a few more places where SYMENGINE_EXPORT was missing which is fixed now, but it also exposed some issues on the ci with the new default BUILD_SHARED_LIBS=ON

as this is an independent issue, lets discuss this in #2152 (you can inspect the ci failures there)

@isuruf

isuruf commented Jul 29, 2026

Copy link
Copy Markdown
Member

@jschueller, let's add my changes back in with the default for BUILD_SHARED_LIBS=OFF?

@mergify

mergify Bot commented Jul 30, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@jschueller

Copy link
Copy Markdown
Contributor Author

done, its enabled by default except when piranha is used because of its template instanciations (like hash_set iterators) creating ODR violations leading to crashing the tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants