Module: xenomai-3
Branch: next
Commit: 5948b5eb2d1f803d4b313651b22cf73867538209
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5948b5eb2d1f803d4b313651b22cf73867538209

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Aug 26 21:21:40 2016 +0200

boilerplate: honor PIC setting for bootstrap object

The bootstrap object must conform to the code generation option used
for building the Xenomai libraries to allow external libraries to
include it.

This means that we need to export a PIC object 3rd-party shared
libraries can link against if shared library support is enabled for
Xenomai, and a non-PIC object for the static counterpart. Such objects
are available as @libdir@/xenomai/bootstrap-pic.o and
@libdir@/xenomai/bootstrap.o respectively.

xeno-config* scripts now pick the PIC glue object if Xenomai supports
shared libraries by default, unless the new --no-pic switch is given
on the command line. If Xenomai was built not to support shared
libraries (--disable-shared), the default is implicitly non-PIC,
therefore --no-pic has no effect.

---

 configure.ac                     |   11 +++++++----
 lib/boilerplate/init/Makefile.am |   20 ++++++++++++++------
 scripts/xeno-config-cobalt.in    |   22 ++++++++++++++++------
 scripts/xeno-config-mercury.in   |   22 ++++++++++++++++------
 4 files changed, 53 insertions(+), 22 deletions(-)

diff --git a/configure.ac b/configure.ac
index 42f2f5d..3ad2775 100644
--- a/configure.ac
+++ b/configure.ac
@@ -831,15 +831,18 @@ dnl in-tree executables which require POSIX symbol 
wrapping.
    AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ["$cobalt_wrappers"])
 fi
 
-XENO_AUTOINIT_LDFLAGS='$(top_builddir)/lib/boilerplate/init/bootstrap.o'" 
-Wl,--wrap=main -Wl,--dynamic-list=$topdir/scripts/dynlist.ld"
+dnl
+dnl Build the Makefiles
+dnl
+
+XENO_AUTOINIT_LDFLAGS='$(top_builddir)/lib/boilerplate/init/bootstrap-internal.o'"
 -Wl,--wrap=main -Wl,--dynamic-list=$topdir/scripts/dynlist.ld"
 AC_SUBST(XENO_AUTOINIT_LDFLAGS)
 
 XENO_CORE_LIB=$rtcore_type/lib${rtcore_type}.la
 AC_SUBST(XENO_CORE_LIB)
 
-dnl
-dnl Build the Makefiles
-dnl
+test x$enable_shared = xyes && default_codegen="-pic" || default_codegen=
+AC_SUBST(default_codegen)
 
 AC_SUBST(DOXYGEN_SHOW_INCLUDE_FILES)
 AC_SUBST(DOXYGEN_HAVE_DOT)
diff --git a/lib/boilerplate/init/Makefile.am b/lib/boilerplate/init/Makefile.am
index 7a58f54..8c68cd9 100644
--- a/lib/boilerplate/init/Makefile.am
+++ b/lib/boilerplate/init/Makefile.am
@@ -1,18 +1,26 @@
-noinst_LIBRARIES = libbootstrap.a
+noinst_LTLIBRARIES = libbootstrap.la
 
-libbootstrap_a_SOURCES = bootstrap.c
+libbootstrap_la_SOURCES = bootstrap.c
 
-libbootstrap_a_CPPFLAGS =              \
+libbootstrap_la_CPPFLAGS =             \
        @XENO_USER_CFLAGS@              \
        -I$(top_srcdir)/include         \
        -I$(top_srcdir)/lib
 
-all-local: $(libbootstrap_a_OBJECTS)
-       cp $(libbootstrap_a_OBJECTS) bootstrap.o
+get_pic_object = $(shell source ./$(libbootstrap_la_OBJECTS) && echo 
$$pic_object)
+get_nonpic_object = $(shell source ./$(libbootstrap_la_OBJECTS) && echo 
$$non_pic_object)
+
+all-local: $(libbootstrap_la_OBJECTS)
+       @test -r $(call get_pic_object) && \
+       cp $(call get_pic_object) bootstrap-internal.o || \
+       cp $(call get_nonpic_object) bootstrap-internal.o
 
 install-data-local:
        $(mkinstalldirs) $(DESTDIR)$(libdir)/xenomai
-       $(INSTALL_DATA) $(libbootstrap_a_OBJECTS) 
$(DESTDIR)$(libdir)/xenomai/bootstrap.o
+       @test -r $(call get_pic_object) && \
+       $(INSTALL_DATA) $(call get_pic_object) 
$(DESTDIR)$(libdir)/xenomai/bootstrap-pic.o || true
+       @test -r $(get_nonpic_object) && \
+       $(INSTALL_DATA) $(call get_nonpic_object) 
$(DESTDIR)$(libdir)/xenomai/bootstrap.o || true
 
 uninstall-local:
        $(RM) -r $(DESTDIR)$(libdir)/xenomai
diff --git a/scripts/xeno-config-cobalt.in b/scripts/xeno-config-cobalt.in
index fec0e28..f4b7059 100644
--- a/scripts/xeno-config-cobalt.in
+++ b/scripts/xeno-config-cobalt.in
@@ -8,6 +8,7 @@ datarootdir="@datarootdir@"
 datadir="@datadir@"
 pkgdatadir="${datadir}/@PACKAGE@"
 includedir="@includedir@"
+codegen="@default_codegen@"
 
 XENO_VERSION="@PACKAGE_VERSION@"
 XENO_PREFIX="${staging}${prefix}"
@@ -18,10 +19,8 @@ XENO_BASE_CFLAGS="-I$XENO_INCLUDE_DIR/cobalt 
-I$XENO_INCLUDE_DIR @XENO_USER_APP_
 XENO_POSIX_LDFLAGS="-L${staging}${libdir} -lcobalt -lpthread -lrt 
