Skip to contentSkip to conversation

scripts/xeno-config: add -Wl,--no-as-needed

PATCH Applied Henning Schild 2 participants 2 messages May 16, 2017 – May 21, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/xeno-config: add -Wl,--no-as-needed

Linking with "--as-needed" could cause the linker to not list essential wrapping libraries as needed for a shared library or a dynamically linked binary. The result would be runtime ld.so errors for the binaries or linking problems with the .so.
gcc defaults to "--no-as-needed" that is why we never needed to specify that flag explicitly. But gcc from Ubuntu is patched to default to "--as-needed".
This patch enforces "--no-as-needed", which will have no effect on most toolchains. On Ubuntu it will override the default and make sure xenomai applications get linked as expected.

---
 scripts/xeno-config-cobalt.in  | 1 +
 scripts/xeno-config-mercury.in | 1 +
 2 files changed, 2 insertions(+)
scripts/xeno-config-cobalt.in +1 -0
index 82815e1936..ae313d3897 100644
@@ -282,6 +282,7 @@ if test x$do_ldflags = xy; then
 	fi
 	bootstrap="${XENO_LIBRARY_DIR}/xenomai/bootstrap${codegen}.o"
     fi
+    ldflags="-Wl,--no-as-needed $ldflags"
     echo "$ldflags $copperplate $bootstrap $wrap_main $XENO_POSIX_LDFLAGS"
 fi
 
scripts/xeno-config-mercury.in +1 -0
index a0aa75b737..2d2842f300 100644
@@ -213,6 +213,7 @@ if test x$do_ldflags = xy; then
 	fi
 	bootstrap="${XENO_LIBRARY_DIR}/xenomai/bootstrap${codegen}.o"
     fi
+    ldflags="-Wl,--no-as-needed $ldflags"
     echo "$ldflags $copperplate $bootstrap $wrap_main $XENO_BASE_LDFLAGS"
 fi
 
Signature · 1 line
2.13.0
#1 lore raw
Quoted 35 lines · Henning Schild

Linking with "--as-needed" could cause the linker to not list essential wrapping libraries as needed for a shared library or a dynamically linked binary. The result would be runtime ld.so errors for the binaries or linking problems with the .so.
gcc defaults to "--no-as-needed" that is why we never needed to specify that flag explicitly. But gcc from Ubuntu is patched to default to "--as-needed".
This patch enforces "--no-as-needed", which will have no effect on most toolchains. On Ubuntu it will override the default and make sure xenomai applications get linked as expected.

---
 scripts/xeno-config-cobalt.in  | 1 +
 scripts/xeno-config-mercury.in | 1 +
 2 files changed, 2 insertions(+)
scripts/xeno-config-cobalt.in +1 -0
index 82815e1936..ae313d3897 100644
@@ -282,6 +282,7 @@ if test x$do_ldflags = xy; then
 	fi
 	bootstrap="${XENO_LIBRARY_DIR}/xenomai/bootstrap${codegen}.o"
     fi
+    ldflags="-Wl,--no-as-needed $ldflags"
     echo "$ldflags $copperplate $bootstrap $wrap_main $XENO_POSIX_LDFLAGS"
 fi
 
scripts/xeno-config-mercury.in +0 -0
index a0aa75b737..2d2842f300 100644

scripts/xeno-config-mercury.in if test x$do_ldflags = xy; then · line 219

Quoted 7 lines
scripts/xeno-config-mercury.in +1 -0
@@ -213,6 +213,7 @@ if test x$do_ldflags = xy; then
 	fi
 	bootstrap="${XENO_LIBRARY_DIR}/xenomai/bootstrap${codegen}.o"
     fi
+    ldflags="-Wl,--no-as-needed $ldflags"
     echo "$ldflags $copperplate $bootstrap $wrap_main $XENO_BASE_LDFLAGS"
 fi
 

Merged, thanks.

Signature · 1 line
Philippe.