How to build openmp without libffi?

Is there a way to build openmp runtime without libffi?

In llvm/CMakeLists.txt, I do see LLVM_ENABLE_FFI but it is OFF by default. However, I don’t see such flag in openmp or libomptarget CMakeLists.txt.

I am trying to understand if my build of LLVM can avoid dependence on this library.

Thanks,
Madhur.

The dependency on libffi is due to the x64 offloading plugin. We use libffi to call a generic function pointer to mimic a GPU kernel call on the CPU. I don’t think that OpenMP respects LLVM_ENABLE_FFI currently, most likely because it’s a separate use-case than what LLVM would use it for. I don’t believe that FFI is required unless you want the x64 offloading plugin. If we don’t find libffi we just continue without building the CPU plugin. So, what issues are you seeing?

The dependency on libffi is due to the x64 offloading plugin. We use libffi to call a generic function pointer to mimic a GPU kernel call on the CPU. I don’t think that OpenMP respects LLVM_ENABLE_FFI currently, most likely because it’s a separate use-case than what LLVM would use it for. I don’t believe that FFI is required unless you want the x64 offloading plugin. If we don’t find libffi we just continue without building the CPU plugin.

Is this also applicable to AArch64 plugin? My build platform does have libffi installed and thus CPU plugin is built.

So, what issues are you seeing?

The platform I am building on and the platform I am using my compiler on have different versions on libffi installed and thus the error during installation. I can get away with installing the required libffi version but it is not always possible as not all distros ship the version I may need.

Yes, I should’ve specified all CPU-based targets use libfii. This shouldn’t result in an error. Can you post what you’re seeing?

Well, it is just

error: Failed dependencies:
libffi.so.7()(64bit) is needed by myclang

My build platform has libffi7-3.2.1.git259-10.8.x86_64.rpm installed but my user platform has libffi-3.1-22.el8.x86_64.rpm with it. Again, I get away by upgrading my libffi but it is not scalable and always possible for me to do so.

Does it tell you where in the CMake that failed? As far as I can tell it shouldn’t error because if we fail to find libfii we just continue as normal so I’d like some more context.

The error is not in Cmake. I am building myclang package (myclang.pkg) on platform 1. It has the following libffi present on it. Hence, CPU plugin is built.

libffi7-3.2.1.git259-10.8.x86_64.rpm

I am installing myclang.pkg on platform 2 which has following libffi.

libffi-3.1-22.el8.x86_64.rpm

When doing installation of myclang.pkg on platform 2, I am getting the below error.

error: Failed dependencies:
libffi.so.7()(64bit) is needed by myclang

This is basically happening because there is version mismatch. Hence my original question. Can I avoid it? Or is there a build flag available? I hope that helps.

Okay, so you’re building LLVM which detects libffi and builds with it, but then causes a failure when it tries to load it? Presumably this happens when you try to run something? Since the only thing that links against it are the CPU plugins which are only opened via dlopen.