Discussion:
[PATCH 1/1] erc32 sim: Add libdl to build of sis
Joel Sherrill
2014-08-14 22:21:06 UTC
Permalink
sis failed to link on Fedora 20 because it was not linking against
libdl. There may be a better way but this does work.

2013-08-14 Joel Sherrill <***@oarcorp.com>

* Makefile.in, configure.ac: Probe for libdl and use if available.
* configure: Regenerated
---
sim/erc32/Makefile.in | 3 +-
sim/erc32/configure | 94 +++++++++++++++++++++++++++++++++++++++++++++-----
sim/erc32/configure.ac | 3 ++
3 files changed, 90 insertions(+), 10 deletions(-)

diff --git a/sim/erc32/Makefile.in b/sim/erc32/Makefile.in
index 0ce58a6..b5a6c4b 100644
--- a/sim/erc32/Makefile.in
+++ b/sim/erc32/Makefile.in
@@ -20,9 +20,10 @@

TERMCAP_LIB = @TERMCAP@
READLINE_LIB = @READLINE@
+DL_LIB = @DLLIB@

SIM_OBJS = exec.o erc32.o func.o help.o float.o interf.o
-SIM_EXTRA_LIBS = $(READLINE_LIB) $(TERMCAP_LIB) -lm
+SIM_EXTRA_LIBS = $(READLINE_LIB) $(TERMCAP_LIB) $(DL_LIB) -lm
SIM_EXTRA_ALL = sis
SIM_EXTRA_INSTALL = install-sis
SIM_EXTRA_CLEAN = clean-sis
diff --git a/sim/erc32/configure b/sim/erc32/configure
index b8fd852..dd9882e 100755
--- a/sim/erc32/configure
+++ b/sim/erc32/configure
@@ -601,6 +601,7 @@ ac_includes_default="\
ac_subst_vars='LTLIBOBJS
LIBOBJS
cgen_breaks
+DLLIB
READLINE
TERMCAP
REPORT_BUGS_TEXI
@@ -1389,7 +1390,7 @@ Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --enable-plugins Enable support for plugins (defaults no)
+ --enable-plugins Enable support for plugins
--enable-shared[=PKGS] build shared libraries [default=yes]
--enable-static[=PKGS] build static libraries [default=yes]
--enable-fast-install[=PKGS]
@@ -8768,15 +8769,46 @@ fi

# BFD uses libdl when when plugins enabled.

-# Check whether --enable-plugins was given.
+ maybe_plugins=no
+ for ac_header in dlfcn.h
+do :
+ ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
+"
+if test "x$ac_cv_header_dlfcn_h" = x""yes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DLFCN_H 1
+_ACEOF
+ maybe_plugins=yes
+fi
+
+done
+
+ for ac_header in windows.h
+do :
+ ac_fn_c_check_header_compile "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default
+"
+if test "x$ac_cv_header_windows_h" = x""yes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_WINDOWS_H 1
+_ACEOF
+ maybe_plugins=yes
+fi
+
+done
+
+
+ # Check whether --enable-plugins was given.
if test "${enable_plugins+set}" = set; then :
enableval=$enable_plugins; case "${enableval}" in
- yes | "") plugins=yes ;;
- no) plugins=no ;;
- *) plugins=yes ;;
- esac
+ no) plugins=no ;;
+ *) plugins=yes
+ if test "$maybe_plugins" != "yes" ; then
+ as_fn_error "Building with plugin support requires a host that supports dlopen." "$LINENO" 5
+ fi ;;
+ esac
else
- plugins=no
+ plugins=$maybe_plugins
+
fi


@@ -12265,7 +12297,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12268 "configure"
+#line 12300 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
@@ -12371,7 +12403,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12374 "configure"
+#line 12406 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
@@ -13022,6 +13054,50 @@ fi
fi


+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dl in -ldl" >&5
+$as_echo_n "checking for dl in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dl+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dl ();
+int
+main ()
+{
+return dl ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_dl_dl=yes
+else
+ ac_cv_lib_dl_dl=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dl" >&5
+$as_echo "$ac_cv_lib_dl_dl" >&6; }
+if test "x$ac_cv_lib_dl_dl" = x""yes; then :
+ DLLIB=-ldl
+else
+ :
+fi
+
+
+
ac_sources="$sim_link_files"
ac_dests="$sim_link_links"
while test -n "$ac_sources"; do
diff --git a/sim/erc32/configure.ac b/sim/erc32/configure.ac
index bc46091..21e5813 100644
--- a/sim/erc32/configure.ac
+++ b/sim/erc32/configure.ac
@@ -32,4 +32,7 @@ else
AC_ERROR([the required "readline" library is missing]), $TERMCAP)
fi
AC_SUBST(READLINE)
+
+AC_CHECK_LIB(dl, dl, DLLIB=-ldl, :, )
+AC_SUBST(DLLIB)
SIM_AC_OUTPUT
--
1.9.3
Joel Sherrill
2014-08-14 22:37:41 UTC
Permalink
I just tried psim and it fails missing libdl also. Did something change
in general in the simulators build procedure or does something
like this need to be propagated?

