build: Derive object names in make_sunver.pl

The recent move of libgfortran object files to subdirs and the resulting
breakage of libgfortran.so symbol exports demonstrated how fragile
deriving object and archive names from their libtool counterparts in the
Makefiles is.  Therefore, this patch moves that step into
make_sunver.pl, considerably simplifying the Makefile rules to create
the version scripts.

Bootstrapped without regressions on i386-pc-solaris2.11 and
sparc-sun-solaris2.11, verifying that the version scripts are identical
except for the input filenames.

2024-05-06  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	contrib:
	* make_sunver.pl: Use File::Basename;
	Skip -lLIB args.
	Convert libtool object/archive names to underlying
	objects/archives.

	libatomic:
	* Makefile.am [LIBAT_BUILD_VERSIONED_SHLIB_SUN]
	(libatomic.map-sun): Pass $(libatomic_la_OBJECTS),
	$(libatomic_la_LIBADD) to make_sunver.pl unmodified.
	* Makefile.in: Regenerate.

	libffi:
	* Makefile.am [LIBFFI_BUILD_VERSIONED_SHLIB_SUN] (libffi.map-sun):
	Pass $(libffi_la_OBJECTS), $(libffi_la_LIBADD) to make_sunver.pl
	unmodified.
	* Makefile.in: Regenerate.

	libgfortran:
	* Makefile.am [LIBGFOR_USE_SYMVER_SUN} (gfortran.ver-sun): Pass
	$(libgfortran_la_OBJECTS), $(libgfortran_la_LIBADD) to
	make_sunver.pl unmodified.
	* Makefile.in: Regenerate.

	libgomp:
	* Makefile.am [LIBGOMP_BUILD_VERSIONED_SHLIB_SUN]
	(libgomp.ver-sun): Pass $(libgomp_la_OBJECTS),
	$(libgomp_la_LIBADD) to make_sunver.pl unmodified.
	* Makefile.in: Regenerate.

	libitm:
	* Makefile.am [LIBITM_BUILD_VERSIONED_SHLIB_SUN] (libitm.map-sun):
	Pass $(libitm_la_OBJECTS), $(libitm_la_LIBADD) to make_sunver.pl
	unmodified.
	* Makefile.in: Regenerate.

	libquadmath:
	* Makefile.am [LIBQUAD_USE_SYMVER_SUN] (quadmath.map-sun): Pass
	$(libquadmath_la_OBJECTS), $(libquadmath_la_LIBADD) to
	make_sunver.pl unmodified.
	* Makefile.in: Regenerate.

	libssp:
	* Makefile.am [LIBSSP_USE_SYMVER_SUN] (ssp.map-sun): Pass
	$(libssp_la_OBJECTS), $(libssp_la_LIBADD) to make_sunver.pl
	unmodified.
	* Makefile.in: Regenerate.

	libstdc++-v3:
	* src/Makefile.am [ENABLE_SYMVERS_SUN]
	(libstdc++-symbols.ver-sun): Pass $(libstdc___la_OBJECTS),
	$(libstdc___la_LIBADD) to make_sunver.pl unmodified.
	* src/Makefile.in: Regenerate.
This commit is contained in:
Rainer Orth 2024-05-07 13:14:05 +02:00
parent b09c2e9560
commit 35b05a02de
17 changed files with 29 additions and 46 deletions

View File

