Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys-libs/db: use --version-script instead of --default-symver for ld.{gold,lld} #19100

Closed
wants to merge 1 commit into from

Conversation

telans
Copy link
Contributor

@telans telans commented Jan 18, 2021

ld.{gold,lld} do not supprt --default-symver. Using the --version-script script provided fixes configure and outputs symbol names matching --default-symver.

ld.bfd (default-symver) ld.{gold,lld} (version-script)
T __txn_stat_print_pp@@libdb-6.0.so@@libdb-6.0.so
T __txn_updateckp@@libdb-6.0.so@@libdb-6.0.so
D __txn_xa_regop_42_desc@@libdb-6.0.so@@libdb-6.0.so
T __txn_xa_regop_42_verify@@libdb-6.0.so@@libdb-6.0.so
T __ua_memcpy@@libdb-6.0.so@@libdb-6.0.so
T __txn_stat_print_pp@@libdb-6.0.so@@libdb-6.0.so
T __txn_updateckp@@libdb-6.0.so@@libdb-6.0.so
D __txn_xa_regop_42_desc@@libdb-6.0.so@@libdb-6.0.so
T __txn_xa_regop_42_verify@@libdb-6.0.so@@libdb-6.0.so
T __ua_memcpy@@libdb-6.0.so@@libdb-6.0.so

Closes: https://bugs.gentoo.org/729510
Closes: https://bugs.gentoo.org/595108
Package-Manager: Portage-3.0.13, Repoman-3.0.2
Signed-off-by: Theo Anderson telans@posteo.de

@gentoo-bot
Copy link

Pull Request assignment

Submitter: @telans
Areas affected: ebuilds
Packages affected: sys-libs/db

sys-libs/db: @gentoo/base-system

Linked bugs

Bugs linked: 595108, 729510


In order to force reassignment and/or bug reference scan, please append [please reassign] to the pull request title.

Docs: Code of ConductCopyright policy (expl.) ● DevmanualGitHub PRsProxy-maint guide

@gentoo-bot gentoo-bot added assigned PR successfully assigned to the package maintainer(s). bug linked Bug/Closes found in footer, and cross-linked with the PR. labels Jan 18, 2021
@gentoo-repo-qa-bot
Copy link
Collaborator

Pull request CI report

Report generated at: 2021-01-18 05:30 UTC
Newest commit scanned: 55db4fe
Status: ✅ good

There are existing issues already. Please look into the report to make sure none of them affect the packages in question:
https://qa-reports.gentoo.org/output/gentoo-ci/80e82439f6/output.html

@Arfrever
Copy link
Contributor

Not having versions of symbols (which is currently done by -Wl,--default-symver) will degrade ABI and allow run-time collisions of symbols in programs, which through their dependencies pull multiple versions of sys-libs/db.

See versions of symbols:

$ (for lib in /usr/lib64/libdb-*.so; do echo "==================== ${lib##*/} ===================="; nm -CD --with-symbol-versions "${lib}" | grep @@libdb; done)

@telans
Copy link
Contributor Author

telans commented Jan 18, 2021

Would you mind taking a gander at this?