--joel
Post by Joel Sherrill
sis failed to link on Fedora 20 because it was not linking against
libdl. There may be a better way but this does work.
* Makefile.in, configure.ac: Probe for libdl and use if available.
* configure: Regenerated
---
sim/erc32/Makefile.in | 3 +-
sim/erc32/configure | 94 +++++++++++++++++++++++++++++++++++++++++++++-----
sim/erc32/configure.ac | 3 ++
3 files changed, 90 insertions(+), 10 deletions(-)
diff --git a/sim/erc32/Makefile.in b/sim/erc32/Makefile.in
index 0ce58a6..b5a6c4b 100644
--- a/sim/erc32/Makefile.in
+++ b/sim/erc32/Makefile.in
@@ -20,9 +20,10 @@
SIM_OBJS = exec.o erc32.o func.o help.o float.o interf.o
-SIM_EXTRA_LIBS = $(READLINE_LIB) $(TERMCAP_LIB) -lm
+SIM_EXTRA_LIBS = $(READLINE_LIB) $(TERMCAP_LIB) $(DL_LIB) -lm
SIM_EXTRA_ALL = sis
SIM_EXTRA_INSTALL = install-sis
SIM_EXTRA_CLEAN = clean-sis
diff --git a/sim/erc32/configure b/sim/erc32/configure
index b8fd852..dd9882e 100755
--- a/sim/erc32/configure
+++ b/sim/erc32/configure
@@ -601,6 +601,7 @@ ac_includes_default="\
ac_subst_vars='LTLIBOBJS
LIBOBJS
cgen_breaks
+DLLIB
READLINE
TERMCAP
REPORT_BUGS_TEXI
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --enable-plugins Enable support for plugins (defaults no)
+ --enable-plugins Enable support for plugins
--enable-shared[=PKGS] build shared libraries [default=yes]
--enable-static[=PKGS] build static libraries [default=yes]
--enable-fast-install[=PKGS]
@@ -8768,15 +8769,46 @@ fi
# BFD uses libdl when when plugins enabled.
-# Check whether --enable-plugins was given.
+ maybe_plugins=no
+ for ac_header in dlfcn.h
+ ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
+"
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DLFCN_H 1
+_ACEOF
+ maybe_plugins=yes
+fi
+
+done
+
+ for ac_header in windows.h
+ ac_fn_c_check_header_compile "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default
+"
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_WINDOWS_H 1
+_ACEOF
+ maybe_plugins=yes
+fi
+
+done
+
+
+ # Check whether --enable-plugins was given.
enableval=$enable_plugins; case "${enableval}" in
- yes | "") plugins=yes ;;
- no) plugins=no ;;
- *) plugins=yes ;;
- esac
+ no) plugins=no ;;
+ *) plugins=yes
+ if test "$maybe_plugins" != "yes" ; then
+ as_fn_error "Building with plugin support requires a host that supports dlopen." "$LINENO" 5
+ fi ;;
+ esac
else
- plugins=no
+ plugins=$maybe_plugins
+
fi
@@ -12265,7 +12297,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12268 "configure"
+#line 12300 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12371,7 +12403,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12374 "configure"
+#line 12406 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -13022,6 +13054,50 @@ fi
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dl in -ldl" >&5
+$as_echo_n "checking for dl in -ldl... " >&6; }
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dl ();
+int
+main ()
+{
+return dl ();
+ ;
+ return 0;
+}
+_ACEOF
+ ac_cv_lib_dl_dl=yes
+else
+ ac_cv_lib_dl_dl=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dl" >&5
+$as_echo "$ac_cv_lib_dl_dl" >&6; }
+ DLLIB=-ldl
+else
+fi
+
+
+
ac_sources="$sim_link_files"
ac_dests="$sim_link_links"
while test -n "$ac_sources"; do
diff --git a/sim/erc32/configure.ac b/sim/erc32/configure.ac
index bc46091..21e5813 100644
--- a/sim/erc32/configure.ac
+++ b/sim/erc32/configure.ac
@@ -32,4 +32,7 @@ else
AC_ERROR([the required "readline" library is missing]), $TERMCAP)
fi
AC_SUBST(READLINE)
+
+AC_CHECK_LIB(dl, dl, DLLIB=-ldl, :, )
+AC_SUBST(DLLIB)
SIM_AC_OUTPUT
--
Joel Sherrill, Ph.D. Director of Research & Development
***@OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
Mike Frysinger
2014-08-15 00:30:30 UTC
Permalink
Post by Joel Sherrill
sis failed to link on Fedora 20 because it was not linking against
libdl. There may be a better way but this does work.
can you post some errors ? the only sim that actually uses libdl is the
Blackfin one. i suspect the dl usage is coming from another binutils lib
(like bfd?) which means the fix is not this :).
-mike
Joel Sherrill
2014-08-15 13:13:24 UTC
Permalink
Post by Mike Frysinger
Post by Joel Sherrill
sis failed to link on Fedora 20 because it was not linking against
libdl. There may be a better way but this does work.
can you post some errors ? the only sim that actually uses libdl is the
Blackfin one. i suspect the dl usage is coming from another binutils lib
(like bfd?) which means the fix is not this :).
I just saw the sparc failure and fixed it. Once I saw that all of our
targets with simulators enabled failed like this (from v850), I was pretty
sure I had fixed a symptom and not the root cause.

