Emscripten compiler flag to allow 64bit integers

1,043 views
Skip to first unread message

Daniel Rodríguez

unread,
Jan 16, 2016, 8:25:12 PM1/16/16
to emscripten-discuss
Hey team, a bit late happy new year!

I've been trying to build a project that tries to use int64 bit numbers but the C code doesn't seem to detect that 64 bit integers are enabled, is there a flag we can send to the compiler?

Any advice would be great.

To be specific, I'm trying to build webruby (a web version of MRuby) but with an mruby modified to support bignums.

Mruby with bignums support: https://github.com/chasonr/mruby

Any information is appreciated!
Thanks for your time and best regards.

Alon Zakai

unread,
Jan 16, 2016, 10:11:08 PM1/16/16
to emscripten-discuss
64-bit integers should just work - there is no flag that you should be passing. What error are you seeing? Bitcode to reproduce the problem would also help.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Rodriguez

unread,
Jan 17, 2016, 12:49:23 AM1/17/16
to emscripte...@googlegroups.com
Hey!

So, just to give some context, I'm building this webruby (it has the webruby with bignums) https://github.com/sadasant/webruby/tree/cloudwalk

I'm sorry if my explanation is not an isolated example, neither a simple one, the problem is indeed complex for me, however I will try my best to explain my situation.

Webruby creates a file called webruby.js with a compiled version of mruby with a little layer to make it usable in a simple way.

To the chansorg webruby I changed include/mrbconf.h to add the following flags:

+#define SHA256_DIGEST_LENGTH 32
+#define SHA512_DIGEST_LENGTH 64
+#define MRB_STACK_EXTEND_DOUBLING 1
+#define MRB_INT64 1

I included them in that file instead of as emscripten flags because I tried too many times without good improvement using compiler flags.

The last flag is the main issue, MRuby defaults the integer value to 32 bits, that flag should force integers of 64bits.

The build logs are attached. Most of the warnings have this appearance (paraphrased):

warning: comparison of constant 9223372036854775807 with [...] is always true

The result is rather simple, the javascript file is generated but the mruby internal functions are not working, they aren't even showing any error.

What seems to be happening is that the building process is not detecting that we're using 64 bit integers?

It's using emcc 1.34.3

In beforehand, maybe this is a simple problem and I'm ignoring the solution, please take in count that any help or information that we could share will be very appreciated.

Best regards.


--
You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/Fe1Q5I_VJok/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-disc...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Daniel J. Rodríguez S.
http://sadasant.com/
logs

Daniel Rodriguez

unread,
Jan 17, 2016, 12:53:04 AM1/17/16
to emscripte...@googlegroups.com
Forbid my typo, I intended to say:

To the chasonr mruby ....

My bad. 

Floh

unread,
Jan 17, 2016, 7:06:19 AM1/17/16
to emscripten-discuss
To me this looks like there's a mixup between "64-bit integer support" and "64-bit platform". On 64-bit platforms, pointers and size_t are usually 64 bits wide. On 32-bit platforms (like emscripten), these are 32-bit, but compilers still support 64-bit integer types on 32-bit platforms.

This warning seems to suggest that the build expects size_t to be 64-bit wide, but on emscripten this is always 32-bit:

/home/daniel/.rvm/gems/ruby-2.1.5/gems/webruby-0.9.3/modules/mruby/src/string.c:176:13: warning: comparison of constant 9223372036854775807 with expression of type 'size_t' (aka 'unsigned int') is always false [-Wtautological-constant-out-of-range-compare]
    if (len >= MRB_INT_MAX) {

Cheers,
-Floh.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/Fe1Q5I_VJok/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-discuss+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Daniel Rodriguez

unread,
Jan 17, 2016, 9:14:09 PM1/17/16
to emscripte...@googlegroups.com
Floh and everyone interested,

Floh was right. I built it on a ubuntu 32bit docker machine and it worked like a charm.

Amazing, I'm very happy, I appreciate your help very much. 


Cheers,
-Floh.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/Fe1Q5I_VJok/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-disc...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Daniel J. Rodríguez S.
http://sadasant.com/

--
You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/Fe1Q5I_VJok/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-disc...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Floh

unread,
Jan 18, 2016, 4:49:53 AM1/18/16
to emscripten-discuss
That's still strange, since the host platform's bit-ness should not affect the emscripten build at all... may be you are running ./configure scripts that look at the host platform? If that's the case you should use emconfigure (but as a cmake guy I don't have experience with that).

Cheers,
-Floh.

Cheers,
-Floh.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/Fe1Q5I_VJok/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-discuss+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Daniel J. Rodríguez S.
http://sadasant.com/

--
You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/Fe1Q5I_VJok/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-discuss+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Daniel Rodriguez

unread,
Jan 18, 2016, 11:02:41 AM1/18/16
to emscripte...@googlegroups.com
Floh, sorry for telling you this but it actually didn't work.

I tested it yesterday over midnight, I was tired so I used a staging environment which has an older and working version.
I did even downloaded the javascript to diff it but apparently I did it with the wrong file, so it all looked correct.

I've been making tests again now that I got some sleep and it is not working.
Checking the build logs I actually saw the same warnings in the ubuntu 32bit docker instance.

I apologize for cheering,
if you find some time, or anyone in the forum, I would appreciate some guidance.

Best regards.


Cheers,
-Floh.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/Fe1Q5I_VJok/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-disc...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Daniel J. Rodríguez S.
http://sadasant.com/

--
You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/Fe1Q5I_VJok/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-disc...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Daniel J. Rodríguez S.
http://sadasant.com/

--
You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/Fe1Q5I_VJok/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-disc...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Floh

unread,
Jan 19, 2016, 3:33:49 AM1/19/16
to emscripten-discuss
I'd first try to unset that MRB_INT64 define. The original code might assume that sizeof(mrb_int) == sizeof(size_t) which would be wrong if the MRB_INT64 define is set on a 32-bit platform.

If that doesn't help, compile the code as native on a 32-bit platform, and start debugging :)

-Floh.

Cheers,
-Floh.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/Fe1Q5I_VJok/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-discuss+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Daniel J. Rodríguez S.
http://sadasant.com/

--
You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/Fe1Q5I_VJok/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-discuss+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Daniel J. Rodríguez S.
http://sadasant.com/

--
You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/Fe1Q5I_VJok/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-discuss+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages