Changes between Version 6 and Version 8 of Ticket #61775


Ignore:
Timestamp:
Dec 8, 2020, 5:26:29 AM (3 years ago)
Author:
mascguy (Christopher Nielsen)
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #61775

    • Property Summary changed from mame: 0.226 build fails on 10.8; libc++ issue? to mame: 0.226 build fails on 10.8, due to C header /usr/include/xlocale/_stdio.h, snprintf_l(), etc
  • Ticket #61775 – Description

    v6 v8  
    1616}}}
    1717
    18 The issue appears to relate to the libc++ headers: When '_XOPEN_SOURCE' is defined, certain items aren't declared unless '_DARWIN_C_SOURCE' is also defined. So far, this bug seems to be isolated to MacOS 10.8.x.
     18Root cause appears to be preprocessor logic within C header file `/usr/include/xlocale/_stdio.h`, determining whether additional stdio functions are defined. One of those being `snprintf_l()`.
    1919
    20 Note that the Mame port is presently using MacPorts Clang 9. However, the same failures also occur with MacPorts Clang 10.
     20Findings:
     21* In later MacOS/Xcode releases, the logic is `#if __DARWIN_C_LEVEL >= 200112L || defined(__cplusplus)`. The latter condition ensures we don't have to worry about `_DARWIN_C_LEVEL`.
     22* But under MacOS 8.x, the logic is simply `#if __DARWIN_C_LEVEL >= 200112L`, with no awareness of C++ code. This breaks the Mame build.
    2123
    22 Potential solution: Patch source file 'posixfile.cpp', adding the following at the appropriate place:
     24For now, patching Mame source file `posixfile.cpp` is the easy fix. We simply have to appropriately define `__DARWIN_C_LEVEL`, or `_DARWIN_C_SOURCE`. I can confirm that the latter works, and the former certainly should as well.
    2325
    24 {{{
    25 // MacPorts: Fix for libc++ compilation errors on MacOS 10.8
    26 #if defined(__APPLE__)
    27 #define _DARWIN_C_SOURCE
    28 #endif
    29 }}}
    30 
    31 While we could certainly define '_DARWIN_C_SOURCE' globally, that seems more risky. Particularly given that the issue only affects one Mame source file.
    32 
    33 I've confirmed that the proposed fix allows Mame to build successfully, on MacOS 10.8.
     26Note: I'd prefer not to globally define anything, since the issue is limited to a single source file. There's too much risk, and it's simply not needed elsewhere.