Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'st_check_for_sizeof_st_index_t' declared as array with a negative size #130

Open
vadi2 opened this issue Jul 21, 2019 · 15 comments
Open

'st_check_for_sizeof_st_index_t' declared as array with a negative size #130

vadi2 opened this issue Jul 21, 2019 · 15 comments

Comments

@vadi2
Copy link

vadi2 commented Jul 21, 2019

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?

@k-takata
Copy link
Owner

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.

@vadi2
Copy link
Author

vadi2 commented Jul 24, 2019

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.

@vadi2
Copy link
Author

vadi2 commented Jul 24, 2019

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

@k-takata
Copy link
Owner

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.

@vadi2
Copy link
Author

vadi2 commented Jul 24, 2019

@vadi2
Copy link
Author

vadi2 commented Jul 27, 2019

Reported at https://bugs.ruby-lang.org/issues/16025.

vadi2 added a commit to vadi2/edbee-lib that referenced this issue Jul 27, 2019
@nobu
Copy link
Contributor

nobu commented Jul 30, 2019

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

@vadi2
Copy link
Author

vadi2 commented Jul 30, 2019

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

@vadi2
Copy link
Author

vadi2 commented Jul 30, 2019

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.

@nobu
Copy link
Contributor

nobu commented Jul 30, 2019

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

@nobu
Copy link
Contributor

nobu commented Jul 30, 2019

Please elaborate the way to reproduce the issue.

@vadi2
Copy link
Author

vadi2 commented Jul 30, 2019

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.

@vadi2
Copy link
Author

vadi2 commented Aug 12, 2019

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

@vadi2
Copy link
Author

vadi2 commented Oct 3, 2019

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

Lessica added a commit to Lessica/Onigmo-swift-build that referenced this issue Apr 1, 2022
@raa0121
Copy link

raa0121 commented Aug 17, 2023

$ ./configure
$ CC=emcc make

This way I got the same error.

$  CC=emcc ./configure
$ make

I had a successful build this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants