k-takata / Onigmo

Onigmo is a regular expressions library forked from Oniguruma.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'st_check_for_sizeof_st_index_t' declared as array with a negative size

vadi2 opened this issue · comments

I'm trying to compile a library that used Onigmo with Emscripten 1.38.30 and I'm getting the following error:

regcomp.o 3rdparty/edbee-lib/vendor/onig/regcomp.c
In file included from 3rdparty/edbee-lib/vendor/onig/regcomp.c:31:
In file included from 3rdparty/edbee-lib/vendor/onig/regparse.h:33:
In file included from 3rdparty/edbee-lib/vendor/onig/regint.h:923:
3rdparty/edbee-lib/vendor/onig/st.h:65:45: error: 'st_check_for_sizeof_st_index_t' declared as an
      array with a negative size
typedef char st_check_for_sizeof_st_index_t[SIZEOF_VOIDP == (int)sizeof(st_index_t) ? 1 : -1];
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3rdparty/edbee-lib/vendor/onig/config.h:109:22: note: expanded from macro 'SIZEOF_VOIDP'
#define SIZEOF_VOIDP 8
                     ^
1 error generated.
shared:ERROR: compiler frontend failed to generate LLVM bitcode, halting
Makefile:36871: recipe for target 'regcomp.o' failed

Any ideas what could be wrong?

What are the definitions of SIZEOF_LONG and SIZEOF_LONG_LONG in 3rdparty/edbee-lib/vendor/onig/config.h? Are they defined to 8?
sizeof(st_index_t) should be equal to sizeof(void*), and this line (st.h L65) just checks it.

If this error occurs even if the both sizes are the same (maybe because of a compiler problem), you can comment out this line.

Yes, both are 8:

onig$ cat config.h | grep SIZEOF_LONG
#define SIZEOF_LONG 8
#define SIZEOF_LONG_LONG 8

So it sounds like an Emscripten compiler problem, I will comment it out.

Is there a chance to add a workaround for it in the source? Would rather not be using a custom fork of the library.

Does Emscripten have its own definition? (like __GNUC__, _MSC_VER, etc.)

Actually st.h is imported from Ruby, so it would be better if Ruby adds a workaround for it.

I tried building by emcc, but SIZEOF_VOIDP is 4.
How can I run emcc for 64bit binary?

./emsdk install sdk-1.38.16-64bit and ./emsdk activate --embedded sdk-1.38.16-64bit (I used instructions from Qt).

Sorry I didn't reply in the original bug tracker - I did select the Watch option (it was off by default) and yet I still didn't receive any emails about a notification.

I don't know how to comment on there because there is no Reply button 😕

Yes I'm just trying to build Onigmo that is used as part of https://github.com/edbee/edbee-lib using Emscripten.

Installed and acrtivated sdk-1.38.16-64bit, then run emsdk_env.sh.
Seems running the proper version.

$ emcc --version
emcc (Emscripten gcc/clang-like replacement) 1.38.16 (commit e2110d88167bc0bd74affe35054d799f90dfa759)
Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt)
This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

But the size of pointer is still 4.

$ emcc -E -dM -xc /dev/null | grep SIZEOF
#define __SIZEOF_DOUBLE__ 8
#define __SIZEOF_FLOAT__ 4
#define __SIZEOF_INT__ 4
#define __SIZEOF_LONG_DOUBLE__ 8
#define __SIZEOF_LONG_LONG__ 8
#define __SIZEOF_LONG__ 4
#define __SIZEOF_POINTER__ 4
#define __SIZEOF_PTRDIFF_T__ 4
#define __SIZEOF_SHORT__ 2
#define __SIZEOF_SIZE_T__ 4
#define __SIZEOF_WCHAR_T__ 4
#define __SIZEOF_WINT_T__ 4

Please elaborate the way to reproduce the issue.

It seems I have the same values:

vadi@volga:~/Programs/emsdk$ emcc --version
emcc (Emscripten gcc/clang-like replacement) 1.38.30 (commit a51302ba20697f5251a8185cfdc72e72b14351e4)
Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt)
This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  
vadi@volga:~/Programs/emsdk$ emcc -E -dM -xc /dev/null | grep SIZEOF
#define __SIZEOF_DOUBLE__ 8
#define __SIZEOF_FLOAT__ 4
#define __SIZEOF_INT__ 4
#define __SIZEOF_LONG_DOUBLE__ 8
#define __SIZEOF_LONG_LONG__ 8
#define __SIZEOF_LONG__ 4
#define __SIZEOF_POINTER__ 4
#define __SIZEOF_PTRDIFF_T__ 4
#define __SIZEOF_SHORT__ 2
#define __SIZEOF_SIZE_T__ 4
#define __SIZEOF_WCHAR_T__ 4
#define __SIZEOF_WINT_T__ 4
vadi@volga:~/Programs/emsdk$ 

I'm not sure what the issue is now, besides that check failing?

My emcc is newer, sorry I gave the wrong command above - copy/pasted it on autopilot.

@nobu is there anything I can provide to help you with this?

@k-takata Sorry to bother, what can I do to get the library building in Emscripten?

$ ./configure
$ CC=emcc make

This way I got the same error.

$  CC=emcc ./configure
$ make

I had a successful build this way.