@ -17,6 +17,7 @@
# GNU mangling style.
use FileHandle;
use File::Basename;
use IPC::Open2;
# Enforce C locale.
@ -37,12 +38,22 @@ my @OBJECTS = ();
# List of shared objects to omit from processing.
my @SHAREDOBJS = ();
# Filter out those input archives that have corresponding shared objects to
# avoid adding all symbols matched in the archive to the output map.
foreach $file (@ARGV) {
# Filter out those input archives that have corresponding shared objects to
# avoid adding all symbols matched in the archive to the output map.
if (($so = $file) =~ s/\.a$/.so/ && -e $so) {
printf STDERR "omitted $file -> $so\n";
push (@SHAREDOBJS, $so);
# Skip libraries.
} elsif ($file =~ /^-l/) {
next;
# Convert libtool object/archive names to underlying objects/archives.
} elsif ($file =~ /\.l[ao]$/) {
my ($name, $path, $suffix) = fileparse($file, ".l[ao]");
$suffix =~ s/l//;
# Strip leading ./ prepended by fileparse.
$path =~ s%^\./%%;
push (@OBJECTS, "$path.libs/$name$suffix")
} else {
push (@OBJECTS, $file);
}

View File

@ -55,9 +55,7 @@ libatomic.map-sun : $(top_srcdir)/libatomic.map \
$(libatomic_la_OBJECTS) $(libatomic_la_LIBADD)
perl $(top_srcdir)/../contrib/make_sunver.pl \
$(top_srcdir)/libatomic.map \
$(libatomic_la_OBJECTS:%.lo=.libs/%.o) \
`echo $(libatomic_la_LIBADD) | \
sed 's,\([^/ ]*\)\.l\([ao]\),.libs/\1.\2,g'` \
$(libatomic_la_OBJECTS) $(libatomic_la_LIBADD) \
> $@ || (rm -f $@ ; exit 1)
endif
else

View File

@ -888,9 +888,7 @@ vpath % $(strip $(search_path))
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@ $(libatomic_la_OBJECTS) $(libatomic_la_LIBADD)
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@ perl $(top_srcdir)/../contrib/make_sunver.pl \
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@ $(top_srcdir)/libatomic.map \
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@ $(libatomic_la_OBJECTS:%.lo=.libs/%.o) \
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@ `echo $(libatomic_la_LIBADD) | \
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@ sed 's,\([^/ ]*\)\.l\([ao]\),.libs/\1.\2,g'` \
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@ $(libatomic_la_OBJECTS) $(libatomic_la_LIBADD) \
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@ > $@ || (rm -f $@ ; exit 1)
-include $(wildcard $(DEPDIR)/*.Ppo)

View File

@ -200,8 +200,7 @@ libffi_version_dep = libffi.map-sun
libffi.map-sun : libffi.map $(top_srcdir)/../contrib/make_sunver.pl \
$(libffi_la_OBJECTS) $(libffi_la_LIBADD)
perl $(top_srcdir)/../contrib/make_sunver.pl libffi.map \
`echo $(libffi_la_OBJECTS) $(libffi_la_LIBADD) | \
sed 's,\([^/ ]*\)\.l\([ao]\),.libs/\1.\2,g'` \
$(libffi_la_OBJECTS) $(libffi_la_LIBADD) \
> $@ || (rm -f $@ ; exit 1)
endif
else

View File

@ -1940,8 +1940,7 @@ stamp-build-info: doc/libffi.texi $(srcdir)/doc/version.texi doc/$(am__dirstamp)
@LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi.map-sun : libffi.map $(top_srcdir)/../contrib/make_sunver.pl \
@LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@ $(libffi_la_OBJECTS) $(libffi_la_LIBADD)
@LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@ perl $(top_srcdir)/../contrib/make_sunver.pl libffi.map \
@LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@ `echo $(libffi_la_OBJECTS) $(libffi_la_LIBADD) | \
@LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@ sed 's,\([^/ ]*\)\.l\([ao]\),.libs/\1.\2,g'` \
@LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@ $(libffi_la_OBJECTS) $(libffi_la_LIBADD) \
@LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@ > $@ || (rm -f $@ ; exit 1)
libffi.map: $(top_srcdir)/libffi.map.in

View File

@ -29,9 +29,7 @@ gfortran.ver-sun : gfortran.ver \
$(libgfortran_la_OBJECTS) $(libgfortran_la_LIBADD)
perl $(top_srcdir)/../contrib/make_sunver.pl \
gfortran.ver \
$(subst /,/.libs/,$(libgfortran_la_OBJECTS:.lo=.o)) \
`echo $(libgfortran_la_LIBADD) | \
sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
$(libgfortran_la_OBJECTS) $(libgfortran_la_LIBADD) \
> $@ || (rm -f $@ ; exit 1)
endif
else

View File

@ -4576,9 +4576,7 @@ uninstall-am: uninstall-cafexeclibLTLIBRARIES uninstall-gfor_cHEADERS \
@LIBGFOR_USE_SYMVER_SUN_TRUE@@LIBGFOR_USE_SYMVER_TRUE@ $(libgfortran_la_OBJECTS) $(libgfortran_la_LIBADD)
@LIBGFOR_USE_SYMVER_SUN_TRUE@@LIBGFOR_USE_SYMVER_TRUE@ perl $(top_srcdir)/../contrib/make_sunver.pl \
@LIBGFOR_USE_SYMVER_SUN_TRUE@@LIBGFOR_USE_SYMVER_TRUE@ gfortran.ver \
@LIBGFOR_USE_SYMVER_SUN_TRUE@@LIBGFOR_USE_SYMVER_TRUE@ $(subst /,/.libs/,$(libgfortran_la_OBJECTS:.lo=.o)) \
@LIBGFOR_USE_SYMVER_SUN_TRUE@@LIBGFOR_USE_SYMVER_TRUE@ `echo $(libgfortran_la_LIBADD) | \
@LIBGFOR_USE_SYMVER_SUN_TRUE@@LIBGFOR_USE_SYMVER_TRUE@ sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
@LIBGFOR_USE_SYMVER_SUN_TRUE@@LIBGFOR_USE_SYMVER_TRUE@ $(libgfortran_la_OBJECTS) $(libgfortran_la_LIBADD) \
@LIBGFOR_USE_SYMVER_SUN_TRUE@@LIBGFOR_USE_SYMVER_TRUE@ > $@ || (rm -f $@ ; exit 1)
# Turn on vectorization and loop unrolling for matmul.

View File

@ -44,9 +44,7 @@ libgomp.ver-sun : libgomp.ver \
$(libgomp_la_OBJECTS) $(libgomp_la_LIBADD)
perl $(top_srcdir)/../contrib/make_sunver.pl \
libgomp.ver \
$(libgomp_la_OBJECTS:%.lo=.libs/%.o) \
`echo $(libgomp_la_LIBADD) | \
sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
$(libgomp_la_OBJECTS) $(libgomp_la_LIBADD) \
> $@ || (rm -f $@ ; exit 1)
endif
else

View File

@ -1378,9 +1378,7 @@ vpath % $(strip $(search_path))
@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@ $(libgomp_la_OBJECTS) $(libgomp_la_LIBADD)
@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@ perl $(top_srcdir)/../contrib/make_sunver.pl \
@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@ libgomp.ver \
@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@ $(libgomp_la_OBJECTS:%.lo=.libs/%.o) \
@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@ `echo $(libgomp_la_LIBADD) | \
@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@ sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@ $(libgomp_la_OBJECTS) $(libgomp_la_LIBADD) \
@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@ > $@ || (rm -f $@ ; exit 1)
omp_lib_kinds.mod: omp_lib.mod

View File

@ -39,9 +39,7 @@ libitm.map-sun : $(top_srcdir)/libitm.map \
$(libitm_la_OBJECTS) $(libitm_la_LIBADD)
perl $(top_srcdir)/../contrib/make_sunver.pl \
$(top_srcdir)/libitm.map \
$(libitm_la_OBJECTS:%.lo=.libs/%.o) \
`echo $(libitm_la_LIBADD) | \
sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
$(libitm_la_OBJECTS) $(libitm_la_LIBADD) \
> $@ || (rm -f $@ ; exit 1)
endif
else

View File

@ -1179,9 +1179,7 @@ vpath % $(strip $(search_path))
@LIBITM_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBITM_BUILD_VERSIONED_SHLIB_TRUE@ $(libitm_la_OBJECTS) $(libitm_la_LIBADD)
@LIBITM_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBITM_BUILD_VERSIONED_SHLIB_TRUE@ perl $(top_srcdir)/../contrib/make_sunver.pl \
@LIBITM_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBITM_BUILD_VERSIONED_SHLIB_TRUE@ $(top_srcdir)/libitm.map \
@LIBITM_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBITM_BUILD_VERSIONED_SHLIB_TRUE@ $(libitm_la_OBJECTS:%.lo=.libs/%.o) \
@LIBITM_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBITM_BUILD_VERSIONED_SHLIB_TRUE@ `echo $(libitm_la_LIBADD) | \
@LIBITM_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBITM_BUILD_VERSIONED_SHLIB_TRUE@ sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
@LIBITM_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBITM_BUILD_VERSIONED_SHLIB_TRUE@ $(libitm_la_OBJECTS) $(libitm_la_LIBADD) \
@LIBITM_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBITM_BUILD_VERSIONED_SHLIB_TRUE@ > $@ || (rm -f $@ ; exit 1)
# Make sure -msse is appended at the end.
@ARCH_X86_TRUE@x86_sse.lo : override CXXFLAGS += -msse

View File

@ -25,8 +25,7 @@ quadmath.map-sun : $(srcdir)/quadmath.map \
$(libquadmath_la_OBJECTS) $(libquadmath_la_LIBADD)
perl $(top_srcdir)/../contrib/make_sunver.pl \
$(srcdir)/quadmath.map \
`echo $(libquadmath_la_OBJECTS) $(libquadmath_la_LIBADD) | \
sed 's,\([^/ ]*\)\.l\([ao]\),.libs/\1.\2,g'` \
$(libquadmath_la_OBJECTS) $(libquadmath_la_LIBADD) \
> $@ || (rm -f $@ ; exit 1)
endif
else

View File

@ -1434,8 +1434,7 @@ uninstall-am: uninstall-dvi-am uninstall-html-am uninstall-info-am \
@BUILD_LIBQUADMATH_TRUE@@LIBQUAD_USE_SYMVER_SUN_TRUE@@LIBQUAD_USE_SYMVER_TRUE@ $(libquadmath_la_OBJECTS) $(libquadmath_la_LIBADD)
@BUILD_LIBQUADMATH_TRUE@@LIBQUAD_USE_SYMVER_SUN_TRUE@@LIBQUAD_USE_SYMVER_TRUE@ perl $(top_srcdir)/../contrib/make_sunver.pl \
@BUILD_LIBQUADMATH_TRUE@@LIBQUAD_USE_SYMVER_SUN_TRUE@@LIBQUAD_USE_SYMVER_TRUE@ $(srcdir)/quadmath.map \
@BUILD_LIBQUADMATH_TRUE@@LIBQUAD_USE_SYMVER_SUN_TRUE@@LIBQUAD_USE_SYMVER_TRUE@ `echo $(libquadmath_la_OBJECTS) $(libquadmath_la_LIBADD) | \
@BUILD_LIBQUADMATH_TRUE@@LIBQUAD_USE_SYMVER_SUN_TRUE@@LIBQUAD_USE_SYMVER_TRUE@ sed 's,\([^/ ]*\)\.l\([ao]\),.libs/\1.\2,g'` \
@BUILD_LIBQUADMATH_TRUE@@LIBQUAD_USE_SYMVER_SUN_TRUE@@LIBQUAD_USE_SYMVER_TRUE@ $(libquadmath_la_OBJECTS) $(libquadmath_la_LIBADD) \
@BUILD_LIBQUADMATH_TRUE@@LIBQUAD_USE_SYMVER_SUN_TRUE@@LIBQUAD_USE_SYMVER_TRUE@ > $@ || (rm -f $@ ; exit 1)
@BUILD_LIBQUADMATH_TRUE@stamp-geninsrc: libquadmath.info

View File

@ -23,9 +23,7 @@ ssp.map-sun : $(srcdir)/ssp.map \
$(libssp_la_OBJECTS) $(libssp_la_LIBADD)
perl $(top_srcdir)/../contrib/make_sunver.pl \
$(srcdir)/ssp.map \
$(libssp_la_OBJECTS:%.lo=.libs/%.o) \
`echo $(libssp_la_LIBADD) | \
sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
$(libssp_la_OBJECTS) $(libssp_la_LIBADD) \
> $@ || (rm -f $@ ; exit 1)
endif
else

View File

@ -822,9 +822,7 @@ uninstall-am: uninstall-nobase_libsubincludeHEADERS \
@LIBSSP_USE_SYMVER_SUN_TRUE@@LIBSSP_USE_SYMVER_TRUE@ $(libssp_la_OBJECTS) $(libssp_la_LIBADD)
@LIBSSP_USE_SYMVER_SUN_TRUE@@LIBSSP_USE_SYMVER_TRUE@ perl $(top_srcdir)/../contrib/make_sunver.pl \
@LIBSSP_USE_SYMVER_SUN_TRUE@@LIBSSP_USE_SYMVER_TRUE@ $(srcdir)/ssp.map \
@LIBSSP_USE_SYMVER_SUN_TRUE@@LIBSSP_USE_SYMVER_TRUE@ $(libssp_la_OBJECTS:%.lo=.libs/%.o) \
@LIBSSP_USE_SYMVER_SUN_TRUE@@LIBSSP_USE_SYMVER_TRUE@ `echo $(libssp_la_LIBADD) | \
@LIBSSP_USE_SYMVER_SUN_TRUE@@LIBSSP_USE_SYMVER_TRUE@ sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
@LIBSSP_USE_SYMVER_SUN_TRUE@@LIBSSP_USE_SYMVER_TRUE@ $(libssp_la_OBJECTS) $(libssp_la_LIBADD) \
@LIBSSP_USE_SYMVER_SUN_TRUE@@LIBSSP_USE_SYMVER_TRUE@ > $@ || (rm -f $@ ; exit 1)
# GNU Make needs to see an explicit $(MAKE) variable in the command it

View File

@ -350,9 +350,7 @@ libstdc++-symbols.ver-sun : libstdc++-symbols.ver \
CXXFILT="$(CXXFILT)"; export CXXFILT; \
perl $(toplevel_srcdir)/contrib/make_sunver.pl \
libstdc++-symbols.ver \
$(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
`echo ' $(libstdc___la_LIBADD) ' | \
sed -e 's,/\([^/.]*\)\.la,/.libs/\1.a,g' -e 's/ -l[^ ]* / /'` \
$(libstdc___la_OBJECTS) $(libstdc___la_LIBADD) \
> $@ || (rm -f $@ ; exit 1)
endif
if ENABLE_SYMVERS_DARWIN

View File

@ -1096,9 +1096,7 @@ compatibility-condvar.o: compatibility-condvar.cc
@ENABLE_SYMVERS_SUN_TRUE@@ENABLE_SYMVERS_TRUE@ CXXFILT="$(CXXFILT)"; export CXXFILT; \
@ENABLE_SYMVERS_SUN_TRUE@@ENABLE_SYMVERS_TRUE@ perl $(toplevel_srcdir)/contrib/make_sunver.pl \
@ENABLE_SYMVERS_SUN_TRUE@@ENABLE_SYMVERS_TRUE@ libstdc++-symbols.ver \
@ENABLE_SYMVERS_SUN_TRUE@@ENABLE_SYMVERS_TRUE@ $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
@ENABLE_SYMVERS_SUN_TRUE@@ENABLE_SYMVERS_TRUE@ `echo ' $(libstdc___la_LIBADD) ' | \
@ENABLE_SYMVERS_SUN_TRUE@@ENABLE_SYMVERS_TRUE@ sed -e 's,/\([^/.]*\)\.la,/.libs/\1.a,g' -e 's/ -l[^ ]* / /'` \
@ENABLE_SYMVERS_SUN_TRUE@@ENABLE_SYMVERS_TRUE@ $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD) \
@ENABLE_SYMVERS_SUN_TRUE@@ENABLE_SYMVERS_TRUE@ > $@ || (rm -f $@ ; exit 1)
@ENABLE_SYMVERS_DARWIN_TRUE@@ENABLE_SYMVERS_TRUE@libstdc++-symbols.explist : libstdc++-symbols.ver \
@ENABLE_SYMVERS_DARWIN_TRUE@@ENABLE_SYMVERS_TRUE@ ${glibcxx_srcdir}/scripts/make_exports.pl \