basho / erlang_js

A linked-in driver for Erlang to Mozilla's Spidermonkey Javascript runtime.
Apache License 2.0
238 stars 88 forks source link

Add patch to js-1.8.0 which fixes inline compilation error with gcc 4.7+ #37

Closed dantealiegri closed 11 years ago

dantealiegri commented 11 years ago

Hey guys, this enables erlang_js to be compiled with gcc 4.7+, as gcc now wants inline on a function definition when always_inline is specified.

Vagabond commented 11 years ago

I can confirm that this does not harm compilation on Arch linux with gcc 4.8. However, my version of GCC did not need this patch to be able to compile erlang_js.

cmeiklejohn commented 11 years ago

@dantealiegri Can you provide the platform where this error is reproducible?

dantealiegri commented 11 years ago

@cmeiklejohn : it's on a linode machine running Fedora 17.

[dante@li549-157 ~]$ gcc --version gcc (GCC) 4.7.2 20120921 (Red Hat 4.7.2-2)

[dante@li549-157 ~]$ rpm -qa gcc gcc-4.7.2-2.fc17.i686

cmeiklejohn commented 11 years ago

I've just built a Fedora 17 VM and couldn't reproduce this using gcc-4.7.2-2.fc17.x86_64.

dantealiegri commented 11 years ago

Well that is exciting and awkward.

gcc -o Linux_All_OPT.OBJ/jslock.o -c -Wall -Wno-format -MMD -Os -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DHAVE_VA_COPY -DVA_COPY=va_copy -DPIC -fPIC -UDEBUG -DNDEBUG -UDEBUG_dante -DJS_THREADSAFE -DEDITLINE -ILinux_All_OPT.OBJ -I/home/dante/riak/riak-1.4.0/deps/erlang_js/c_src/system/include/nspr -DHAVE_VA_COPY -DVA_COPY=va_copy jslock.c jslock.c: In function âClaimTitleâ: jslock.c:389:14: warning: variable âstatâ set but not used [-Wunused-but-set-variable] jslock.c: In function âjs_SuspendThreadâ: jslock.c:905:14: warning: variable âstatâ set but not used [-Wunused-but-set-variable] jslock.c: In function âjs_ResumeThreadâ: jslock.c:935:14: warning: variable âstatâ set but not used [-Wunused-but-set-variable] jslock.c: At top level: jslock.c:997:1: warning: always_inline function might not be inlinable [-Wattributes] jslock.c:983:1: warning: always_inline function might not be inlinable [-Wattributes] jslock.c:130:1: warning: always_inline function might not be inlinable [-Wattributes] jslock.c: In function âjs_LockTitleâ: jslock.c:983:1: error: inlining failed in call to always_inline âjs_Lockâ: function body can be overwritten at link time jslock.c:1055:9: error: called from here jslock.c: In function âjs_UnlockTitleâ: jslock.c:997:1: error: inlining failed in call to always_inline âjs_Unlockâ: function body can be overwritten at link time jslock.c:1104:9: error: called from here jslock.c: In function âjs_TransferTitleâ: jslock.c:997:1: error: inlining failed in call to always_inline âjs_Unlockâ: function body can be overwritten at link time jslock.c:1178:5: error: called from here

Is what I am getting.

cmeiklejohn commented 11 years ago

Just tried again, no dice.

[root@feltmad erlang_js]# rpm -qa gcc
gcc-4.7.2-2.fc17.x86_64
[root@feltmad erlang_js]#  gcc --version
gcc (GCC) 4.7.2 20120921 (Red Hat 4.7.2-2)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Are you building Riak or standalone erlang_js?

cmeiklejohn commented 11 years ago

I just realized you are running 32-bit and not 64-bit. I rebuilt my box and I'm still unable to reproduce this:

[root@feltmad erlang_js]# uname -a
Linux feltmad 3.3.7-1.fc17.i686.PAE #1 SMP Mon May 21 22:42:05 UTC 2012 i686 i686 i386 GNU/Linux
[root@feltmad erlang_js]# rpm -qa gcc
gcc-4.7.2-2.fc17.i686
[root@feltmad erlang_js]# gcc --version
gcc (GCC) 4.7.2 20120921 (Red Hat 4.7.2-2)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@feltmad erlang_js]#

Could there be anything else unusual about your configuration? (are you building with any non-standard CFLAGS?)

dantealiegri commented 11 years ago

I'm building as part of riak 1.4. I'm going to avoid the pure insanity of some difference between the rpms, and I'm mostly sure this can't involve headers. The only other thing I can think of is that the flags to the compiler are different. Can you show me what the compilation line for that file is, on your working version?

cmeiklejohn commented 11 years ago

gcc -o Linux_All_OPT.OBJ/jslock.o -c -Wall -Wno-format -MMD -DGCC_OPT_BUG -Os -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -UDEBUG -DNDEBUG -UDEBUG_root -DJS_THREADSAFE -DEDITLINE -ILinux_All_OPT.OBJ -I/root/erlang_js/c_src/system/include/nspr -DHAVE_VA_COPY -DVA_COPY=va_copy jslock.c

cmeiklejohn commented 11 years ago

It appears the major differences here are related to -DPIC -fPIC. I've manually changed my CFLAGS to include these switches and I was able to reproduce the problem.

cmeiklejohn commented 11 years ago

However, using your branch I still run into the following compilation issue:

jslock.c: At top level:
jslock.c:997:1: warning: always_inline function might not be inlinable [-Wattributes]
jslock.c:983:1: warning: always_inline function might not be inlinable [-Wattributes]
jslock.c:130:1: warning: always_inline function might not be inlinable [-Wattributes]
jslock.c: In function ‘js_LockTitle’:
jslock.c:983:1: error: inlining failed in call to always_inline ‘js_Lock’: function body can be overwritten at link time
jslock.c:1055:9: error: called from here
jslock.c: In function ‘js_UnlockTitle’:
jslock.c:997:1: error: inlining failed in call to always_inline ‘js_Unlock’: function body can be overwritten at link time
jslock.c:1104:9: error: called from here
jslock.c: In function ‘js_TransferTitle’:
jslock.c:997:1: error: inlining failed in call to always_inline ‘js_Unlock’: function body can be overwritten at link time
jslock.c:1178:5: error: called from here
make[4]: *** [Linux_All_OPT.OBJ/jslock.o] Error 1
make[4]: Leaving directory `/root/erlang_js_fixed/c_src/js/src'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/root/erlang_js_fixed/c_src/js/src'
make[2]: *** [/root/erlang_js_fixed/c_src/system/lib/libjs.a] Error 2
make[2]: Leaving directory `/root/erlang_js_fixed/c_src'
make[1]: *** [c_src] Error 2
make[1]: Leaving directory `/root/erlang_js_fixed'
ERROR: Command [compile] failed!
make: *** [all] Error 1
dantealiegri commented 11 years ago

is jstypes.h modified when that compile fails? I think configure needs to be re-run after the patch is applied.

cmeiklejohn commented 11 years ago

I've confirmed that the patch is applied, and the build still fails.

dantealiegri commented 11 years ago

gotcha. If you change

define JS_INLINE attribute((always_inline)) inline

to

error "Set Inline"

do you get an error on compile?

cmeiklejohn commented 11 years ago

Actually, I found the problem, the patch wasn't applying because my test VM didn't have 'patch'. Derp. Otherwise, this looks good to me, so I'm going to :+1: it.

cmeiklejohn commented 11 years ago

Thanks!