<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2017-04-30 11:43 GMT+02:00 Emil Velikov <span dir="ltr"><<a href="mailto:emil.l.velikov@gmail.com" target="_blank">emil.l.velikov@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Rob,<br>
<span class="gmail-"><br>
On 27 April 2017 at 20:43, Rob Herring <<a href="mailto:robh@kernel.org">robh@kernel.org</a>> wrote:<br>
> From: Mauro Rossi <<a href="mailto:issor.oruam@gmail.com">issor.oruam@gmail.com</a>><br>
><br>
> Necessary to fix the following radeonsi building errors:<br>
><br>
> In file included from external/mesa/src/gallium/<wbr>drivers/radeonsi/si_blit.c:24:<br>
> In file included from external/mesa/src/gallium/<wbr>drivers/radeonsi/si_pipe.h:29:<br>
> In file included from external/mesa/src/gallium/<wbr>drivers/radeonsi/si_shader.h:<wbr>71:<br>
> In file included from external/llvm/include/llvm-c/<wbr>Core.h:18:<br>
> In file included from external/llvm/include/llvm-c/<wbr>ErrorHandling.h:17:<br>
> In file included from external/llvm/include/llvm-c/<wbr>Types.h:17:<br>
> external/llvm/include/llvm/<wbr>Support/DataTypes.h:49:3: error: "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"<br>
> ^<br>
> external/llvm/include/llvm/<wbr>Support/DataTypes.h:53:3: error: "Must #define __STDC_CONSTANT_MACROS before " "#including Support/DataTypes.h"<br>
> ^<br>
> 2 errors generated.<br>
<br>
</span>AFAICT this patch is a hack, as such can we try and fix it in the correct place?<br>
Alternatively please add a big note HACK with some information.<br>
<br>
More elaborate reply follows below, as posted on the Android-x86 mailing list.<br>
<br>
Thanks<br>
Emil<br>
<br>
"...one might<br>
require the defines _only_ when building C++ sources.<br>
<br>
Skimming through my local include/llvm/Support/<wbr>DataTypes.h we have:<br>
<br>
...<br>
#define HAVE_STDINT_H 1<br>
...<br>
<br>
#ifdef __cplusplus<br>
#include <cstdint><br>
#else<br>
#ifdef HAVE_STDINT_H<br>
#include <stdint.h><br>
#else<br>
#error "Compiler must provide an implementation of stdint.h"<br>
#endif<br>
#endif<br>
<br>
#ifndef _MSC_VER<br>
<br>
#if !defined(UINT32_MAX)<br>
# error "The standard header <cstdint> is not C++11 compliant. Must #define "\<br>
"__STDC_LIMIT_MACROS before #including Support/DataTypes.h"<br>
#endif<br>
<br>
#if !defined(UINT32_C)<br>
# error "The standard header <cstdint> is not C++11 compliant. Must #define "\<br>
"__STDC_CONSTANT_MACROS before #including Support/DataTypes.h"<br>
<br>
<br>
In my header [snipped above] the error message is misleading/wrong. We<br>
are using cstdint only in C++ context, and stdint.h in C one. But<br>
that's nothing for you to worry.<br>
<br>
Yet both UINT32_MAX and UINT32_C are defined in stdint.h since they<br>
are part of the C99 standard, which we explicitly require. Even on<br>
Android via LOCAL_CONLYFLAGS += -std=c99.<br></blockquote><div><br></div><div>external/libcxx/include/cstdint does not define UINT32_MAX nor UINT32_C<br></div><div>it relies on #include <stdint.h><br><br></div><div>and in bionic's <stdint.h> I see:<br><br>#ifndef _STDINT_H<br>#define _STDINT_H<br><br>#include <bits/wchar_limits.h><br>#include <stddef.h><br>...<br>/* Keep the kernel from trying to define these types... */<br>#define __BIT_TYPES_DEFINED__<br>...<br>#define UINT32_C(c) c ## U<br>...<br>#define UINT32_MAX (4294967295U)<br>...<br>#endif /* _STDINT_H */<br><br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
Please address this in the correct place. Some how-to/directions:<br>
- check if -std=c99 is correctly propagated<br>
- check that the llvm header is sane (should look roughly like above)<br>
- the stdint.h ends up included and the required macros are guarded<br>
appropriately - ideally there should be no guards, since C11 and C++11<br>
explicitly made the UINT32* macros "allowed".<br>
"<br></blockquote><div><br></div><div>he-he, very funny, those macro are considered harmful ...and were revised in several TC,<br></div><div>and they surely are if they still cause issues.<br></div><div><br></div><div>In the link [1] the problem with in llvm is known and acknowledged,<br></div><div>however they still check for UINT32_MAX UINT32_C being defined,<br></div><div>but are they?<br></div><div><br></div><cstdlib> in libcxx/includes path just wraps bionic's <stdint.h> which has the macros,<br></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">But if -std=c99 is used, is the followwing comment in <a href="http://en.cppreference.com/w/cpp/types/integer">http://en.cppreference.com/w/cpp/types/integer</a> to be taken in consideration?<br><br></div><div class="gmail_extra"><<The C99 standard suggests that C++ implementations should not define the
above limit, constant, or format macros unless the macros <code>__STDC_LIMIT_MACROS</code>, <code>__STDC_CONSTANT_MACROS</code> or <code>__STDC_FORMAT_MACROS</code> (respectively) are defined before including the relevant C header (<code>stdint.h</code> or <code>inttypes.h</code>).
This recommendation was not adopted by any C++ standard and was removed
in C11. However, some implementations (such as glibc 2.17) try to apply
this rule, and it may be necessary to define the <code>__STDC</code> macros; C++ compilers may try to work around this by automatically defining them in some circumstances.>><br><br></div><div class="gmail_extra">And if the macro <code>__STDC_LIMIT_MACROS </code>are not necessarily to be defined in C++11, <br><br>I can't see includes of <cstdint> or <stdint.h> in src/gallium/drivers/radeonsi<br><br>utente@utente-System-Product-Name:~/nougat-x86/external/mesa/src/gallium/drivers/radeonsi$ cgrep cstdint<br>utente@utente-System-Product-Name:~/nougat-x86/external/mesa/src/gallium/drivers/radeonsi$ cgrep stdint<br>utente@utente-System-Product-Name:~/nougat-x86/external/mesa/src/gallium/drivers/radeonsi$<br><br></div><div class="gmail_extra">So how will the UINT32_MAX, UINT32_C macros be defined? Are they pre-bundled?<br>I ask because I don't know<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">M.<br></div><div class="gmail_extra"><br><br></div></div>