COVESA / COVESA/dlt-daemon

libdlt symbol hygiene

Open
#582 1 comment 1 reaction 1 assignee Claimed by @minminlittleshrimp View on GitHub
refactor
Dominant language
C
Stars
459
Forks
340
Avg merge
4d 21h
Merged PRs (30d)
2

Description

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).

```cmake
set_target_properties(dlt PROPERTIES
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN 1
)
```

to stop exporting all symbols and utilize

```cmake
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

```c
DLT_EXPORT DltReturnValue dlt_init();
```

It appears that `GenerateExportHeader` was [targetting only CXX](https://cmake.org/cmake/help/latest/module/GenerateExportHeader.html) apps before CMake 3.12.
Would it be okay to up the minimum CMake 3.12? According [ubuntu.com mirrors](https://old-releases.ubuntu.com/ubuntu/pool/main/c/cmake/) this version is available for Ubuntu 16.04.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.