[llvm] [LLVM][CMake] Prefer to find libffi.a if present (PR #78779)

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 19 12:44:27 PST 2024


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/78779

Summary:
This patch is an attempt to make the `find_package(FFI)` support in LLVM
prefer to use the static library version if present. This is currently
an optional library for building `libffi`, and its presence implies that
it should likely be used. This patch is an attempt to fix some problems
observed with testing programs linked against `libffi` on many different
systems that could have conflicting paths. Linking it statically
prevents this.

If this is not a desirable solution, we could either roll this logic
custom, or handling it via a `COMPONENT` or something.


>From 00d66570a708a0a0e03f41e7bda1fb598df0f4b2 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Fri, 19 Jan 2024 14:39:52 -0600
Subject: [PATCH] [LLVM][CMake] Prefer to find libffi.a if present

Summary:
This patch is an attempt to make the `find_package(FFI)` support in LLVM
prefer to use the static library version if present. This is currently
an optional library for building `libffi`, and its presence implies that
it should likely be used. This patch is an attempt to fix some problems
observed with testing programs linked against `libffi` on many different
systems that could have conflicting paths. Linking it statically
prevents this.

If this is not a desirable solution, we could either roll this logic
custom, or handling it via a `COMPONENT` or something.
---
 llvm/cmake/modules/FindFFI.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/cmake/modules/FindFFI.cmake b/llvm/cmake/modules/FindFFI.cmake
index c9ba104601872e..1d922ce26e7ef8 100644
--- a/llvm/cmake/modules/FindFFI.cmake
+++ b/llvm/cmake/modules/FindFFI.cmake
@@ -34,7 +34,7 @@ else()
   endif()
 endif()
 
-find_library(FFI_LIBRARIES ffi PATHS ${FFI_LIBRARY_DIR})
+find_library(FFI_LIBRARIES NAMES libffi.a ffi PATHS ${FFI_LIBRARY_DIR})
 
 if(FFI_LIBRARIES)
   include(CMakePushCheckState)



More information about the llvm-commits mailing list