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

fix build with lld linker #2880

Merged
merged 1 commit into from
Jun 14, 2023
Merged

fix build with lld linker #2880

merged 1 commit into from
Jun 14, 2023

Conversation

kraj
Copy link
Contributor

@kraj kraj commented Jun 12, 2023

was added this symbol comes from libgpg-error however, therefore its needed to add -lgpg-error to cmdline to resolve this symbol especially with gold and lld linker. Fixes

aarch64-yoe-linux-ld.lld: error: undefined reference due to --no-allow-shlib-undefined: gpg_strerror_r

referenced by ./.libs/libostree-1.so

@openshift-ci
Copy link

openshift-ci bot commented Jun 12, 2023

Hi @kraj. Thanks for your PR.

I'm waiting for a ostreedev member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@kraj kraj changed the title With f461c02bb55bf2853a3b81ed5c8618040ab54e98 use of gpg_strerror_r fix build with lld linker Jun 12, 2023
@dbnicholson
Copy link
Member

/ok-to-test

@cgwalters cgwalters enabled auto-merge June 13, 2023 20:11
@@ -191,7 +191,7 @@ libostree_1_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/bsdiff -I$(srcdir)/libglnx -I$(
-DPKGLIBEXECDIR=\"$(pkglibexecdir)\"
libostree_1_la_LDFLAGS = -version-number 1:0:0 -Bsymbolic-functions $(addprefix $(wl_versionscript_arg),$(symbol_files))
libostree_1_la_LIBADD = libotutil.la libglnx.la libbsdiff.la $(OT_INTERNAL_GIO_UNIX_LIBS) $(OT_INTERNAL_GPGME_LIBS) \
$(OT_DEP_LZMA_LIBS) $(OT_DEP_ZLIB_LIBS) $(OT_DEP_CRYPTO_LIBS)
$(OT_DEP_LZMA_LIBS) $(OT_DEP_ZLIB_LIBS) $(OT_DEP_CRYPTO_LIBS) $(OT_DEP_GPG_ERROR_LIBS)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, strange that $(OT_INTERNAL_GPGME_LIBS) doesn't already have this. Oh, I think this is a small regression from dd98a2a. In the case that you don't have the gpgme pkg-config file then it falls back to using gpgme-config and gpg-error-config and ultimately does:

OT_DEP_GPGME_LIBS="${OT_DEP_GPGME_LIBS} ${OT_DEP_GPG_ERROR_LIBS}"

However, in the case that you do have the gpgme pkg-config file then it doesn't do that. I think the more appropriate fix is to actually explicitly include gpg-error in the initial gpgme pkg-config check since apparently this user's gpgme.pc doesn't include it and we're currently not doing anything with the checked value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kraj could you try this change instead:

diff --git a/configure.ac b/configure.ac
index f7ae2d64b..5d6023660 100644
--- a/configure.ac
+++ b/configure.ac
@@ -242,9 +242,7 @@ AC_ARG_WITH(gpgme,
            AS_HELP_STRING([--with-gpgme], [Use gpgme @<:@default=yes@:>@]),
            [], [with_gpgme=yes])
 AS_IF([test x$with_gpgme != xno], [
-    have_gpgme=yes
-    PKG_CHECK_MODULES([OT_DEP_GPGME], gpgme >= $LIBGPGME_DEPENDENCY, [], have_gpgme=no)
-    PKG_CHECK_MODULES([OT_DEP_GPG_ERROR], [gpg-error], [], have_gpgme=no)
+    PKG_CHECK_MODULES([OT_DEP_GPGME], [gpgme >= $LIBGPGME_DEPENDENCY gpg-error], [have_gpgme=yes], [have_gpgme=no])
     ]
 )
 AS_IF([test x$with_gpgme != xno && test x$have_gpgme != xyes], [

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But wouldn't that make us start hard failing on sytems without gpg-error?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it will do anything different. All that does is merge the pkg-config checks, but you already would have fallen into the have_gpgme=no case if you didn't have gpg-error. That said, gpg-error is already a hard requirement for gpgme. I'm frankly surprised that pkg-config --libs gpgme doesn't include -lgpg-error for @kraj already. It does on my system, but this whole area has been built on downstream hacks for a long time since upstream wouldn't just DTRT. What I'm proposing above likely fixes the issue, but it's also more correct since libostree directly calls gpg_strerror_r from gpg-error when GPG support is in use.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kraj could you try this change instead:

diff --git a/configure.ac b/configure.ac
index f7ae2d64b..5d6023660 100644
--- a/configure.ac
+++ b/configure.ac
@@ -242,9 +242,7 @@ AC_ARG_WITH(gpgme,
            AS_HELP_STRING([--with-gpgme], [Use gpgme @<:@default=yes@:>@]),
            [], [with_gpgme=yes])
 AS_IF([test x$with_gpgme != xno], [
-    have_gpgme=yes
-    PKG_CHECK_MODULES([OT_DEP_GPGME], gpgme >= $LIBGPGME_DEPENDENCY, [], have_gpgme=no)
-    PKG_CHECK_MODULES([OT_DEP_GPG_ERROR], [gpg-error], [], have_gpgme=no)
+    PKG_CHECK_MODULES([OT_DEP_GPGME], [gpgme >= $LIBGPGME_DEPENDENCY gpg-error], [have_gpgme=yes], [have_gpgme=no])
     ]
 )
 AS_IF([test x$with_gpgme != xno && test x$have_gpgme != xyes], [

The configure.ac change works for me too. The reason I am seeing it is because I am using lld linker which does not have bfd linker linker transitive dependency checker. it will fail with gold linker too perhaps in same way.

@dbnicholson do you want me to update this pull with your suggestion ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configure.ac change works for me too. The reason I am seeing it is because I am using lld linker which does not have bfd linker linker transitive dependency checker. it will fail with gold linker too perhaps in same way.

That part makes sense. We definitely need -lgpg-error one way or another because the gpg_strerror_r symbol needs to be resolved from libostree. What I'm surprised about is how you were getting a link command that didn't already include it because pkg-config --libs gpgme should contain it.

Ah, now I see this upstream commit that changes from Requires to Requires.private. My installed version doesn't have that. That is correct but also does break libostree without this change as noted in the commit message:

It will break build of an application which directly uses gpg-error or libassuan without specifying them

So, yes, I think this was the correct fix for the issue.

kraj added a commit to kraj/ostree that referenced this pull request Jun 14, 2023
With f461c02 use of gpg_strerror_r
was added this symbol comes from libgpg-error however, therefore its
needed to add -lgpg-error to cmdline to resolve this symbol especially
with gold and lld linker. Fixes

aarch64-yoe-linux-ld.lld: error: undefined reference due to --no-allow-shlib-undefined: gpg_strerror_r
>>> referenced by ./.libs/libostree-1.so

Upstream-Status: Submitted [ostreedev#2880]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
With f461c02 use of gpg_strerror_r
was added this symbol comes from libgpg-error however, therefore its
needed to add -lgpg-error to cmdline to resolve this symbol especially
with gold and lld linker. Fixes

aarch64-yoe-linux-ld.lld: error: undefined reference due to --no-allow-shlib-undefined: gpg_strerror_r
>>> referenced by ./.libs/libostree-1.so
@dbnicholson dbnicholson merged commit ff805f1 into ostreedev:main Jun 14, 2023
20 checks passed
quaresmajose pushed a commit to quaresmajose/ostree that referenced this pull request Jun 23, 2023
With f461c02 use of gpg_strerror_r
was added this symbol comes from libgpg-error however, therefore its
needed to add -lgpg-error to cmdline to resolve this symbol especially
with gold and lld linker. Fixes

aarch64-yoe-linux-ld.lld: error: undefined reference due to --no-allow-shlib-undefined: gpg_strerror_r
>>> referenced by ./.libs/libostree-1.so

Upstream-Status: Submitted [ostreedev#2880]
Signed-off-by: Khem Raj <raj.khem@gmail.com>

%% original patch: 0001-libostree-Link-with-libgpg-error-for-gpg_strerror_r-.patch
quaresmajose pushed a commit to quaresmajose/ostree that referenced this pull request Jun 23, 2023
With f461c02 use of gpg_strerror_r
was added this symbol comes from libgpg-error however, therefore its
needed to add -lgpg-error to cmdline to resolve this symbol especially
with gold and lld linker. Fixes

aarch64-yoe-linux-ld.lld: error: undefined reference due to --no-allow-shlib-undefined: gpg_strerror_r
>>> referenced by ./.libs/libostree-1.so

Upstream-Status: Submitted [ostreedev#2880]
Signed-off-by: Khem Raj <raj.khem@gmail.com>

%% original patch: 0001-libostree-Link-with-libgpg-error-for-gpg_strerror_r-.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants