Open davidmallasen opened 2 years ago
@davidmallasen thanks for bringing this up. This will take a bit of work to resolve as different compilers provide different supporting structures. The errors reported indicate that the math library offered has some different assumptions. Good news is that I am very interested to get the RISC-V environment clean and in the regular regression line-up.
This is going to be a porting exercise discovering what the RISC-V compiler, runtime, and library environment constraints are and organizing the code accordingly. If you can tell me how to recreate your environment so we can collaborate that would be the first step.
Hello @theo-lemurian
To recreate the RISC-V environment on a Ubuntu 22.04 machine:
In home directory of user user
:
git clone https://github.com/riscv/riscv-gnu-toolchain
cd riscv-gnu-toolchain
sudo apt-get install autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev
./configure --prefix=/home/user/riscv --enable-multilib
make
cd ..
In ~/.bashrc
add: export PATH="$PATH:/home/user/riscv/bin/"
source .bashrc
git clone https://github.com/stillwater-sc/universal.git
mkdir test_universal
cd test_universal
mkdir src
mkdir build
cd src
Create file main.cpp:
#include <universal/number/posit/posit.hpp>
int main() {
sw::universal::posit<32,2> a = 1;
std::cout << to_hex(a.get()) << std::endl;
return 0;
}
cd ..
Create file CMakeLists.txt:
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(example)
set(CMAKE_CXX_COMPILER riscv64-unknown-elf-g++)
set(SRC_FOLDER "${CMAKE_CURRENT_LIST_DIR}/src")
include_directories("~/universal/include")
add_executable(test_posit ${SRC_FOLDER}/main.cpp)
set_property(TARGET test_posit PROPERTY CXX_STANDARD 17)
Then:
cd build
cmake ..
make
I hope this helps. David
Tried over the weekend to create a RISC-V Qemu setup but was unsuccessful. Do you have any guidance?
finally got a risc-v environment. Now I can reproduce your errors. There is some restructuring required to have gcc and risc-v play nice together. I'll work on that this week. In the mean time, maybe you can help me decipher this error:
stillwater@3e7deb69f9bc:~/test/build$ make
[ 50%] Building CXX object CMakeFiles/test_posit.dir/src/main.cpp.o
[100%] Linking CXX executable test_posit
riscv64-unknown-elf-g++: error: unrecognized command-line option '-rdynamic'
make[2]: *** [CMakeFiles/test_posit.dir/build.make:97: test_posit] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/test_posit.dir/all] Error 2
Any idea where this -rdynamic flag comes from?
@davidmallasen ^^^
Hello @Ravenwater ,
I don't use qemu so I don't know about that, but great hearing that you could get the risc-v environment working.
I've never used that flag, so I'm not sure where it comes from. Searching online it seems that it is part of the linking process, maybe that helps to figure it out? From the gcc documentation: https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html A more detailed explanation: https://stackoverflow.com/questions/36692315/what-exactly-does-rdynamic-do-and-when-exactly-is-it-needed
@davidmallasen got the basics up and running. Looks like the mathlib in the RISC-V toolchain is a couple of decades behind, so I need to understand what their roadmap is for them to support a compliant <cmath>
. I will stub out all the functions they are not yet supporting to see if we can get this up and running. Once we get something working, it will be easier to track their progress and integrate with their future releases.
Perfect, sounds like a good solution @Ravenwater
Hello!
I'm having some trouble using Universal for RISC-V. I have a small test project with the following directories:
The content of CMakeLists.txt is:
When executing:
I get the following errors:
The cpp file includes
<universal/number/posit/posit.hpp>
, and the same small code is working when compiling in Ubuntu by default without theline in
CMakeLists.txt
. I have also tried using clang++ with the same result. Any insights into how to solve this? Thanks!