Issue 4704 in v8: opcode error when building - MIPS + musl (node.js release)

172 views
Skip to first unread message

arty.net2@gmail.com via Monorail

unread,
Jan 25, 2016, 5:33:09 AM1/25/16
to v8-re...@googlegroups.com
Status: Untriaged
Owner: ----

New issue 4704 by arty.n...@gmail.com: opcode error when building - MIPS + musl (node.js release)
https://bugs.chromium.org/p/v8/issues/detail?id=4704

Hello guys,

while building the latest stable node.js tarball (v5.5.0) and one belonging to the LTS , specifically the v4.2.1 one, for MIPS BE architecture, I have bumped into this issue :

########### LOG #########

mips-openwrt-linux-musl-g++ '-DV8_TARGET_ARCH_MIPS' '-D__mips_soft_float=1' '-DENABLE_DISASSEMBLER' '-D_MIPS_ARCH_MIPS32R2' '-DFPU_MODE_FP32' -I../deps/v8 -I/home/arturo/temp/openwrt-arty/staging_dir/target-mips_34kc_musl-1.1.11/usr/include  -pthread -Wall -Wextra -Wno-
.....
 -c -o /home/arturo/temp/openwrt-arty/build_dir/target-mips_34kc_musl-1.1.11/node-v4.2.1/out/Release/obj.target/v8_libbase/deps/v8/src/base/cpu.o ../deps/v8/src/base/cpu.cc
{standard input}: Assembler messages:
{standard input}:33: Error: opcode not supported on this processor: mips32r2 (mips32r2) `ldc1 $f0,24($fp)'
{standard input}:34: Error: opcode not supported on this processor: mips32r2 (mips32r2) `mtc1 $t0,$f1'
{standard input}:35: Error: opcode not supported on this processor: mips32r2 (mips32r2) `sdc1 $f0,24($fp)'

########### LOG #########

the gcc compiler version used is the cutting-edge 5.2.0 while the embedded C library used to build the toolchain is musl. I have tried to insert the optimization "-msmartmips" (as last resort) but I get the same error anyway....any thoughts about that ? When building with gcc-4.8 I have never such kind of opcode error....

here it is my "configure" options :

--dest-cpu=mips \
    --dest-os=linux \
    --with-mips-float-abi=soft \
    --without-snapshot \
    --shared-zlib \
    --shared-openssl \
    --prefix=/usr

binutils are the latest v2.25.1 and the full optimization string (temporary) is this one :

###########

-Os -pipe -mno-branch-likely -mips32r2 -mtune=34kc -msmartmips

###########

Please consider this whole setup in fully embedded SDK (for the OpenWRT distro), so all the main dependecies are fully satisfied. It seems a lack of V8 definition in the cpu.cc file itself....

Thanks in advance.

Regards, Arturo


-- 
You received this message because:
  1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

jkummerow@chromium.org via Monorail

unread,
Jan 25, 2016, 11:00:28 AM1/25/16
to v8-re...@googlegroups.com
Updates:
	Cc: v8-mips-...@googlegroups.com

Comment #1 on issue 4704 by jkumme...@chromium.org: opcode error when building - MIPS + musl (node.js release)
https://bugs.chromium.org/p/v8/issues/detail?id=4704#c1

MIPS folks, this one's for you.

-- 
You received this message because:
  1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

ivica.bogosavljevic@imgtec.com via Monorail

unread,
Jan 25, 2016, 12:03:33 PM1/25/16
to v8-re...@googlegroups.com
Comment #2 on issue 4704 by ivica.bo...@imgtec.com: opcode error when building - MIPS + musl (node.js release)
https://bugs.chromium.org/p/v8/issues/detail?id=4704#c2

Hi Arturo,

From the information you provided, it seems that the problem is following:
* Currently there is an effort on MIPS to move away from 32-bit floating point registers to 64-bit floating point registers. To allow this change, a new FP compilation mode called FPXX is created to support same binaries being executed on both FP32 and FP64 enabled systems. You can find more information about this here: https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking

With this being said, GCC has been modified in the following way: version of gcc < 5 implicitly generate FP32 compatible code (-mfp32 flag) and versions of gcc >= 5.0 implicitly generate FPXX compatible code (code that can run in both FP32 and FP64 hardware). v8 does not yet support FPXX. In the logs you provided I don't see that either -mfp32 or -mfpxx, so guess would be that you didn't specify FP model on the command line, and this causes your compilation to fail.

To fix this, you need to force -mfp32 option to the compiler. I don't see your environment variables in the log so I cannot tell exactly what's the problem, but if you export fpu mode explicitly, this should be fed to the compiler and all things should work. You could do this in several ways, here is one: call this command before v8's make

export GYPFLAGS="-Dmips_arch_variant=r2 -Dmips_fpu_mode=fp32"

In case you are still experiencing problems, please post the whole compilation log so we can examine it and see what might be the problem.

Ivica

-- 
You received this message because:
  1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

arty.net2@gmail.com via Monorail

unread,
Jan 26, 2016, 5:26:39 AM1/26/16
to v8-re...@googlegroups.com
Comment #3 on issue 4704 by arty.n...@gmail.com: opcode error when building - MIPS + musl (node.js release)
https://bugs.chromium.org/p/v8/issues/detail?id=4704#c3

Hello Ivica,

I have tried to force the flag but nothing happened. I still keep getting the same error. Attached you will find the complete build log for node v5.5.0...

However, altough not explicitly set, the firs part of my previous log showed the requested flags as enabled :

############# CODE

mips-openwrt-linux-musl-g++ '-DV8_TARGET_ARCH_MIPS' '-D__mips_soft_float=1' '-DENABLE_DISASSEMBLER' '-D_MIPS_ARCH_MIPS32R2' '-DFPU_MODE_FP32'

##############

so, it seems that the right settings are detected anyway. Please take into consideration that at the very beginning of the log is reported an extraction of a node binary x64 tarball to embed in my sdk (to build the additional modules in second step).

it is just FYI so not to create any kind of confusion. In the meanwhile, I'll run other build and in case of success report here.

 Regards, Arturo



Attachments:
	node_550_build.txt  884 KB

-- 
You received this message because:
  1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

arty.net2@gmail.com via Monorail

unread,
Jan 26, 2016, 6:47:43 AM1/26/16
to v8-re...@googlegroups.com
Comment #4 on issue 4704 by arty.n...@gmail.com: opcode error when building - MIPS + musl (node.js release)
https://bugs.chromium.org/p/v8/issues/detail?id=4704#c4

turns out that switching back to an older version of binutils did the trick ! 

https://releases.linaro.org/14.09/components/toolchain/binutils-linaro/

I have now successfully built again the sources without any particular CFLAGS or CPP FLAGS. I had previously built my embedded toolchain with a plain version of binutils (v2.25.1) but for many devices like mine, the right choice is to stick with the linaro patched ones....

now is time to run some test with the freshly generated EXEs...

  Arturo 

-- 
You received this message because:
  1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

ivica.bogosavljevic@imgtec.com via Monorail

unread,
Jan 26, 2016, 7:36:55 AM1/26/16
to v8-re...@googlegroups.com
Comment #5 on issue 4704 by ivica.bo...@imgtec.com: opcode error when building - MIPS + musl (node.js release)
https://bugs.chromium.org/p/v8/issues/detail?id=4704#c5

Hi Arturo,

There is no problem with -mfp32 flag in your configuration, this flag seems to be correctly forwarded to the compiler.

I was surprised to see -msoft-float passed to the compiler since soft-float support was dropped from v8 in 2013. V8 now requires either a FPU or a kernel emulation of FPU. Soft-float support would certainly explain the errors you are getting, since v8 uses hand written assembly to detect presence of 64-bit FPU in __detect_fp64_mode (ldc1, mtc1 and sdc1 are floating point instructions) in cpu.cc.

Is there any specific reason why you want to compile with soft-float support? If not, could you please try to compile your code with --with-mips-float-abi=hard and see if this solves your issue.

If you still need soft-float support, you could comment the code in __detect_fp64_mode and have it return false (since you don't have FPU). But I strongly recommend against this because I am not sure how v8 would behave since it officially does not support soft floating point.

Ivica


-- 
You received this message because:
  1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

arty.net2@gmail.com via Monorail

unread,
Jan 26, 2016, 10:02:49 AM1/26/16
to v8-re...@googlegroups.com
Comment #6 on issue 4704 by arty.n...@gmail.com: opcode error when building - MIPS + musl (node.js release)
https://bugs.chromium.org/p/v8/issues/detail?id=4704#c6

Hi Ivica,

my board runs an Atheros 9331 cpu which hasn't a FPU on board and for this very reason, as you have just told, I have to :

+enable FPU emulation when building my image (and overloading the cpu)
+force soft-float support in the configure also because my toolchain will warn me with an error that the hard-float mode is not allowed for my device.

I have come up with a simple patch, keeping to false (as default) the value of the "is_fp64_mode_" variable, please double-check it :


--- cpu.cc  2016-01-21 02:08:19.000000000 +0100
+++ cpu-new-2.cc    2016-01-26 15:55:16.000000000 +0100
@@ -586,7 +586,7 @@
   has_fpu_ = HasListItem(cpu_model, "FPU");
   delete[] cpu_model;
 #ifdef V8_HOST_ARCH_MIPS
-  is_fp64_mode_ = __detect_fp64_mode();
+  is_fp64_mode_ = 0;
   architecture_ = __detect_mips_arch_revision();
 #endif

I think that just this should simply do the trick. 

You will find attached another patch abruptely deleting all the fp64 entries in the code. please let me know which one is the right one to apply so to run some tests.

Best, ARturo



Attachments:
	fp64.patch  1.2 KB

-- 
You received this message because:
  1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

ivica.bogosavljevic@imgtec.com via Monorail

unread,
Jan 27, 2016, 5:05:03 AM1/27/16
to v8-re...@googlegroups.com
Comment #7 on issue 4704 by ivica.bo...@imgtec.com: opcode error when building - MIPS + musl (node.js release)
https://bugs.chromium.org/p/v8/issues/detail?id=4704#c7

Hi Arturo,

So your problem is definitely with soft-float support. 

Your patch fix the issue in the sense that the code compiles, but again v8 recommends against it, here are the reasons why:

* v8 does not have an official soft-float support. This thing is not tested and we don't know if it works correctly in all scenarios. You might experience some problems which nobody can help you with

* We did some performance comparison between soft-float and hard-float on MIPS using google octane benchsuite. Soft-float is on average 5% faster that hard-float on a board without HW FPU. Is this performance difference enough to justify using soft-float?

* Even if v8 is compiled with soft-float, this setting only applies to V8 C code. Don't forget that v8 is a JIT compiler and most of the code executed is v8 JIT code, not v8 C code. v8 JIT code DOES generate FP instructions if they are needed, regardless of compiler settings.


Your patch fixes the problem in correct way, but for the reasons above, I recommend strongly to move to hard-float

-- 
You received this message because:
  1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

hablich@chromium.org via Monorail

unread,
Feb 2, 2016, 2:54:06 PM2/2/16
to v8-re...@googlegroups.com
Updates:
	Status: WontFix

Comment #8 on issue 4704 by habl...@chromium.org: opcode error when building - MIPS + musl (node.js release)
https://bugs.chromium.org/p/v8/issues/detail?id=4704#c8

Closing this issue as it evolved into a tech support post. Feel free to re-open or continue communication via the issue though :-).

-- 
You received this message because:
  1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings
Reply all
Reply to author
Forward
0 new messages