@XENO_USER_APP_LDFLAGS@"
 XENO_LIBRARY_DIR="${staging}${libdir}"
 LD_FILE_OPTION="@LD_FILE_OPTION@"
-WRAP_MAIN_OPT="${staging}${libdir}/xenomai/bootstrap.o -Wl,--wrap=main 
-Wl,--dynamic-list=${XENO_LIBRARY_DIR}/dynlist.ld"
-WRAP_MAIN="$WRAP_MAIN_OPT"
 
-unset prefix exec_prefix libdir datadir datarootdir pkgdatadir includedir 
skin_list compat
+unset skin_list compat
 
 dump_wrappers()
 {
@@ -57,6 +56,7 @@ Options :
         --cflags
         --ldflags
         --lib*-dir,--libdir,--user-libdir
+        --no-pic, --nopic
         --core
         --info
         --compat
@@ -109,6 +109,8 @@ fi
 do_ldflags=
 do_cflags=
 do_setinit=
+do_autoinit=y
+do_nopic=
 
 while test $# -gt 0; do
     case "$1" in
@@ -133,11 +135,14 @@ while test $# -gt 0; do
             ;;
        --no-auto-init)
            do_setinit=y
-           WRAP_MAIN=
+           do_autoinit=
            ;;
        --auto-init)
            do_setinit=y
-           WRAP_MAIN="$WRAP_MAIN_OPT"
+           do_autoinit=y
+           ;;
+       --no-pic|--nopic)
+           do_nopic=y
            ;;
         --lib*-dir|--libdir|--user-libdir)
             echo $XENO_LIBRARY_DIR
@@ -249,7 +254,12 @@ if test x$do_ldflags = xy; then
                ;;
        esac
     done
-    echo "$ldflags $copperplate $WRAP_MAIN $XENO_POSIX_LDFLAGS"
+    wrap_main=
+    if test x$do_autoinit = xy; then
+       test x$do_nopic = xy && codegen=
+       wrap_main="${XENO_LIBRARY_DIR}/xenomai/bootstrap${codegen}.o 
-Wl,--wrap=main -Wl,--dynamic-list=${XENO_LIBRARY_DIR}/dynlist.ld"
+    fi
+    echo "$ldflags $copperplate $wrap_main $XENO_POSIX_LDFLAGS"
 fi
 
 exit 0
diff --git a/scripts/xeno-config-mercury.in b/scripts/xeno-config-mercury.in
index 04fed80..c67652b 100644
--- a/scripts/xeno-config-mercury.in
+++ b/scripts/xeno-config-mercury.in
@@ -8,6 +8,7 @@ datarootdir="@datarootdir@"
 datadir="@datadir@"
 pkgdatadir="${datadir}/@PACKAGE@"
 includedir="@includedir@"
+codegen="@default_codegen@"
 
 XENO_VERSION="@PACKAGE_VERSION@"
 XENO_PREFIX="${staging}${prefix}"
@@ -17,10 +18,8 @@ XENO_INCLUDE_DIR="${staging}${includedir}"
 XENO_BASE_CFLAGS="-I$XENO_INCLUDE_DIR/mercury -I$XENO_INCLUDE_DIR 
@XENO_USER_APP_CFLAGS@ -D__MERCURY__"
 XENO_BASE_LDFLAGS="-L${staging}${libdir} -lmercury -lpthread -lrt 
@XENO_USER_APP_LDFLAGS@"
 XENO_LIBRARY_DIR="${staging}${libdir}"
-WRAP_MAIN_OPT="${staging}${libdir}/xenomai/bootstrap.o -Wl,--wrap=main 
-Wl,--dynamic-list=${XENO_LIBRARY_DIR}/dynlist.ld"
-WRAP_MAIN="$WRAP_MAIN_OPT"
 
-unset prefix exec_prefix libdir datadir datarootdir pkgdatadir includedir 
skin_list
+unset skin_list
 
 usage ()
 {
@@ -39,6 +38,7 @@ Options :
         --cflags
         --ldflags
         --lib*-dir,--libdir,--user-libdir
+        --no-pic, --nopic
         --core
         --info
 EOF
@@ -80,6 +80,8 @@ fi
 do_ldflags=
 do_cflags=
 do_setinit=
+do_autoinit=y
+do_nopic=
 
 while test $# -gt 0; do
     case "$1" in
@@ -101,11 +103,14 @@ while test $# -gt 0; do
             ;;
        --no-auto-init)
            do_setinit=y
-           WRAP_MAIN=
+           do_autoinit=
            ;;
        --auto-init)
            do_setinit=y
-           WRAP_MAIN="$WRAP_MAIN_OPT"
+           do_autoinit=y
+           ;;
+       --no-pic|--nopic)
+           do_nopic=y
            ;;
         --lib*-dir|--libdir|--user-libdir)
             echo $XENO_LIBRARY_DIR
@@ -193,7 +198,12 @@ if test x$do_ldflags = xy; then
                ;;
        esac
     done
-    echo "$ldflags $copperplate $WRAP_MAIN $XENO_BASE_LDFLAGS"
+    wrap_main=
+    if test x$do_autoinit = xy; then
+       test x$do_nopic = xy && codegen=
+       wrap_main="${XENO_LIBRARY_DIR}/xenomai/bootstrap${codegen}.o 
-Wl,--wrap=main -Wl,--dynamic-list=${XENO_LIBRARY_DIR}/dynlist.ld"
+    fi
+    echo "$ldflags $copperplate $wrap_main $XENO_BASE_LDFLAGS"
 fi
 
 exit 0


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to