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

How to build node.js for ARM core without hardware FPU. #15

Closed
rench opened this issue Jun 30, 2017 · 22 comments
Closed

How to build node.js for ARM core without hardware FPU. #15

rench opened this issue Jun 30, 2017 · 22 comments

Comments

@rench
Copy link
Contributor

rench commented Jun 30, 2017

hello, i want to know if there any way to modify node source code or kernel to support soft vfp3 on bcm4709 ?

ar9344 can enable MIPS FPU Emulator for soft PFU?
can bcm53xx do this?

@nxhack
Copy link
Owner

nxhack commented Jul 3, 2017

Hi @rench

LEDE 17.01-head / linux-4.4.74

config FPE_NWFPE
        bool "NWFPE math emulation"
        depends on (!AEABI || OABI_COMPAT) && !THUMB2_KERNEL
        ---help---
          Say Y to include the NWFPE floating point emulator in the kernel.
          This is necessary to run most binaries. Linux does not currently
          support floating point hardware so you need to say Y here even if
          your machine has an FPA or floating point co-processor podule.

          You may say N here if you are going to load the Acorn FPEmulator
          early in the bootup.

To forcibly enable it...
I don't know how bad effects will come out.

  • bcm4709 and bcm53xx
    CONFIG_TARGET_BOARD="bcm53xx"
    make kernel_menuconfig
    -> Select Kernel Features
    ---> Unselect Use the ARM EABI to compile the kernel
    (back top)
    -> Select Floating point emulation
    ---> Select NWFPE math emulation

  • ar9344
    CONFIG_TARGET_BOARD="ar71xx"
    make kernel_menuconfig
    -> Select Kernel type
    ---> Select MIPS FPU Emulator

@rench
Copy link
Contributor Author

rench commented Jul 4, 2017

yesterday , i found this way.
i try to enable aeabi and oabi_compat , it won't effect.
i will try disable aeabi.

@nxhack
Copy link
Owner

nxhack commented Jul 4, 2017

i try to enable aeabi and oabi_compat , it won't effect.

Hmm...
What happens if you enable "VFP-format floating point maths"?

-> Select Floating point emulation
---> Select NWFPE math emulation
---> Select VFP-format floating point maths

@rench
Copy link
Contributor Author

rench commented Jul 4, 2017

Unfortunately, I disabled aeabi, the results of the router can not start.
if you enable "VFP-format floating point maths",
when node it echo Illegal instruction too.

i found some hard code in toolchains/gcc/common.mk

ifneq ($(CONFIG_SOFT_FLOAT),y)
  ifeq ($(CONFIG_arm),y)
    GCC_CONFIGURE = \
		--with-float=hard
  endif
endif

do this trigger Illegal instruction ?

@nxhack
Copy link
Owner

nxhack commented Jul 4, 2017

It is not caused by the float instruction generated by gcc. It is a problem that the float instruction generated by the V8 JIT compiler. So hardware FPU or kernel FPU emulation is required.

Unfortunately, it seems better to give up using node on ARM without FPU.

@rench
Copy link
Contributor Author

rench commented Jul 4, 2017

sad.i have 2 routers with bcm4709.

but how can MIPS FPU Emulator work good?
i see node/Makefile use --with-arm-float-abi=soft
but when i run node --v8-options in router, it echo softfp

i search some docs.

1.compile application use -mfloat-abi=soft, so how to pass this parameter to compile node
2.compile application use -mfpu=fpa -mfloat-abi=softfp/hard,but must enable FPE_NWFPE

how to pass this parameters to compile node??

@nxhack
Copy link
Owner

nxhack commented Jul 4, 2017

but how can MIPS FPU Emulator work good?

The reason is simple: The fpu emulator of MIPS work well, the fpu emulator of ARM does not work well.

i see node/Makefile use --with-arm-float-abi=soft
but when i run node --v8-options in router, i echo softfp

As the last challenge...

