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

libdlt symbol hygiene #582

Open
Felix-El opened this issue Dec 6, 2023 · 1 comment
Open

libdlt symbol hygiene #582

Felix-El opened this issue Dec 6, 2023 · 1 comment
Assignees
Labels

Comments

@Felix-El
Copy link

Felix-El commented Dec 6, 2023

Today, libdlt exposes all of its symbols, which can lead to symbol conflicts.
In fact, this is what brought me here. I was lucky my linker discovered some of such conflicts (many linkers won't). There is high risk code will silently break in unobvious ways and cause major debugging pain.
This is similar to C's ODR (one definition rule) which causes UB when violated - at inter-project scale (exe + shared libs)!
To reduce the "problem surface" libdlt should not contribute symbols like "buffer" to the host applications but only the public API.

I would like to contribute a patch that fixes the situation in the following way, if the community agrees (please comment).

set_target_properties(dlt PROPERTIES
    C_VISIBILITY_PRESET hidden
    CXX_VISIBILITY_PRESET hidden
    VISIBILITY_INLINES_HIDDEN 1
)

to stop exporting all symbols and utilize

include(GenerateExportHeader)
generate_export_header(dlt)

to have a header generated which offers the DLT_EXPORT macro to put in front of all public APIs like

DLT_EXPORT DltReturnValue dlt_init();

It appears that GenerateExportHeader was targetting only CXX apps before CMake 3.12.
Would it be okay to up the minimum CMake 3.12? According ubuntu.com mirrors this version is available for Ubuntu 16.04.

@minminlittleshrimp
Copy link
Collaborator

Thank you @Felix-El ,
sound interesting to me.
It worths investigating, I will look into it and response soon.

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