General NAS-Central Forums

Welcome to the NAS community
It is currently Sat Dec 16, 2017 5:23 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Thu Nov 02, 2017 10:53 pm 
Offline
User avatar

Joined: Mon Dec 21, 2015 7:21 pm
Posts: 605
Hi,

I wanted to compile a source which uses feclearexcept and fetestexcept. Unfortunately the compilation ended in an error with undefined reference... :(

After that, I found this code for testing somewhere on the internet:

Code:
#include <stdio.h>
#include <math.h>
#include <fenv.h>
#pragma STDC FENV_ACCESS on

int main ()
{
  feclearexcept (FE_ALL_EXCEPT);
  sqrt(-1);
  if (fetestexcept(FE_INVALID)) printf ("sqrt(-1) raises FE_INVALID\n");
  return 0;
}


And tried to build a binary:

Code:
root@NSA320S:~# gcc -o /tmp/test /tmp/test.c -lm
/tmp/ccKyBcNO.o: In function `main':
test.c:(.text+0xc): undefined reference to `feclearexcept'
test.c:(.text+0x20): undefined reference to `fetestexcept'
collect2: error: ld returned 1 exit status


Yeah, it looks like uClibc isn't supports the fe*except, but just to be definitely sure, I ran this command too:

Code:
root@NSA320S:~# strings /ffp/lib/libm.so.0 | grep -E ^fe
root@NSA320S:~#


This is really strange, because the package, that I tried to compile could be a lifesaver. Is there an easy way to implement this into uClibc somehow @barmalej2?

Thanks

_________________
Thanks nas-central the lot of help! :)


Top
 Profile  
 
PostPosted: Fri Nov 03, 2017 10:05 am 
Offline

Joined: Sun Apr 29, 2012 5:24 pm
Posts: 2314
MrDini wrote:
Is there an easy way to implement this into uClibc somehow @barmalej2?
Unfortunately not. From uClibc config:

Quote:
UCLIBC_HAS_FENV
bool "Enable C99 Floating-point environment"
depends on UCLIBC_HAS_FLOATS
help
If you want the uClibc math library to contain the C99 floating
point environment, rounding and exception handling functions then
say Y here.

NOTE: Supported architectures currently include:
i386

This feature was enabled since first ffp uClibc release, thus is still confusing when compiling programs (header present with defined functions, but libmath doesn't has them for arm arch). Will be disabled in next release. I'm planning to upload full updated ffp toolchain in next weekend.

MrDini wrote:
This is really strange, because the package, that I tried to compile could be a lifesaver.

Give me more info. Will see, what I can do.


Top
 Profile  
 
PostPosted: Fri Nov 03, 2017 1:01 pm 
Offline
User avatar

Joined: Mon Dec 21, 2015 7:21 pm
Posts: 605
Thanks. Hmmm, a new toolchain... It sounds great. :)

I wanted to compile the sox source in order to convert files directly on my NAS.

But with an sshfs mount and using an x64 PC, I could convert all of my files. So I have a half solution. :)

Will take a look on the configure script, maybe there is an fenv check somewhere (and force disable it with a patch in this case).

_________________
Thanks nas-central the lot of help! :)


Top
 Profile  
 
PostPosted: Fri Nov 03, 2017 7:21 pm 
Offline

Joined: Sun Apr 29, 2012 5:24 pm
Posts: 2314
SoX source code contains a lot hardcoded paths for /usr prefix. You need to adjust to /ffp in hard way. Basic instructions for SoX compilation:
Quote:
# Adjust SoX for uClibc first
/ffp/bin/wget -Nnv 'https://git.buildroot.net/buildroot/plain/package/sox/0001-uclibc.patch'
patch -p1 < 0001-uclibc.patch
# Fix SoX bug: https://sourceforge.net/p/sox/mailman/message/33499897/
/ffp/bin/wget -nv 'https://bogomips.org/sox.git/patch/?id=b4097a995ca152f3059faa1dd05f684ac0217737' -O sox-dynamic.patch
patch -p1 < sox-dynamic.patch
# Adapt prefix for /ffp
grep -lrZ '/usr/local' . | xargs -r0 sed -i 's|/usr/local|/ffp|g'
grep -lrZ '/usr' . | xargs -r0 sed -i 's|/usr|/ffp|g'
find . -iname "config.*" -type f -exec sed -i -r 's/^#! ?\/bin\/sh/#!\/ffp\/bin\/sh/' {} +
find . -iname "config.*" -type f -exec sed -i -r 's/^#! ?\/bin\/bash/#!\/ffp\/bin\/bash/' {} +
find . -iname "config.*" -type f -exec sed -i -r 's/^#! ?\/usr\/bin\/env/#!\/ffp\/bin\/env/' {} +
find . -iname "configure" -type f -exec sed -i -r 's/^#! ?\/bin\/sh/#!\/ffp\/bin\/sh/' {} +
find . -iname "configure" -type f -exec sed -i -r 's/^#! ?\/bin\/bash/#!\/ffp\/bin\/bash/' {} +
find . -iname "configure" -type f -exec sed -i -r 's/^#! ?\/usr\/bin\/env/#!\/ffp\/bin\/env/' {} +
find . -executable -type f -exec sed -i -r 's/^#! ?\/bin\/sh/#!\/ffp\/bin\/sh/' {} +
find . -executable -type f -exec sed -i -r 's/^#! ?\/bin\/bash/#!\/ffp\/bin\/bash/' {} +
find . -executable -type f -exec sed -i -r 's/^#! ?\/usr\/bin\/env/#!\/ffp\/bin\/env/' {} +
find . -iname "*.py*" -type f -exec sed -i -r 's/^#! ?\/usr\/bin\/python/#!\/ffp\/bin\/python/' {} +
find . -iname "*.py*" -type f -exec sed -i -r 's/^#! ?\/usr\/bin\/env/#!\/ffp\/bin\/env/' {} +
find . -iname "*.py*" -type f -exec sed -i -r 's/^#! ?\/bin\/python/#!\/ffp\/bin\/python/' {} +
find . -iname "*.py*" -type f -exec sed -i -r 's/^#! ?\/bin\/env/#!\/ffp\/bin\/env/' {} +
find . -iname "*.pl*" -type f -exec sed -i -r 's/^#! ?\/usr\/bin\/perl/#!\/ffp\/bin\/perl/' {} +
find . -iname "*.pl*" -type f -exec sed -i -r 's/^#! ?\/usr\/bin\/env/#!\/ffp\/bin\/env/' {} +
find . -iname "*.pl*" -type f -exec sed -i -r 's/^#! ?\/bin\/perl/#!\/ffp\/bin\/perl/' {} +
find . -iname "*.pl*" -type f -exec sed -i -r 's/^#! ?\/bin\/env/#!\/ffp\/bin\/env/' {} +
# Reconfigure source code due to changes
autoreconf -fi
# And you are ready to go
ac_cv_header_fenv_h=no ./configure --prefix=/ffp --with-sysroot=/ffp --with-dyn-default --with-gsm --with-lpc10 --with-distro='Fonz Fun Plug'
make


Use can skip options --with-gsm --with-lpc10, if you have separate ffp packages of these. Otherwise they are required for static linking bundled in tree gsm and lpc10 sources, when --with-dyn-default (forces to link dynamically with ffp provided libraries) option is used.


Top
 Profile  
 
PostPosted: Fri Nov 03, 2017 11:14 pm 
Offline
User avatar

Joined: Mon Dec 21, 2015 7:21 pm
Posts: 605
Thanks. But as I noticed, if I remove the --with-dyn-default flag, it compiles smoothely. :)

And now, I have a working SoX package. :)

_________________
Thanks nas-central the lot of help! :)


Top
 Profile  
 
PostPosted: Sat Nov 04, 2017 8:22 am 
Offline

Joined: Sun Apr 29, 2012 5:24 pm
Posts: 2314
Are you saying that you can't compile, when options "--with-dyn-default --with-gsm --with-lpc10" is used?
Of course, you can build without "--with-dyn-default", but in that case you will get static build, which is not preferred as shared, using on low resources NAS.


Top
 Profile  
 
PostPosted: Sat Nov 04, 2017 9:08 am 
Offline
User avatar

Joined: Mon Dec 21, 2015 7:21 pm
Posts: 605
Yes. I moved the fenv.h first to a temporary path and reconfigured it. After that I ran the automake, but after a while, it showd up an undefined reference to 'lsx_error'.

And I found this patch, but I didn't have time to try this out, because I needed the binary ASAP, So I just removed the --with-dyn-default flag, and it compiled first without any issues. :) But I am going to recompile the source again with the patch applied.

PS: I didn't have to hardcode any pathes. It just worked. :D

Edit: Oh, I see, You also used this patch.

_________________
Thanks nas-central the lot of help! :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 51 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group