Building libomp + libomptarget for riscv32

Dear all,

for our project, we need to build libomp + libomptarget for the RISCV32 architecture, and I have some questions in this respect.

  • I found the CMake variable LIBOMP_ARCH, however when I use e.g. cmake -DLIBOMP_ARCH=riscv64 (or any other supported architecture) this does not change the target for which the binaries are built, it seems to only have some influence on certain preprocessor related source code parts. In the docs, I only find example CMake configurations using LIBOMP_ARCH. So my question is: Are there complete examples of how to actually configure and build libomp for a certain target? Am I supposed to simply set the target using CMAKE_CXX_FLAGS, using e.g. --target=riscv64 when compiling with Clang?

  • The variable LIBOMP_ARCH does not seem to be used for libomptarget building, however its README mentions some supported architectures. What is the intended way of compiling libomptarget for a certain architecture, and are there any examples of how to do this?

  • In general, any general hints on what I likely have to do for successfully building libomp and libomptarget for RISCV32 would help me a lot.

I would appreciate any help a lot!

Best regards,

Kai Plociennik

LIBOMP_ARCH is not being used for configuring how CMake compiles the library. Like you said, it’s only used in preprocessing for those target related variables. If the target architect is different from your host architecture, which I guess it should be the case here, you need cross compilation. You might want to check CMake document on how to cross compile. Same policy applies to libomptarget. libomptarget can be built on multiple architectures supported as listed in the document.

As for 32-bit OS, I’m not sure if there are any assumption about 64-bit used in libomptarget.

As of ⚙ D128817 [Libomptarget] Use new tripcount argument in the runtime. (and a follow on to fix the syntax of the assert) the libomptarget contains a static assert that implies a 64-bit system. It previously built for i386, but I don’t know if it worked and I’m not sure how much effort the team put into 32-bit support.

We should make that comparison work for 32-bit or 64-bit pointers, that being said I’m not aware of anyone whose tried building libomptarget on a 32-bit system in the first place. I’d be interested in whether or not it worked.

Thank you all for your answers, I will try to get this working and will tell you how it worked out!