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

Math for embed devices #87

Closed
seanshpark opened this issue May 21, 2015 · 10 comments
Closed

Math for embed devices #87

seanshpark opened this issue May 21, 2015 · 10 comments
Labels
bug Undesired behaviour discussion Ongoing discussion
Milestone

Comments

@seanshpark
Copy link
Contributor

NuttX doesn't provide libm and have link problem.
fabs, acos, asin, atan, atan2, ceil, cos, exp, floor, log, pow, sin, sqrt and tan are undefined.
I'm posting this issue for discussion.

@LaszloLango LaszloLango added the discussion Ongoing discussion label May 21, 2015
@egavrin egavrin added this to the ECMA builtins milestone May 21, 2015
@LaszloLango
Copy link
Contributor

CC: @tczene, @kkristof

@egavrin egavrin added the bug Undesired behaviour label May 21, 2015
@egavrin
Copy link
Contributor

egavrin commented May 21, 2015

It may not work on stm32, because it only supports single precision floating point format, not double. It seems that the DOUBLE_TO_ECMA_NUMBER_T macro should be implemented manually as low-level function. #33

@kkristof
Copy link
Contributor

Hi, I have run the make build_all_nuttx which didn't show any error. We don't have any stm32 board so we can't try the binary. Could you give us more information like the make.log and the target which you can't build?

@galpeter
Copy link
Contributor

Hi, I think the reason for the link failure is that jerry uses the fdlibm (which is in the third-party dir) and you don't pass as a library when linking the final target. Also note that the fdlibm is a C project and not a C++ one, I saw that you only use CXX_FLAGS in the toolchain files in iotjs.

@seanshpark
Copy link
Contributor Author

Description for this issue was too short. Forgive me for insufficient explanation.
IoT.js for nuttx build orders are explain in https://github.com/Samsung/iotjs/wiki/Build-for-NuttX page.
You'll get the errors with it as fdlibm is not linked.

As there is a patch for this problem, #91, I've done with below steps in manual

  1. build iotjs
(cd to iotjs)
./tools/build.py --buildtype=release \
--target-arch=arm --target-os=nuttx \
--nuttx-home=/home/maxwell/harmony/nuttx/nuttx \
--buildlib --make-flags=-j1
  1. build jerry with patch
(in iotjs folder)
cd deps/jerry
git checkout master
git pull
git checkout -b tczene-fix-math master
git pull git@github.com:tczene/jerryscript.git fix-math
LTO=OFF make release.nuttx -j4
cp build/obj-VALGRIND-OFF-LTO-OFF/nuttx/third-party/fdlibm/librelease.jerry-fdlibm.third_party.lib.a \
../../build/arm-nuttx/release/libs/libfdlibm.a
  1. copy libs to nuttx
(back in iotjs folder)
cp build/arm-nuttx/release/libs/libjerrycore.a ../nuttx/nuttx/lib/libjerry.a
cp build/arm-nuttx/release/libs/libuv.a ../nuttx/nuttx/lib
cp build/arm-nuttx/release/iotjs/liblibiotjs.a ../nuttx/nuttx/lib/libiotjs.a
cp build/arm-nuttx/release/libs/libfdlibm.a ../nuttx/nuttx/lib/libfdlibm.a
  1. patch nuttx to apply libfdlibm.a
diff --git a/nuttx/FlatLibs.mk b/nuttx/FlatLibs.mk
index 458925b..f674495 100644
--- a/nuttx/FlatLibs.mk
+++ b/nuttx/FlatLibs.mk
@@ -115,6 +115,7 @@ endif

 ifeq ($(CONFIG_LIBJERRY),y)
 NUTTXLIBS += lib$(DELIM)libjerry$(LIBEXT)
+NUTTXLIBS += lib$(DELIM)libfdlibm$(LIBEXT)
 endif
  1. build nuttx
(cd to nuttx where .config file exist)
make

But there are VFP issues.

LD: nuttx
arm-none-eabi-ld: error: .../harmony/nuttx/nuttx/nuttx uses VFP register arguments, .../harmony/nuttx/nuttx/lib/libfdlibm.a(w_log.c.obj) does not
arm-none-eabi-ld: failed to merge target specific data of file .../harmony/nuttx/nuttx/lib/libfdlibm.a(w_log.c.obj)
...

@galpeter
Copy link
Contributor

Hi @seanshpark,
This VFP linking issue is caused by the following: In iotjs the cmake config files only sets the CMAKE_CXX_FLAGS but the fdlibm is a C project, thus it will use CMAKE_C_FLAGS which are not set by the iotjs config files. I've created a simple patch which also sets the CMAKE_C_FLAGS with the required target specific options, should I create a pull request for it or just share it as a secret gist?

@galpeter
Copy link
Contributor

@seanshpark could you try this patch? https://gist.github.com/galpeter/4383e5d2a1c78c9a777d
This should set the required flags for the fdlibm and then there should be no link error related to the VFP registers.

@seanshpark
Copy link
Contributor Author

@galpeter , thank you for the patch. please make a pull request to iotjs.
p.s. current iotjs build does not generate fdlibm so I may have to change the build script. manual building in deps/jerry folder still has VFP register arguments problem with nuttx.

@galpeter
Copy link
Contributor

For me after applying the patch the VFP errors were gone, I'll do the pull request.

@seanshpark
Copy link
Contributor Author

It's working ok for me too with jerryscript-project/iotjs#52. Thank you.

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

No branches or pull requests

5 participants