Skip to content

build: add Darwin/macOS support#872

Open
felipek wants to merge 2 commits into
COVESA:masterfrom
felipek:darwin_support
Open

build: add Darwin/macOS support#872
felipek wants to merge 2 commits into
COVESA:masterfrom
felipek:darwin_support

Conversation

@felipek
Copy link
Copy Markdown

@felipek felipek commented May 13, 2026

Adds platform handling for Darwin/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

Copilot AI review requested due to automatic review settings May 13, 2026 11:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, no socket) 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.

Comment thread src/lib/dlt_user.c
Comment thread CMakeLists.txt Outdated
@minminlittleshrimp
Copy link
Copy Markdown
Collaborator

Hi @felipek
please kindly perform signoff in commit message.
Thank you

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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread src/lib/dlt_user.c Outdated
@felipek
Copy link
Copy Markdown
Author

felipek commented May 13, 2026

Hi @felipek please kindly perform signoff in commit message. Thank you

Yes, done. Thanks!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread CMakeLists.txt
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread src/lib/dlt_user.c Outdated
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>
@felipek felipek force-pushed the darwin_support branch 2 times, most recently from 891b5e3 to 0dbba26 Compare May 13, 2026 16:14
@felipek felipek requested a review from Copilot May 13, 2026 16:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

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

Successfully merging this pull request may close these issues.

3 participants