<div dir="ltr">You should define _GNU_SOURCE, in order to get the vasprintf definition (newlib will set __GNU_VISIBLE based on it)<div><br></div><div>While _GNU_SOURCE is "theoretically" supposed to be for end-users to define, to request extra nonstandard functions from standard headers, in practice, it's set effectively always for C++ code, because the C++ standard libraries need it. (see how clang sets it by default for a number of targets in clang/lib/Basic/Targets.cpp).<br><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 13, 2017 at 10:17 AM, Martin J. O'Riordan via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-IE" link="#0563C1" vlink="#954F72"><div class="m_1805277865752714766WordSection1"><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">I have a partial fix for these issues.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">The first is a group of errors that are due to Newlib v2.5.0 providing a richer Locale support than previous releases (Newlib’s ‘</span><span style="font-size:12.0pt;font-family:"Courier New"">locale.h</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">’), and this is turn results in conflicts for all the definitions contained in LibC++’s source ‘</span><span style="font-size:12.0pt;font-family:"Courier New"">include/support/newlib/<wbr>xlocale.h</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">’ I have changed:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New"">#include <support/xlocale/__nop_locale_<wbr>mgmt.h><u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">to:<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New"">#if defined(__NEWLIB__) && (__NEWLIB__ == 2) \<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New"">     && defined(__NEWLIB_MINOR__) && (__NEWLIB_MINOR__ >= 5) \<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New"">     && (!defined(__POSIX_VISIBLE) || (__POSIX_VISIBLE < 200809))<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New"">#include <support/xlocale/__nop_locale_<wbr>mgmt.h><u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New"">#endif<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">I think that  this is a reasonably portable resolution, though I will have to examine intermediate versions of Newlib after v2.2.0-20150423 and before v2.5.0 to see when the relevant changes occurred, so the exclusion check may need to be refined.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">However, I am not sure what to do about ‘</span><span style="font-size:12.0pt;font-family:"Courier New"">vasprintf</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">’.  I tried excluding the function ‘</span><span style="font-size:12.0pt;font-family:"Courier New"">__libcpp_asprintf_l</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">’ if ‘</span><span style="font-size:12.0pt;font-family:"Courier New"">__STRICT_ANSI__</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">’ is defined, but this had knock-on consequences because this function is used elsewhere in the C++ headers, so it is a more complex issue to resolve.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">Thanks,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">            MartinO<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><div><div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Martin J. O'Riordan [mailto:<a href="mailto:martin.oriordan@movidius.com" target="_blank">martin.oriordan@<wbr>movidius.com</a>] <br><b>Sent:</b> 12 January 2017 15:58<br><b>To:</b> 'cfe-dev' <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>><br><b>Subject:</b> Newlib v2.5.0 and LibC++ locale support<u></u><u></u></span></p></div></div><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">I am in the process of updating from using Newlib v2.2.0-20150423 for our common C library with LLVM to v2.5.0 and this is breaking LibC++.  Both LibC++ v3.9 and what is currently at head are affected.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">There are some general problems with Locales, and in particular the definition of the type ‘</span><span style="font-size:12.0pt;font-family:"Courier New";color:black">locale_t</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">’ which is defined in Newlib’s ‘</span><span style="font-size:12.0pt;font-family:"Courier New";color:black">sys/_locale.h</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">’ as:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New";color:black">typedef struct __locale_t *locale_t;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">and in LibC++’s ‘</span><span style="font-size:12.0pt;font-family:"Courier New";color:black">support/xlocale/__nop_locale_<wbr>mgmt.h</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">’ as:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New";color:black">typedef void *locale_t;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">But it is also running into another problem with ‘</span><span style="font-size:12.0pt;font-family:"Courier New";color:black">vasprintf</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">’.  In LibC++ this is referenced in ‘</span><span style="font-size:12.0pt;font-family:"Courier New";color:black">__bsd_locale_fallbacks.h</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">’, but ‘</span><span style="font-size:12.0pt;font-family:"Courier New";color:black">vasprintf</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">’ is not an ISO C function, and the newer version of Newlib has the declaration in ‘</span><span style="font-size:12.0pt;font-family:"Courier New";color:black"><stdio.h></span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">’ guarded with ‘</span><span style="font-size:12.0pt;font-family:"Courier New";color:black">__GNU_VISIBLE</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">’ to keep it out of the global namespace, thus:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New";color:black">#if __GNU_VISIBLE<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New";color:black">int  _EXFUN(asprintf, (char **__restrict, const char *__restrict, ...)<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New";color:black">               _ATTRIBUTE ((__format__ (__printf__, 2, 3))));<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New";color:black">int  _EXFUN(vasprintf, (char **, const char *, __VALIST)<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New";color:black">               _ATTRIBUTE ((__format__ (__printf__, 2, 0))));<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New";color:black">#endif<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">I don’t know which version of Newlib changed the declaration of ‘</span><span style="font-size:12.0pt;font-family:"Courier New";color:black">vasprintf</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">’, but the current LibC++ does not seem to handle the change.  Should I be building LibC++ with ‘</span><span style="font-size:12.0pt;font-family:"Courier New";color:black">__GNU_VISIBLE</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">’ defined?  Any recommendations for how I should resolve the multiple definition of ‘</span><span style="font-size:12.0pt;font-family:"Courier New";color:black">locale_t</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">’?<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">Thanks,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif;color:black">            MartinO<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Courier New";color:black"><u></u> <u></u></span></p></div></div><br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>