Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set -fvisibility=hidden on OSX and GNU/Linux #2462

Open
jorisv opened this issue Oct 24, 2024 · 1 comment
Open

Set -fvisibility=hidden on OSX and GNU/Linux #2462

jorisv opened this issue Oct 24, 2024 · 1 comment
Labels

Comments

@jorisv
Copy link
Contributor

jorisv commented Oct 24, 2024

In stack-of-tasks/eigenpy#444 we fall on this specific issue:

When building cppad Python binding on OSX in Debug mode, running the following code will crash:

import pinocchio as pin
import pinocchio.cppad as ADpin
from pycppad import AD, ADFun, Independent

It's because pinocchio.cppad doesn't load pycppad as expected.

When building cppad binding, we build the same module.cpp than for the double binding.
Then, both binding can have the same symbols defined.
It's what happen in our example: pinocchio::python::exposeSpecificTypeFeatures for the double binding is loaded instead of the one from cppad binding. Then pycppad is not imported, the AD scalar type is not registered and the code crash.

To avoid this issue we added -fvisibility-inlines-hidden that will set inlined function hidden by default.

But I think we can go further and use -fvisibility=hidden on the whole library.
Since we already manage symbol visibility for Windows, I think it will not cost us so much time.

The main advantage:

  • Avoid some strange bug
  • Smaller binary
  • Catch bad symbol visibility setup on OSX and GNU/Linux (and avoid debugging that on Windows)
@jorisv jorisv added the c++ label Oct 24, 2024
@jcarpent
Copy link
Contributor

Looks perfect to me. Thanks a lot @jorisv for converging to this suggestion.

This was referenced Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants