[Mesa-dev] [PATCH:mesa 2/4] Avoid fighting with Solaris headers over isnormal()

Connor Abbott cwabbott0 at gmail.com
Tue Feb 17 13:59:36 PST 2015


On Tue, Feb 17, 2015 at 4:41 PM, Alan Coopersmith
<alan.coopersmith at oracle.com> wrote:
> On 02/17/15 10:21 AM, Emil Velikov wrote:
>>
>> Hi Alan,
>>
>> On 16/02/15 02:41, Alan Coopersmith wrote:
>>>
>>> When compiling in C99 or C++11 modes, Solaris defines isnormal() as
>>> a macro via <math.h>, which causes the function definition to become
>>> too mangled to compile.
>>>
>> Is this series sufficient to get mesa working again with Solaris ?
>
>
> No.  There are still two problems in src/glsl/nir/nir.h:
>
> 1) #pragma once needs to be replaced with a traditional header guard.
>    Since gcc listed #pragma once as deprecated, the Solaris Studio
>    compiler team decided it wasn't worth supporting, and this header
>    causes failures if it's included twice.  (None of the other #pragma
>    once headers seem to cause problems in the build.)
>
> @@ -25,6 +25,9 @@
>   *
>   */
>
> +#ifndef __NIR_H__
> +#define __NIR_H__
> +
>  #pragma once

Need to actually remove the pragma? I'm fine with this, using the
pragma was a silly idea anyways since no one else uses it. I wish it
were used more generally though.

>
>  #include "util/hash_table.h"
> @@ -1566,3 +1569,4 @@ bool nir_opt_remove_phis(nir_shader *shader);
>  #ifdef __cplusplus
>  } /* extern "C" */
>  #endif
> +#endif
>
> 2) Studio C++ does not allow structs to contain arrays with no dimensions.
>    I was able to hack around it by setting the array to zero size and
>    adding the the -features=zla flag to enable zero-length arrays:
>
> @@ -640,7 +643,7 @@ typedef struct nir_alu_instr {
>     nir_instr instr;
>     nir_op op;
>     nir_alu_dest dest;
> -   nir_alu_src src[];
> +   nir_alu_src src[0];
>  } nir_alu_instr;
>
>  /* is this source channel used? */
> @@ -789,7 +792,7 @@ typedef struct {
>
>     nir_deref_var *variables[2];
>
> -   nir_src src[];
> +   nir_src src[0];
>  } nir_intrinsic_instr;

I didn't do this originally, since I did this with another project out
of ignorance and when I tried using clang it generated a warning every
time I tried to access the array member (which in this case, would be
a *lot* of warnings) because this is technically undefined according
to the C standard. But it seems that the latest clang has succumbed to
the bazillions of projects which do this thanks to lame compilers and
legacy code and no longer emits a warning, so... meh.

>
>  /**
>
> Also, I'm building with a very limited configuration and haven't checked the
> rest:  --without-gallium-drivers --disable-dri --disable-dri3
>
> And I have to use CPPFLAGS=" -D__unix__" to make the #ifdefs work in
> include/EGL/eglplatform.h, but it looked like Khronos needs to fix that,
> not Mesa.
>
>> Afaics there is a similar redefinition of isnormal in
>> src/glsl/nir/nir_constant_expressions.py.
>
>
> I have no idea what that's used for or if that's used in our builds.
>
>> The series looks like stable material imho. If you're planning to push
>> these yourself please add
>>
>> Cc: "10.5" <mesa-stable at lists.freedesktop.org>
>> Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>
>
>
> Thanks
>
>
> --
>         -Alan Coopersmith-              alan.coopersmith at oracle.com
>          Oracle Solaris Engineering - http://blogs.oracle.com/alanc
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list