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

Properly fix Pathogen and libClangSharp extensions not being exported on Linux #3

Open
PathogenDavid opened this issue Feb 14, 2021 · 2 comments

Comments

@PathogenDavid
Copy link
Member

PathogenDavid commented Feb 14, 2021

On Linux, libclang typically exports its functions via an explicit listing: libclang.exports.

Because of this, the pathogen_ and clangsharp_ functions aren't being exported on Linux builds. Explicitly setting the visibility (IE: __attribute__((visibility("default")))) does not seem to work when this file is in use, I assume because the linker treats this exports file as the source of truth when it is specified.

In theory we could just list all of our functions here too, but I'm concerned this will lead to mistakes due to the fact that functions will be exported differently depending on the platform. Ideally it should "just work" on Linux like it does on Windows. (Edit: Upon some additional consideration, these mistakes could be prevented by adding some unit tests to either ClangSharp.Pathogen or llvm-project to ensure everything gets exported on all platforms. Although we'd likely want to do this as part of the ClangSharp.Pathogen CI since it's already building libclang.)

For now I've disabled the exports file, which causes the libclang.so file to balloon from 81 MB to 99 MB on my system. It's not clear whether this is caused by all the additional code needed to support these functions or whether it's caused by the fact that a ton of Clang's C++ API is now being exported too. If it's the former, this might just be the workaround.

@PathogenDavid
Copy link
Member Author

Considering libclang.so from the 12.0.0 Ubuntu 16.04 build is 95.4 MB, I'm not sure if this is actually worth the time/effort to shrink it down since it only affects generators and not binding distribution.

@PathogenDavid PathogenDavid changed the title Fix Pathogen and libClangSharp extensions not being exported on Linux Properly fix Pathogen and libClangSharp extensions not being exported on Linux Jul 29, 2021
@PathogenDavid
Copy link
Member Author

A possible solution I came across while working on adding ELF support to LinkImportsTransformation:

  • Disable the exports file
  • Make the default visibility hidden via -fvisibility=hidden
  • Use __attribute__((visibility("default")))

This is actually basically what GCC recommends in the documentation for -fvisibility.

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

No branches or pull requests

1 participant