build: add Darwin/macOS support#872
Open
felipek wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds build-system and portability adjustments to support building and running dlt-daemon/libdlt on Darwin/macOS, primarily by tweaking platform-linked libraries, compiler warning flags, and pthread API differences.
Changes:
- Adjusts CMake platform library selection for Darwin (no
rt, nosocket) in both library and test builds. - Updates thread naming to use the macOS
pthread_setname_np(const char*)signature. - Adds macOS-specific compile-warning suppressions and guards GCC-only warning flags.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| CMakeLists.txt | Guards GCC-only warning suppression and adds macOS warning suppressions under APPLE. |
| src/lib/CMakeLists.txt | Uses empty RT/SOCKET libraries on Darwin. |
| src/lib/dlt_user.c | Adapts pthread_setname_np usage for macOS and skips pthread_condattr_setclock on Apple. |
| tests/CMakeLists.txt | Uses empty extra libraries on Darwin for unit tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
|
Hi @felipek |
Adds platform handling for macOS: - Guard GCC-only -Wno-stringop-truncation behind a compiler check and silence Clang warnings promoted to errors by -Werror. Probe each Clang flag with check_c_compiler_flag() and only apply it when the compiler is Clang, so older Clang or a GCC build on macOS still works. - Wire up empty RT/SOCKET libraries and test libraries for Darwin. - Use the macOS pthread_setname_np signature (current thread only) and skip pthread_condattr_setclock(CLOCK_MONOTONIC), which is unavailable. On macOS pthread_cond_timedwait() always uses CLOCK_REALTIME, so the deadline timespec is built from CLOCK_REALTIME there as well to avoid premature timeouts or excessively long waits. - In dlt-daemon.c, scope the Linux-only fifo_size local behind __linux__ to silence an unused-variable warning on Darwin, and replace the broken "#elif __QNX__" with "#elif defined(__QNX__)" so the branch is selected by macro presence rather than its value. Signed-off-by: Felipe Kellermann <felipek@me.com>
Author
Yes, done. Thanks! |
Adds platform handling for macOS: - Guard GCC-only -Wno-stringop-truncation behind a compiler check and silence Clang warnings promoted to errors by -Werror. Probe each Clang flag with check_c_compiler_flag() and only apply it when the compiler is Clang, so older Clang or a GCC build on macOS still works. - Wire up empty RT/SOCKET libraries and test libraries for Darwin. - Use the macOS pthread_setname_np signature (current thread only) and skip pthread_condattr_setclock(CLOCK_MONOTONIC), which is unavailable. On macOS pthread_cond_timedwait() always uses CLOCK_REALTIME, so the deadline timespec is built from CLOCK_REALTIME there as well to avoid premature timeouts or excessively long waits. - In dlt-daemon.c, scope the Linux-only fifo_size local behind __linux__ to silence an unused-variable warning on Darwin, and replace the broken "#elif __QNX__" with "#elif defined(__QNX__)" so the branch is selected by macro presence rather than its value. Signed-off-by: Felipe Kellermann <felipek@me.com>
891b5e3 to
0dbba26
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds platform handling for Darwin/macOS:
silence Clang warnings promoted to errors by -Werror. Probe each
Clang flag with check_c_compiler_flag() and only apply it when the
compiler is Clang, so older Clang or a GCC build on macOS still works.
skip pthread_condattr_setclock(CLOCK_MONOTONIC), which is unavailable.
On macOS pthread_cond_timedwait() always uses CLOCK_REALTIME, so the
deadline timespec is built from CLOCK_REALTIME there as well to avoid
premature timeouts or excessively long waits.
__linux__to silence an unused-variable warning on Darwin, andreplace the broken
"#elif __QNX__"with"#elif defined(__QNX__)"so the branch is selected by macro presence rather than its value.
Signed-off-by: Felipe Kellermann felipek@me.com