make[3]: Entering directory
`/users/joel/test-gcc/b-v850-rtems4.11-bin/sim/v850'
gcc -DHAVE_CONFIG_H -DTRACE=1 -DWITH_TRACE=-1 -DPROFILE=1
-DWITH_PROFILE=-1 -DWITH_DEFAULT_ALIGNMENT=NONSTRICT_ALIGNMENT
-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31
-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN
-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN -DDEFAULT_INLINE=0
-DWITH_RESERVED_BITS=1 -Wall -Wdeclaration-after-statement
-Wpointer-arith -Wpointer-sign -Wno-unused -Wunused-value
-Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes
-Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type
-Wold-style-declaration -Wold-style-definition -Wformat-nonliteral
-DDEBUG
-I../../../binutils-gdb/sim/v850/../../newlib/libc/sys/sysnecv850 -I.
-I../../../binutils-gdb/sim/v850 -I../common
-I../../../binutils-gdb/sim/v850/../common -I../../include
-I../../../binutils-gdb/sim/v850/../../include -I../../bfd
-I../../../binutils-gdb/sim/v850/../../bfd -I../../opcodes
-I../../../binutils-gdb/sim/v850/../../opcodes -g -O2 -static-libstdc++
-static-libgcc -o run \
nrun.o libsim.a ../../bfd/libbfd.a ../../opcodes/libopcodes.a
../../libiberty/libiberty.a -lz -lnsl
../../bfd/libbfd.a(plugin.o): In function `try_load_plugin':
/users/joel/test-gcc/b-v850-rtems4.11-bin/bfd/../../binutils-gdb/bfd/plugin.c:168:
undefined reference to `dlopen'
/users/joel/test-gcc/b-v850-rtems4.11-bin/bfd/../../binutils-gdb/bfd/plugin.c:175:
undefined reference to `dlsym'
/users/joel/test-gcc/b-v850-rtems4.11-bin/bfd/../../binutils-gdb/bfd/plugin.c:171:
undefined reference to `dlerror'
collect2: error: ld returned 1 exit status
Post by Mike Frysinger
-mike
--
Joel Sherrill, Ph.D. Director of Research & Development
***@OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
Mike Frysinger
2014-08-17 13:20:14 UTC
Permalink
Post by Joel Sherrill
Post by Mike Frysinger
Post by Joel Sherrill
sis failed to link on Fedora 20 because it was not linking against
libdl. There may be a better way but this does work.
can you post some errors ? the only sim that actually uses libdl is the
Blackfin one. i suspect the dl usage is coming from another binutils lib
(like bfd?) which means the fix is not this :).
I just saw the sparc failure and fixed it. Once I saw that all of our
targets with simulators enabled failed like this (from v850), I was pretty
sure I had fixed a symptom and not the root cause.
Roland just regenerated the sim configure files due to changes in the common
plugin/dlfcn logic. i guess pull the latest repo and see if you still have
troubles building ?
-mike
Joel Sherrill
2014-08-18 22:13:18 UTC
Permalink
Post by Mike Frysinger
Post by Joel Sherrill
Post by Mike Frysinger
Post by Joel Sherrill
sis failed to link on Fedora 20 because it was not linking against
libdl. There may be a better way but this does work.
can you post some errors ? the only sim that actually uses libdl is the
Blackfin one. i suspect the dl usage is coming from another binutils lib
(like bfd?) which means the fix is not this :).
I just saw the sparc failure and fixed it. Once I saw that all of our
targets with simulators enabled failed like this (from v850), I was pretty
sure I had fixed a symptom and not the root cause.
Roland just regenerated the sim configure files due to changes in the common
plugin/dlfcn logic. i guess pull the latest repo and see if you still have
troubles building ?
This seemed to fix all but the ppc.

gcc -g -O2 -static-libstdc++ -static-libgcc -o psim main.o libsim.a
../../bfd/libbfd.a ../../libiberty/libiberty.a -lz
../../bfd/libbfd.a(plugin.o): In function `try_load_plugin':
/users/joel/test-gcc/b-powerpc-rtems4.11-bin/bfd/../../binutils-gdb/bfd/plugin.c:168:
undefined reference to `dlopen'
/users/joel/test-gcc/b-powerpc-rtems4.11-bin/bfd/../../binutils-gdb/bfd/plugin.c:175:
undefined reference to `dlsym'
/users/joel/test-gcc/b-powerpc-rtems4.11-bin/bfd/../../binutils-gdb/bfd/plugin.c:171:
undefined reference to `dlerror'
Post by Mike Frysinger
-mike
--
Joel Sherrill, Ph.D. Director of Research & Development
***@OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
Loading...