Configuring pocl for RISCV - configure

I am trying to use pocl to cross-compile OpenCL programs for RISCV64. Slide 18 at this link: https://riscv.org/wp-content/uploads/2015/01/riscv-software-toolchain-workshop-jan2015.pdf seems to suggest that it is possible to generate scalar code for the RISCV backend. I am using pocl-0.8 (based on llvm 3.3 since that is the stable version for the riscv-llvm backend).
I ran the configure command as follows:
./configure CC=/path/to/riscv/bin/riscv64-unknown-elf-gcc CXX=/path/to/riscv/bin/riscv64-unknown-elf-g++ --host=riscv64-unknown-elf
I got the following error:
configure: error: unable to find the libtool dl library (usually libltdl-dev)
I don't get any error if I configure pocl for my native system (x86_64). So, I am guessing I need the RISCV variant of the library mentioned in the error message above but I am not sure how to do that. I would appreciate any help with this. Thanks!

Do you want to run pocl on the RISC-V system generating RISC-V code or to run it on host x64 system to generate RISC-V?
Your configure command
./configure CC=riscv64-unknown-elf-gcc CXX=riscv64-unknown-elf-g++ --host=riscv64-unknown-elf
is for compiling native pocl on RISC-V which is hard (you need full cross-environment and RISC-V target cpu/emulator/board with linux, libc, and many packets). And even for this it is incorrect, as your host (machine where you start compilation of the pocl) is not riscv, but x64 (use --target to set target architecture in configure).
But if you want to run pocl on x64, don't set CC and CXX, host and target in ./configure run to get native x64 pocl. llvm will have all backend and will let you to generate RISC-V codes, when starting pocl on x64.

Related

how to run ELF 64-bit LSB executable, UCB RISC-V, version 1 (GNU/Linux), dynamically linked on Linux

I am trying to do profiling of the code written in C++ with the target Architecture RISC-V. The code has been cross-compiled using RISC-V GNU Toolchain. My executable is unit_tests "ELF 64-bit LSB executable, UCB RISC-V, version 1 (GNU/Linux), dynamically linked,nterpreter /lib/ld-linux-riscv64-lp64d.so.1, for GNU/Linux 4.15.0, with debug_info, not stripped" this information is retrieved using the file command.
What I am trying to do is the profiling of this using gprof. But to do the gprof gmon.out needs to be generated, to generate gmon.out the executable should be run first. I cannot run the binary elf of other architecture in some different architecture. I need a suggestion for this on which emulator or simulator does this for me or I can run on?
I have tried installing qemu using the follwing link:
https://www.google.com/url?q=https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html&sa=D&source=hangouts&ust=1597422417473000&usg=AFQjCNERr6pHYmj0SU6an3WkBRGQI52aTw
but not able to successfully install it.
Also have tried with spike but got "bad synccall" error. Any leads how can I resolve this issue.
I solved this issue using qemu in user mode. Following the instructions in the below link:
Manual-qemu-user
Where I could run the binary elf generated for target RISC-V, which I could run on x86 Linux machine.

Cross Compile GMP and Openswan for ARM on Ubuntu 12.04 32 Bit

