Skip to content

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

@jorisv

Description

@jorisv

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions