Page MenuHomePhabricator

efl: Error with clang and c_std=c
Open, WishlistPublic

Description

I use the following setups:
Compiler: gcc, clang with ccache, the default is gcc.
c_std: c11, gnu11, the default is none.
cpp_std: c++11, gnu++11, the default is c++11.

All that used c_std=c11 have the error:

.
.
.
In file included from ../src/lib/eo/eo_ptr_indirection.h:5,
                 from ../src/lib/eo/eo.c:20:
../src/lib/eo/eo.c: In function ‘_eo_free’:
../src/lib/eo/eo_private.h:142:4: warning: implicit declaration of function ‘typeof’ [-Wimplicit-function-declaration]
  142 |    typeof (_value) _val = _value; \
      |    ^~~~~~
../src/lib/eo/eo.c:1103:9: note: in expansion of macro ‘EO_OPTIONAL_COW_SET’
 1103 |         EO_OPTIONAL_COW_SET(obj, vtable, NULL);
      |         ^~~~~~~~~~~~~~~~~~~
../src/lib/eo/eo_private.h:142:20: error: expected ‘;’ before ‘_val’
  142 |    typeof (_value) _val = _value; \
      |                    ^~~~
../src/lib/eo/eo.c:1103:9: note: in expansion of macro ‘EO_OPTIONAL_COW_SET’
 1103 |         EO_OPTIONAL_COW_SET(obj, vtable, NULL);
      |         ^~~~~~~~~~~~~~~~~~~
../src/lib/eo/eo_private.h:143:29: error: ‘_val’ undeclared (first use in this function)
  143 |    if (_obj->opt->_field != _val) {\
      |                             ^~~~
.
.
.

clang with c_std=gnu11 produce this error:

FAILED: src/generic/evas/evas_image_loader.raw 
ccache clang  -o src/generic/evas/evas_image_loader.raw 'src/generic/evas/580f2bf@@evas_image_loader.raw@exe/raw_main.c.o' -Wl,--no-undefined -Wl,--as-needed -Wl,--start-group src/generic/evas/libevas_loader_common.a src/lib/eina/libeina.so.1.23.0 -pthread -ldl /usr/lib/libsystemd.so /usr/lib/libunwind-generic.so /usr/lib/libunwind.so /usr/lib/libraw.so /usr/lib/libstdc++.so -fopenmp /usr/lib/liblcms2.so -lrt -Wl,--end-group '-Wl,-rpath,$ORIGIN/:$ORIGIN/../../lib/eina' -Wl,-rpath-link,/home/guajar/Desktop/programacao/work/efl/buildclangcgnu/src/generic/evas -Wl,-rpath-link,/home/guajar/Desktop/programacao/work/efl/buildclangcgnu/src/lib/eina
/usr/bin/ld: cannot find -lomp
.
.
.

gcc with c_std=gnu11 was the only that complete the compilation.

In conclusion, clang doesn't compile at all, and c_std=c11 causes error with both compilers.

A example of my build:

CC='ccache clang' CXX='ccache clang++' meson buildclangcgnu -Dbindings=cxx,mono --buildtype=debug -Dinstall-eo-files=true -Dmono-beta=true -Dcpp_std=c++11 -Dc_std=gnu11

If someone wanna go to a adventure. a script to build and compile with all configurations.

brunobelo updated the task description. (Show Details)Tue, Sep 24, 5:46 AM
lauromoura triaged this task as Wishlist priority.Tue, Sep 24, 6:05 AM

This seems to be more related to standards non-conformity/support than actual bugs.

I'm reducing its priority, as this could be handled after the release.

../src/lib/eo/eo_private.h:142:20: error: expected ‘;’ before ‘_val’
  142 |    typeof (_value) _val = _value; \

typeof seems to be a GNU-specific feature, see https://gcc.gnu.org/onlinedocs/gcc/Typeof.html.

clang with c_std=gnu11 produce this error:

/usr/bin/ld: cannot find -lomp

It seems clang requires libomp-dev to be installed, while GCC uses libgomp-dev. See https://askubuntu.com/a/903982