I have to cross compile opensawn for a OMAP4 Board and GMP is prerequisite. First I tried it on 64 bit OS but it gave me this error:
configure: error: Oops, mp_limb_t is 64 bits, but the assembler code in this configuration expects 32 bits.
Then I shifted to Ubuntu 12.04 32 Bit and the GMP V6.0.0 got compiled after few trials. Even after having the ARCH, TOOLCHAIN and CROSS_COMPILER variables in .bashrc I had to export the following:
export ARCH=arm<BR>
export PATH=/home/harsh32bit/Work/Projects/BSQ_VVDN/BISQUARE/gcc-SourceryCodeBenchLite-arm/bin/:$PATH<BR>
export CROSS_COMPILE=arm-none-linux-gnueabi-<BR>
Then following commands were observed:
./configure --build=i686-pc-linux-gnu --host=arm-none-linux-gnueabi --prefix=/home/harsh32bit/Work/Projects/BSQ_VVDN/BISQUARE/gcc-SourceryCodeBenchLite-arm/
make clean
make
make install
Then Soft-linking GMP Library to Toolchain
~/Work/Projects/BSQ_VVDN/BISQUARE/gcc-SourceryCodeBenchLite-arm/lib/gcc/arm-none-linux-gnueabi/4.7.3
# ln -s ~/Work/Projects/BSQ_VVDN/packages/gmp-6.0.0/.libs/libgmp.so libgmp.so
I had the GMP compiled successfully although the make check reported all test failed.
9 of 9 tests failed.
Now when I try to cross compile Openswan-2.6.41 after making changes in CROSSCOMPILE.sh and do this make programs I get this error:
In file included from /home/harsh32bit/Work/Projects/BSQ_VVDN/packages/openswan-2.6.41/include/certs.h:24:0,from /home/harsh32bit/Work/Projects/BSQ_VVDN/packages/openswan-2.6.41/lib/libopenswan/id.c:42:
/home/harsh32bit/Work/Projects/BSQ_VVDN/packages/openswan-2.6.41/include/secrets.h:20:41: fatal error: gmp.h: No such file or directory
compilation terminated
I have gone to TI E2E site for this, sniffed internet for pointers in last 4 weeks but I couldn't figure out. If anyone has any clue about cross compiling openswan and GMP for ARM please advise me.
So essentially
The static linkage of gmp files had to be done sans sudo - since when you call make programs from openswan package without sudo you are not root instead a normal user and if you use make programs with sudo it misses some exported variables particularly ARCH. It takes the default architecture instead of target architecture you want to compile for; like in my case it was for arm.
If you have to use the sudo, make it readable-writeable for all. That is after linking the library files in the toolchain you can call chmod 777 on that file - because then it will be available for rw for all user groups.

Cross compiling, missing packages

I'm working on Linux PC x86_64.
I've set up a cross compile toolchain for raspberry pi and I can compile basic helloworld and run it on raspberry.
I'm stuck at compiling some open-source programs as ./configure is complaining about missing packages, for example:
configure: No package 'glib-2.0' found
I'm using this. ./configure --host=arm-linux-gnueabihf to cross compile and it looks good until that error above.
Should I tell ./configure to use libs from target system or? How to do it?
Pass options to the configure script so that it finds the development headers and libraries. It uses using LDFLAGS and CFLAGS.

powerpc compiler on windows gives "c++ compiler not installed on this system error"

I am trying to use msys powerpc-eabispe-gcc compiler on windows to compile a simple helloworld.cpp program, inorder to generate an elf for powerpc architecture, but I am getting "c++ compiler not installed on this system" error. The bin folder of powerpc-eabispe contains all the exe's, I dont understand why then I get this error??
I used MinGW command prompt to run this command: powerpc-eabispe-gcc.exe -o hello hello.cpp
You need to install the toolchain for the architecture you are targeting.
Search for "cctools" / "binutils" / "crosstools" or "ppc cross-compile environment".
You can also take a look at:
Building and Testing gcc/glibc cross toolchains (This will probably work)
Host/Target specific installation notes for GCC (search powerpc in the page)
However, I would encourage you to try this on a linux or on a mac computer. There are far more resources & docs available on the web for cross-compilation on these platforms.

C/C++ to MIPS Assembly

I know that to compile to assembly, I should use the -Soption with gcc or g++, but how do I get MIPS assembly?
I tried
g++ -march=mips2 dll.c
but that gives the error
dll.c:1:0: error: bad value (mips2) for -march= switch
I saw a suggestion of the compile command mips_gcc, but I can't find how to install that compiler.
I'm using Ubuntu 64-bit, if that helps.
You need a version of gcc that is built as a MIPS cross compiler. You can download the free Mentor/Codesourcery MIPS gnu/gcc cross compilation tool chain from here. This toolchain is available for both Windows and Linux.
After downloading, installing and adding the tool chain to your path you would say:
mips-linux-gnu-g++ -march=mips32r2 -S dll.c
to compile your code to MIPS32R2 assembly.
UPDATE 8/2017:
It looks like Sourcery CodeBench free cross compiler for MIPS is no longer available at Mentor's site.
Try the free toolchain at Imagination's site.

Resources