build: fix cross-platform build support and add macOS CI#225
Open
m-mcgowan wants to merge 5 commits intoblues:masterfrom
Open
build: fix cross-platform build support and add macOS CI#225m-mcgowan wants to merge 5 commits intoblues:masterfrom
m-mcgowan wants to merge 5 commits intoblues:masterfrom
Conversation
cd3c7a1 to
49afe4c
Compare
Add conditional CMake configuration for macOS (APPLE): - Skip -m32 and Linux-specific linker flags - Define HAVE_STRLCPY/HAVE_STRLCAT (macOS provides these natively) - Exclude n_str.c (strlcpy/strlcat bundled implementations) - Suppress AppleClang-specific warnings in upstream code - Use -flat_namespace for dylib and test executables to enable FFF test fake symbol interposition All changes are guarded by if(APPLE)/if(NOT APPLE) so Linux CI behavior is completely unchanged.
Use check_symbol_exists() to detect system-provided strlcpy/strlcat (macOS, *BSD) and conditionally exclude n_str.c and define HAVE_STRLCPY/ HAVE_STRLCAT guards. This avoids collisions with the platform's fortified string macros that prevented compilation on macOS. Guard the 32-bit x86 compile/link flags behind a Linux x86 check instead of if(NOT APPLE), making the build portable to any non-x86 platform. Suppress two AppleClang warnings-as-errors in upstream code (-Wstrict-prototypes, -Wunused-but-set-variable). Add -Wl,-flat_namespace on macOS for both the library and test executables so FFF test fakes can interpose dylib symbols.
- n_ua.c: add void to NoteUserAgent() prototype to fix -Wstrict-prototypes (empty parens means unspecified args in C) - n_helpers.c: remove unused variables j and lastLengthCount that triggered -Wunused-but-set-variable With these fixes the -Wno-* suppressions added in the previous commit are no longer needed and are removed from CMakeLists.txt.
49afe4c to
ca24782
Compare
Contributor
Author
|
Reworked to remove the unused variable warning (for what looks like debug code) and fixed the string functions to use CMake-level detection about the headers provided. |
3 tasks
Adds a `run_macos_unit_tests` job that configures and builds note-c with tests on macos-latest. Tests are not run via ctest because FFF symbol interposition does not fully work on macOS — even with -flat_namespace, intra-library calls are resolved at link time and cannot be faked.
- Add `strlcpy` and `strlcat` to the libc dependency whitelist so the `check_libc_dependencies` job passes when `n_str.c` is excluded on systems that provide these functions natively (glibc 2.38+). - Only add `n_str.c` to the lcov coverage exclude list when the file is actually compiled, avoiding an lcov error on unused patterns.
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.
Summary
check_symbol_existsto detect system-providedstrlcpy/strlcat(macOS, FreeBSD, OpenBSD, glibc 2.38+) instead of bundling them unconditionally-m32,-mfpmath=sse, linker paths) byCMAKE_SYSTEM_PROCESSORso builds work on any POSIX platformNoteUserAgentstrict prototype, unused variables inn_helpers.c)strlcpy/strlcatto the libc dependency whitelist and make the lcovn_str.cexclude conditionalChanges
CMakeLists.txt:check_symbol_existsforstrlcpy/strlcat; defineHAVE_STRLCPY/HAVE_STRLCATand excluden_str.cwhen the system provides them-m32,-mfpmath=sse,-msse2, 32-bit linker paths, and-Wl,-melf_i386behindCMAKE_SYSTEM_NAME/CMAKE_SYSTEM_PROCESSORchecks (Linux x86 only)-Wl,-flat_namespaceon Apple for FFF symbol interpositiontest/CMakeLists.txt:-m32flag by Linux x86 check-Wl,-flat_namespaceto test executables on Applen_str.cfrom lcov coverage when the file is actually compiledn_ua.c/n_helpers.c:-Wstrict-prototypes:NoteUserAgent()→NoteUserAgent(void)j,lastLengthCount) that triggered-Wunused-but-set-variablescripts/check_libc_dependencies.sh:strlcpyandstrlcatto the permitted libc function whitelist.github/workflows/ci.yml:run_macos_unit_testsjob (build-only; FFF interposition limitations prevent running ctest on macOS)Test plan
actlocally