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

Improved control of symbol visibility #3279

Open
rpoyner-tri opened this issue Sep 6, 2024 · 1 comment
Open

Improved control of symbol visibility #3279

rpoyner-tri opened this issue Sep 6, 2024 · 1 comment
Labels
build Build-related issue/PR

Comments

@rpoyner-tri
Copy link

Description of Issue

Drake has begun incorporating portions of OpenUSD, via building from source code. One Drake-specific requirement (that other downstream library developers may have) is to minimize the symbols that are visible from its shared libraries.

Drake uses two techniques to control symbols:

  1. compiler symbol visibility attributes (https://gcc.gnu.org/wiki/Visibility)
  2. rewriting namespace names to contain the string 'drake_vendor'

Technique 1 has the limitation that it sometimes interferes with c++ in surprising ways (e.g #1475). It can work well for plain C code.

Happily, OpenUSD has a very nice system to let downstream builders rewrite its namespaces. However, the Drake integration experience so far has uncovered a few holes in the namespace scheme. I hope to help address this by offering a few small PRs, with reference back to this issue.

Steps to Reproduce

It's easiest to give an example from OpenUSD's own shared library output. These instructions are for Ubuntu Jammy.

  1. $cd path-to/OpenUSD
  2. $ git checkout dev
  3. $ python3 ./build_scripts/build_usd.py --no-python ~/tmp/usd/dist
  4. $ cd ~/tmp/usd/dist
  5. $ readelf --wide --symbols --demangle ./lib/libusd_work.so | grep 'GLOBAL *DEFAULT' |egrep -v 'pxrInternal|GLIBC|GCC|CXXABI|tbb::'
  6. In the output from above, the data section symbol PXR_WORK_THREAD_LIMIT is GLOBAL and not namespaced.
  7. Repeat the above on libusd_gf.so, libusd_pegtl.so, etc., to see other cases.

System Information (OS, Hardware)

Ubuntu LTS versions for x84_64, macOS recent versions for arm64. See the Supported Configurations table at https://drake.mit.edu/installation.html .

Package Versions

The problems vary over time, but several were seen as of v24.08. Current dev has fewer problems already.

Build Flags

@jesschimein
Copy link
Contributor

Filed as internal issue #USD-10094

pixar-oss pushed a commit that referenced this issue Sep 18, 2024
- Use ARCH_HIDDEN to hide nanocolor symbols
- Mark some C-file-only functions `static`, and name all static functions consistently.

Partial fix for #3279.

See #3281

(Internal change: 2341118)
@nvmkuruc nvmkuruc added the build Build-related issue/PR label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build-related issue/PR
Projects
None yet
Development

No branches or pull requests

3 participants