Discussion:
[OpenRISC] NewLIB and trigonometric functions
BAndViG
2014-09-21 18:55:41 UTC
Permalink
Hello all.
I'm trying to port 'whetstone' FPU benchmark. I've found that I couldn't
compile the ported result due to or1k-elf-gcc isn't able to find references
for trigonometric functions. So, I wrote the simple program:

/* start of fsin.c */
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

int main(void)
{
float x = 3.14159 / 4.0;
printf("\n x=%f y=%f",x,sin(x));
return 0;
}
/* end of fsin.c */

and I run compilation with the following command:

or1k-elf-gcc -mhard-mul -mhard-div -msoft-float -mboard=atlys fsin.c -o
fsin.elf

I received the following error messages:

/tmp/ccChxUjX.o: In function `main':
fsin.c:(.text+0x48): undefined reference to `sin'
collect2: error: ld returned 1 exit status

I tried to add -lm option (as I found trigonometric names in
/opt/or1k-toolchain/or1k-elf/lib/soft-float/libm.a), but the result was the
same.

So my question is how to use trigonometric functions in or1k newlib tool
chain?

WBR
Andrey
Stefan Kristiansson
2014-09-22 02:47:37 UTC
Permalink
Post by BAndViG
Hello all.
I'm trying to port 'whetstone' FPU benchmark. I've found that I couldn't
compile the ported result due to or1k-elf-gcc isn't able to find references
/* start of fsin.c */
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main(void)
{
float x = 3.14159 / 4.0;
printf("\n x=%f y=%f",x,sin(x));
return 0;
}
/* end of fsin.c */
or1k-elf-gcc -mhard-mul -mhard-div -msoft-float -mboard=atlys fsin.c -o
fsin.elf
fsin.c:(.text+0x48): undefined reference to `sin'
collect2: error: ld returned 1 exit status
I tried to add -lm option (as I found trigonometric names in
/opt/or1k-toolchain/or1k-elf/lib/soft-float/libm.a), but the result was the
same.
So my question is how to use trigonometric functions in or1k newlib tool
chain?
This works fine for me:
or1k-elf-gcc -mhard-mul -mhard-div -msoft-float -mboard=atlys fsin.c
-lm -o fsin.elf

Stefan
BAndViG
2014-09-22 17:57:35 UTC
Permalink
Thanks, Stefan.
As I'm not very familiar with GNU tools I did a mistake. I placed -lm option
BEFORE source list. With your command line it works fine for me too (by the
way I'm working under Cygwin64).

-----Исходное сообщение-----
From: Stefan Kristiansson
Sent: Monday, September 22, 2014 6:47 AM
To: BAndViG
Cc: openrisc
Subject: Re: [OpenRISC] NewLIB and trigonometric functions

....
This works fine for me:
or1k-elf-gcc -mhard-mul -mhard-div -msoft-float -mboard=atlys fsin.c
-lm -o fsin.elf

Stefan
Olof Kindgren
2014-09-23 05:52:37 UTC
Permalink
Post by BAndViG
Thanks, Stefan.
As I'm not very familiar with GNU tools I did a mistake. I placed -lm option
BEFORE source list. With your command line it works fine for me too (by the
way I'm working under Cygwin64).
-----Исходное сообщение----- From: Stefan Kristiansson
Sent: Monday, September 22, 2014 6:47 AM
To: BAndViG
Cc: openrisc
Subject: Re: [OpenRISC] NewLIB and trigonometric functions
....
or1k-elf-gcc -mhard-mul -mhard-div -msoft-float -mboard=atlys fsin.c
-lm -o fsin.elf
Stefan
_______________________________________________
OpenRISC mailing list
http://lists.openrisc.net/listinfo/openrisc
Hi Andrey,

Good to hear that it's working under cygwin. Are you running FuseSoC
as well? I'm very interested in hearing if that works under cygwin as
well. I haven't had a windows computer where I could test it

//Olof
BAndViG
2014-09-23 19:09:16 UTC
Permalink
Olof, I used FuseSoC once to download source code of modules from various
repositories and to generate tcl script for atlys board. After tcl was
generated the process stopped with error messages. Actually, it was normally
for my case as I didn't provide path for Xilinx tools into Cygwin
environment. As I found later it was right decision, because Xilinx's
Win-tools are compiled as native Win-programs, so they aren't able to work
with Unix stile paths anyway. So I edited the tcl:
(a) to replace paths from Unix to Win stile for both "xfile add" and
"Verilog Include Directories".
i.e. the initial part of a path like "/home..." was replaced by
"C:/cygwin64/home..."
(b) to remove any "process run" lines.
Next I used Xilinx ISE to open the tcl and ISE generated project. Since time
I have been using ISE only, not command line.

Regarding other OR1K related tools.

To build NewLIB tool chain I had to install 'autogen' package from
cygwinports.org (if somebody else interested, see http://cygwinports.org for
howto guide) because official Cygwin64 (!!) repositories don't include it.

Other typical problems are symbolic links in repositories and file names
with symbols are forbidden for NTFS. Both problems are presented in uClibc.
Fortunately, the files with forbidden names are not used for or1k and the
only symbolic link was 'Config'.
The good guide on git simlinks in windows:
http://stackoverflow.com/questions/5917249/git-symlinks-in-windows .

BR
Andrey


-----Исходное сообщение-----
From: Olof Kindgren
Sent: Tuesday, September 23, 2014 9:52 AM
To: BAndViG
Cc: Stefan Kristiansson ; List on OpenRISC.net
Subject: Re: [OpenRISC] NewLIB and trigonometric functions

Hi Andrey,

Good to hear that it's working under cygwin. Are you running FuseSoC
as well? I'm very interested in hearing if that works under cygwin as
well. I haven't had a windows computer where I could test it

//Olof
Olof Kindgren
2014-10-01 10:33:12 UTC
Permalink
Post by BAndViG
Olof, I used FuseSoC once to download source code of modules from various
repositories and to generate tcl script for atlys board. After tcl was
generated the process stopped with error messages. Actually, it was normally
for my case as I didn't provide path for Xilinx tools into Cygwin
environment. As I found later it was right decision, because Xilinx's
Win-tools are compiled as native Win-programs, so they aren't able to work
(a) to replace paths from Unix to Win stile for both "xfile add" and
"Verilog Include Directories".
i.e. the initial part of a path like "/home..." was replaced by
"C:/cygwin64/home..."
(b) to remove any "process run" lines.
Next I used Xilinx ISE to open the tcl and ISE generated project. Since time
I have been using ISE only, not command line.
Regarding other OR1K related tools.
To build NewLIB tool chain I had to install 'autogen' package from
cygwinports.org (if somebody else interested, see http://cygwinports.org for
howto guide) because official Cygwin64 (!!) repositories don't include it.
Other typical problems are symbolic links in repositories and file names
with symbols are forbidden for NTFS. Both problems are presented in uClibc.
Fortunately, the files with forbidden names are not used for or1k and the
only symbolic link was 'Config'.
http://stackoverflow.com/questions/5917249/git-symlinks-in-windows .
BR
Andrey
Good to know. Just using FuseSoC to get the sources and set up the
inital project files was always one intended use case
I see that there exists a cygpath command that automatically
translates the paths to the proper windows paths. Using that when we
detect that we're running under cygwin would be a nice improvement.
Might make sense to remove the process run statements as well

//Olof

Loading...