From e46c5c455c4eceb5dac5e86611d039c6c7089d6e Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Wed, 7 Mar 2018 13:11:03 -0600 Subject: [PATCH] Avoid empty libtool -export-symbols-regex pattern Currently, in LT_LDLIB_shlib_missing, we construct our -export-symbols-regex pattern like so (with some escaping): "($(sed -e 's/^/^/' -e 's/$/$/' xxx.sym | tr '\n' '|' | sed -e 's/|$//'))" The idea is that for a .sym file consisting of, for example: foo bar We then generate a regex like (^foo$|^bar$). However, since the 'tr' removes all newlines, the line given to the last 'sed' in the pipeline has no trailing newline. On some systems, such as Solaris, this causes sed to not output anything at all, resulting in a regex pattern of just "()". For example: # on Debian $ echo -n foo | sed -e 's/foo/bar/' bar$ # on Solaris $ echo -n foo | sed -e 's/foo/bar/' $ To avoid this, we can change the sed pipeline to not remove the newlines until the very end. Change the way we construct our regex to this instead: "($(sed -e 's/^/^/' -e 's/$/$|/' -e '$ s/|$//' xxx.sym | tr -d '\n'))" So the sed removes the extra '|' in the last element by looking at the last line, instead of looking at the end of the line after the 'tr' conversion. Reviewed-on: https://gerrit.openafs.org/12944 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk (cherry picked from commit d0805d72b7a48dcaa7abe1aea136a8cd963d76c2) Change-Id: Iebf0996e63c6233bebbf855cde21094a73fbd420 Reviewed-on: https://gerrit.openafs.org/12949 Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Benjamin Kaduk --- src/config/Makefile.config.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config/Makefile.config.in b/src/config/Makefile.config.in index af51d6ecc..90a47f3ac 100644 --- a/src/config/Makefile.config.in +++ b/src/config/Makefile.config.in @@ -260,8 +260,8 @@ LT_LDLIB_shlib_common=$(LIBTOOL) --quiet --mode=link --tag=CC \ LT_LDLIB_shlib=$(LT_LDLIB_shlib_common) -export-symbols $(srcdir)/$@.sym LT_LDLIB_shlib_missing=$(LT_LDLIB_shlib_common) -export-symbols-regex \ - "($$(sed -e 's/^/^/' -e 's/$$/$$/' $(srcdir)/$@.sym | tr '\n' '|' | \ - sed -e 's/|$$//'))" + "($$(sed -e 's/^/^/' -e 's/$$/$$|/' -e '$$ s/|$$//' $(srcdir)/$@.sym | \ + tr -d '\n'))" # Link a static convenience library (contains no PIC code) LT_LDLIB_static=$(LIBTOOL) --quiet --mode=link --tag=CC \ -- 2.39.5