kernel : AEABI=on, OABI_COMPAT=off, NWFPE=on, VFP=on
node/Makefile: $(if $(CONFIG_SOFT_FLOAT), --with-arm-float-abi=softfp, \

Please tell me the result.

@rench
Copy link
Contributor Author

rench commented Jul 4, 2017

NWFPE depends on AEABI=off || OABI_COMPAT=on
i will try tonight,then tell you result。

@nxhack
Copy link
Owner

nxhack commented Jul 4, 2017

NWFPE depends on AEABI=off || OABI_COMPAT=on

sorry.
kernel : AEABI=on, OABI_COMPAT=on, NWFPE=on, VFP=on
NWFPE can enable.

@rench
Copy link
Contributor Author

rench commented Jul 4, 2017

i will build

  1. AEABI=on, OABI_COMPAT=on, NWFPE=on, VFP=on --with-arm-float-abi=softfp
  2. AEABI=on, OABI_COMPAT=on, NWFPE=on, VFP=off --with-arm-float-abi=softfp

how to pass -mfpu=fpa to compile node?

@nxhack
Copy link
Owner

nxhack commented Jul 4, 2017

TARGET_CFLAGS =-mfpu=fpa

but get

arm-openwrt-linux-muslgnueabi-g  : error: unrecognized argument in option '-mfpu=fpa'
arm-openwrt-linux-muslgnueabi-g  : note: valid arguments to '-mfpu=' are: crypto-neon-fp-armv8 fp-armv8 fpv4-sp-d16 fpv5-d16 fpv5-sp-d16 neon neon-fp-armv8 neon-fp16 neon-vfpv4 vfp vfp3 vfpv3 vfpv3-d16 vfpv3-d16-fp16 vfpv3-fp16 vfpv3xd vfpv3xd-fp16 vfpv4 vfpv4-d16

@rench Let's close this issue.

@rench
Copy link
Contributor Author

rench commented Jul 4, 2017

Do you have any other communication tools?
There are problems we can discuss together.

@nxhack
Copy link
Owner

nxhack commented Jul 4, 2017

OK Let's keep this thread because open discussion is desirable.

and AGAIN.

It is not caused by the float instruction generated by gcc. It is a problem that the float instruction generated by the V8 JIT compiler. So hardware FPU or kernel FPU emulation is required.

Unfortunately, it seems better to give up using node on ARM without FPU.

"nodejs/node/issues/7343" It is as you read.

@rench
Copy link
Contributor Author

rench commented Jul 4, 2017

yes i have read that issue before.
i try to search --with-arm-float-abi parameter in google, but nothing to be show.

I wonder if this parameter really works?

@nxhack
Copy link
Owner

nxhack commented Jul 4, 2017

it is node.js configure parameter.

https://github.com/nodejs/node/blob/v6.x/configure#L295

@rench
Copy link
Contributor Author

rench commented Jul 4, 2017

it does not work.
i think i have wrong step.
the different choice build the same byte trx file.
three trx file has the same bytes.

@rench
Copy link
Contributor Author

rench commented Jul 4, 2017

  1. the fpu emulator of ARM does not work well.
  2. node v8 always use vfp3 and softfp

solve it by:

  • try to make ARM's fpu emulator work well
  • try to make node v8 soft-float.

below section is v8-options that build node with soft/softfp.

root@LEDE:~# ./node --v8-options
target arm v7 vfp3-d16 softfp
ARMv8=0 ARMv7=1 VFP3=1 VFP32DREGS=0 NEON=0 SUDIV=0 MLS=1UNALIGNED_ACCESSES=1 MOVW_MOVT_IMMEDIATE_LOADS=0 COHERENT_CACHE=0 USE_EABI_HARDFLOAT=0

@nxhack nxhack changed the title i come again! How to build node.js for ARM core without hardware FPU. Jul 4, 2017
@nxhack
Copy link
Owner

nxhack commented Jul 5, 2017

hmm

root@LEDE:~# ./node --v8-options
target arm v7 vfp3-d16 softfp

What if we set node.js configure "--with-arm-fpu=vfp" ?

@rench
Copy link
Contributor Author

rench commented Jul 5, 2017

i have test it.but no help.
i think the makefile config is set to build node but not to v8.
node work well because if i run node -v,print v6.11.0.
if i run other cmd,node will invoke v8,so error happen.

if there some config can pass to build v8?

or make FPE work well?

i have no friend know lede,i have no idear now……

@rench
Copy link
Contributor Author

rench commented Jul 5, 2017

https://bugs.chromium.org/p/v8/issues/detail?id=4704

* 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.

after read that, i think the only way is to make arm NWFPE work well.

@rench
Copy link
Contributor Author

rench commented Jul 5, 2017

Found that the latest kernel does not exist / arm / arm / fastfpe directory, and nwfpe EABI should also be outdated: the algorithm for FPA, EABI support VFP should not be properly supported.

working and searching...

@rench
Copy link
Contributor Author

rench commented Jul 5, 2017

@nxhack nxhack closed this as completed Feb 14, 2018
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

2 participants