[ovs-dev,v2,2/2] acinclude: Use AC_SEARCH_LIBS for linking with dl.

Message ID 20190411072943.29566-3-i.maximets@samsung.com
State Deferred
Delegated to: Ian Stokes
Headers show
Series
  • acinclude: User/reader-friendly checking for DPDK dependencies.
Related show

Commit Message

Ilya Maximets April 11, 2019, 7:29 a.m.
DPDK uses dlopen to load plugins and we need to search for
library containing this function. But we should not do this
in a loop because 'AC_SEARCH_LIBS' could do this for us.
Also, 'AC_SEARCH_LIBS' prints user-visible messages that are
useful for debuging.
Also added the new 'checking' message and code normalized to
be more readable.

With this change we'll have following additional messages:

  checking for library containing dlopen... -ldl
  checking whether linking with dpdk works... yes

Acked-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
 acinclude.m4 | 50 +++++++++++++++++++++-----------------------------
 1 file changed, 21 insertions(+), 29 deletions(-)

Comments

Aaron Conole April 11, 2019, 1:30 p.m. | #1
Ilya Maximets <i.maximets@samsung.com> writes:

> DPDK uses dlopen to load plugins and we need to search for
> library containing this function. But we should not do this
> in a loop because 'AC_SEARCH_LIBS' could do this for us.
> Also, 'AC_SEARCH_LIBS' prints user-visible messages that are
> useful for debuging.
> Also added the new 'checking' message and code normalized to
> be more readable.
>
> With this change we'll have following additional messages:
>
>   checking for library containing dlopen... -ldl
>   checking whether linking with dpdk works... yes
>
> Acked-by: Flavio Leitner <fbl@sysclose.org>
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
> ---

Acked-by: Aaron Conole <aconole@redhat.com>
Ben Pfaff April 12, 2019, 5:54 p.m. | #2
On Thu, Apr 11, 2019 at 10:29:43AM +0300, Ilya Maximets wrote:
> DPDK uses dlopen to load plugins and we need to search for
> library containing this function. But we should not do this
> in a loop because 'AC_SEARCH_LIBS' could do this for us.
> Also, 'AC_SEARCH_LIBS' prints user-visible messages that are
> useful for debuging.
> Also added the new 'checking' message and code normalized to
> be more readable.
> 
> With this change we'll have following additional messages:
> 
>   checking for library containing dlopen... -ldl
>   checking whether linking with dpdk works... yes
> 
> Acked-by: Flavio Leitner <fbl@sysclose.org>
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>

Thanks, Ilya!  I applied these patches to master.

Patch

diff --git a/acinclude.m4 b/acinclude.m4
index 22fbf3f40..0dbd3bedc 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -301,36 +301,28 @@  AC_DEFUN([OVS_CHECK_DPDK], [
       ], [[#include <rte_config.h>]])
     ], [], [[#include <rte_config.h>]])
 
-    # On some systems we have to add -ldl to link with dpdk
-    #
-    # This code, at first, tries to link without -ldl (""),
-    # then adds it and tries again.
-    # Before each attempt the search cache must be unset,
-    # otherwise autoconf will stick with the old result
+    # DPDK uses dlopen to load plugins.
+    OVS_FIND_DEPENDENCY([dlopen], [dl], [libdl])
+
+    AC_MSG_CHECKING([whether linking with dpdk works])
+    LIBS="$DPDK_LIB $LIBS"
+    AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM([#include <rte_config.h>
+                        #include <rte_eal.h>],
+                       [int rte_argc; char ** rte_argv;
+                        rte_eal_init(rte_argc, rte_argv);])],
+      [AC_MSG_RESULT([yes])
+       DPDKLIB_FOUND=true],
+      [AC_MSG_RESULT([no])
+       if test "$DPDK_AUTO_DISCOVER" = "true"; then
+         AC_MSG_ERROR(m4_normalize([
+            Could not find DPDK library in default search path, Use --with-dpdk
+            to specify the DPDK library installed in non-standard location]))
+       else
+         AC_MSG_ERROR([Could not find DPDK libraries in $DPDK_LIB_DIR])
+       fi
+      ])
 
-    DPDKLIB_FOUND=false
-    save_LIBS=$LIBS
-    for extras in "" "-ldl"; do
-        LIBS="$DPDK_LIB $extras $save_LIBS"
-        AC_LINK_IFELSE(
-           [AC_LANG_PROGRAM([#include <rte_config.h>
-                             #include <rte_eal.h>],
-                            [int rte_argc; char ** rte_argv;
-                             rte_eal_init(rte_argc, rte_argv);])],
-           [DPDKLIB_FOUND=true])
-        if $DPDKLIB_FOUND; then
-            break
-        fi
-    done
-
-    # If linking unsuccessful
-    if test "$DPDKLIB_FOUND" = "false" ; then
-      if $DPDK_AUTO_DISCOVER; then
-        AC_MSG_ERROR([Could not find DPDK library in default search path, Use --with-dpdk to specify the DPDK library installed in non-standard location])
-      else
-        AC_MSG_ERROR([Could not find DPDK libraries in $DPDK_LIB_DIR])
-      fi
-    fi
     CFLAGS="$ovs_save_CFLAGS"
     LDFLAGS="$ovs_save_LDFLAGS"
     if test "$DPDK_AUTO_DISCOVER" = "false"; then