diff --git a/sys-libs/db/db-6.0.35-r3.ebuild b/sys-libs/db/db-6.0.35-r3.ebuild
index f1c5a7c3c5d..ac543a7e914 100644
--- a/sys-libs/db/db-6.0.35-r3.ebuild
+++ b/sys-libs/db/db-6.0.35-r3.ebuild
@@ -116,6 +116,11 @@ src_prepare() {
 	sed \
 		-e '/db_repsite/s,Skipping:,Skipping,g' \
 		-i "${S_BASE}"/test/tcl/reputils.tcl || die
+
+	# Version script for ld.{gold,lld} which do not supprt --default-symver
+	cat > "${S}"/db-version-script.ver <<-EOF
+	libdb-${SLOT}.so {*;};
+	EOF
 }
 
 multilib_src_configure() {
@@ -147,7 +152,12 @@ multilib_src_configure() {
 	# Add linker versions to the symbols. Easier to do, and safer than header file
 	# mumbo jumbo.
 	if use userland_GNU ; then
-		append-ldflags -Wl,--default-symver
+		# ld.{gold,lld} do not supprt --default-symver
+		if tc-ld-is-gold || tc-ld-is-lld; then
+			append-ldflags -Wl,--version-script="${S}"/db-version-script.ver
+		else
+			append-ldflags -Wl,--default-symver
+		fi
 	fi
 
 	# use `set` here since the java opts will contain whitespace

Using that --version-script results in symbol names which mimick --default-symver:

I'll push this change as it seems acceptable to me.

uses --version-script instead of --default-symver for ld.{gold,lld}
as they do not support --default-symver

Closes: https://bugs.gentoo.org/729510
Closes: https://bugs.gentoo.org/595108
Package-Manager: Portage-3.0.13, Repoman-3.0.2
Signed-off-by: Theo Anderson <telans@posteo.de>
@telans telans changed the title sys-libs/db: fix configure with ld.{gold,lld} sys-libs/db: use --version-script instead of --default-symver for ld.{gold,lld} Jan 18, 2021
@gentoo-repo-qa-bot
Copy link
Collaborator

Pull request CI report

Report generated at: 2021-01-18 22:50 UTC
Newest commit scanned: b5f83f2
Status: ✅ good

There are existing issues already. Please look into the report to make sure none of them affect the packages in question:
https://qa-reports.gentoo.org/output/gentoo-ci/abde752cd4/output.html

@Arfrever
Copy link
Contributor

Besides libdb-${SLOT}.so, there are few other libraries.
E.g. USE="cxx" enables libdb_cxx-${SLOT}.so and libdb_stl-${SLOT}.so.

Currently defined symbols in libdb_cxx-${SLOT}.so have version libdb_cxx-${SLOT}.so, and defined symbols in libdb_stl-${SLOT}.so have version libdb_stl-${SLOT}.so.

Using your version script (with libdb-${SLOT}.so {*;};) for all libraries would result in using the same version libdb-${SLOT}.so for all libraries.
This could still be problem, because there are symbols differing only in their versions.
Example:

$ nm -CD --with-symbol-versions /usr/lib64/libdb-5.3.so | grep db_create@@libdb
000000000003e980 T __bam_db_create@@libdb-5.3.so
0000000000062ea0 T __ham_db_create@@libdb-5.3.so
000000000007bde0 T __heap_db_create@@libdb-5.3.so
0000000000085e10 T __qam_db_create@@libdb-5.3.so
00000000001134a0 T db_create@@libdb-5.3.so
$ nm -CD --with-symbol-versions /usr/lib64/libdb_cxx-5.3.so | grep db_create@@libdb
0000000000062c50 T __bam_db_create@@libdb_cxx-5.3.so
0000000000087170 T __ham_db_create@@libdb_cxx-5.3.so
00000000000a0090 T __heap_db_create@@libdb_cxx-5.3.so
00000000000aa0c0 T __qam_db_create@@libdb_cxx-5.3.so
0000000000137730 T db_create@@libdb_cxx-5.3.so
$ nm -CD --with-symbol-versions /usr/lib64/libdb_stl-5.3.so | grep db_create@@libdb
0000000000073540 T __bam_db_create@@libdb_stl-5.3.so
0000000000097a60 T __ham_db_create@@libdb_stl-5.3.so
00000000000b0980 T __heap_db_create@@libdb_stl-5.3.so
00000000000ba9b0 T __qam_db_create@@libdb_stl-5.3.so
0000000000148020 T db_create@@libdb_stl-5.3.so

So you would need to create separate and slightly different version scripts for each library.

@telans telans marked this pull request as draft January 18, 2021 23:22
@telans
Copy link
Contributor Author

telans commented Jan 18, 2021

Thanks for the tips, this definitely requires more work.

@telans
Copy link
Contributor Author

telans commented Jan 19, 2021

Closing in favour of #19116 which matches tc-ld-diable-gold within these ebuilds.

@telans telans closed this Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assigned PR successfully assigned to the package maintainer(s). bug linked Bug/Closes found in footer, and cross-linked with the PR.
Projects
None yet
4 participants