[MacPorts] #61775: mame: 0.226 build fails on 10.8; libc++ issue? (was: mame: 0.226 build fails on 10.8, due to host libstdc++ bug (_DARWIN_C_SOURCE needs to be defined))

MacPorts noreply at macports.org
Tue Dec 8 01:06:53 UTC 2020


#61775: mame: 0.226 build fails on 10.8; libc++ issue?
----------------------+----------------------
  Reporter:  mascguy  |      Owner:  mascguy
      Type:  defect   |     Status:  assigned
  Priority:  Normal   |  Milestone:
 Component:  ports    |    Version:
Resolution:           |   Keywords:
      Port:  mame     |
----------------------+----------------------
Description changed by mascguy:

Old description:

> Mame 0.226 fails to build on 10.8, due to compilation errors in file
> 'src/osd/modules/files/posixfile.cpp'.
>
> Here's one example:
>
> {{{
> In file included from
> ../../../../../src/osd/modules/file/posixfile.cpp:41:
> In file included from ../../../../../src/osd/modules/file/posixfile.h:12:
> In file included from ../../../../../src/osd/osdcore.h:17:
> In file included from ../../../../../src/lib/util/strformat.h:174:
> In file included from ../../../../../src/lib/util/vecstream.h:25:
> In file included from
> /opt/local/libexec/llvm-9.0/bin/../include/c++/v1/istream:163:
> In file included from
> /opt/local/libexec/llvm-9.0/bin/../include/c++/v1/ostream:140:
> /opt/local/libexec/llvm-9.0/bin/../include/c++/v1/locale:1455:16: error:
> use of undeclared identifier 'snprintf_l'; did you mean 'vswprintf_l'?
>     int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar),
> _LIBCPP_GET_C_LOCALE, __fmt, __v);
>                ^
> }}}
>
> In short, the issue relates to a bug in the host libstdc++: 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.
>
> Proposed immediate-term solution: Patch the source file(s) in question,
> adding the following at the appropriate place:
>
> {{{
> // MacPorts: Fix for libstdc++ bug in MacOS 10.8.x, which causes
> compilation errors
> #if defined(__APPLE__)
> #define _DARWIN_C_SOURCE
> #endif
> }}}
>
> In parallel, I'll also discuss the fixes with the Mame project. And
> ultimately submit a pull request, to permanently fix this for future
> releases.
>
> Note: While we could certainly define '_DARWIN_C_SOURCE' globally, that
> seems more risky. And unnecessary, if only a small number of source files
> are involved.
>
> Currently building on a 10.8 VM, to verify the latter.

New description:

 Mame 0.226 fails to build on 10.8, due to compilation errors in file
 'src/osd/modules/files/posixfile.cpp'.

 Here's one example:

 {{{
 In file included from
 ../../../../../src/osd/modules/file/posixfile.cpp:41:
 In file included from ../../../../../src/osd/modules/file/posixfile.h:12:
 In file included from ../../../../../src/osd/osdcore.h:17:
 In file included from ../../../../../src/lib/util/strformat.h:174:
 In file included from ../../../../../src/lib/util/vecstream.h:25:
 In file included from
 /opt/local/libexec/llvm-9.0/bin/../include/c++/v1/istream:163:
 In file included from
 /opt/local/libexec/llvm-9.0/bin/../include/c++/v1/ostream:140:
 /opt/local/libexec/llvm-9.0/bin/../include/c++/v1/locale:1455:16: error:
 use of undeclared identifier 'snprintf_l'; did you mean 'vswprintf_l'?
     int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar),
 _LIBCPP_GET_C_LOCALE, __fmt, __v);
                ^
 }}}

 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.

 Note that the Mame port is presently using MacPorts Clang 9. However, the
 same failures also occur with MacPorts Clang 10.

 Potential solution: Patch the source file(s) in question, adding the
 following at the appropriate place:

 {{{
 // MacPorts: Fix for libc++ compilation errors on MacOS 10.8
 #if defined(__APPLE__)
 #define _DARWIN_C_SOURCE
 #endif
 }}}

 While we could certainly define '_DARWIN_C_SOURCE' globally, that seems
 more risky. And unnecessary, if only a small number of source files are
 involved.

 Currently building on a 10.8 VM, to verify the latter.

--

-- 
Ticket URL: <https://trac.macports.org/ticket/61775#comment:5>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list