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

[gklib] Fix build error with Android triplet #37416

Closed
wants to merge 2 commits into from

Conversation

Cheney-W
Copy link
Contributor

Fixes #36791

No feature need to be tested.

  • Changes comply with the maintainer guide.
  • SHA512s are updated for each updated download.
  • The "supports" clause reflects platforms that may be fixed by this new version.
  • Any fixed CI baseline entries are removed from that file.
  • Any patches that are no longer applied are deleted from the port's directory.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Only one version is added to each modified port's versions file.

@Cheney-W Cheney-W added category:port-bug The issue is with a library, which is something the port should already support info:internal This PR or Issue was filed by the vcpkg team. labels Mar 13, 2024
Comment on lines 9 to 10
+extern int backtrace(void **buffer, int size);
+extern char **backtrace_symbols(void *const *buffer, int size);
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, this adds a declaration, but where is the definition if not on Linux/glibc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for pointing that out. My original assumption was that these two functions wouldn't be called when not on Linux/glibc, so I didn't consider whether they were actually defined.
Now I've added conditions to them, so they're only declared if the execinfo.h header file can be found.
This is the original text in the source's CMake: check_include_file(execinfo.h HAVE_EXECINFO_H)

@Cheney-W Cheney-W marked this pull request as ready for review March 18, 2024 02:55
@LilyWangLL LilyWangLL added the info:reviewed Pull Request changes follow basic guidelines label Mar 18, 2024
Comment on lines +9 to +12
+#ifdef HAVE_EXECINFO_H
+ extern int backtrace(void **buffer, int size);
+ extern char **backtrace_symbols(void *const *buffer, int size);
+#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

If you know you have execinfo.h, and these functions are declared in execinfo.h, why don't you #include <execinfo.h>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've considered the situation you mentioned. In the issue I submitted to the upstream, I mentioned two possible solutions, one is to add #include <execinfo.h>, but I noticed that the upstream source already has the following inclusion relationship:
error.c have #include <GKlib.h>
GKlib.h have #include "gk_arch.h"
gk_arch.h have:

#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
#endif

So, instead of directly including the header file, I opted for using extended function declarations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course, these are just my personal thoughts. If you think it's better to directly include the header file, I'll adjust my PR accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, the fix is for android, not for clang-17?!
Then the tentative fix is there:
https://github.com/microsoft/vcpkg/pull/35851/files#diff-95c803e4c056c6f158a02350ea41a27b7c646b9571048daff3707d20be342f68

Copy link
Contributor

Choose a reason for hiding this comment

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

i.e. it needs API level 33.

Copy link
Member

Choose a reason for hiding this comment

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

I've considered the situation you mentioned. In the issue I submitted to the upstream, I mentioned two possible solutions, one is to add #include <execinfo.h>, but I noticed that the upstream source already has the following inclusion relationship: error.c have #include <GKlib.h> GKlib.h have #include "gk_arch.h" gk_arch.h have:

#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
#endif

So, instead of directly including the header file, I opted for using extended function declarations.

That suggests that HAVE_EXECINFO_H was off and therefore this patch doesn't do anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The error-prone code is also confined within #ifdef HAVE_EXECINFO_H,

#ifdef HAVE_EXECINFO_H
...
  size = backtrace(array, 10);
  strings = backtrace_symbols(array, size);
...
#endif

so when HAVE_EXECINFO_H is off, the error will not be triggered, and there is no need for patching work.

Copy link
Contributor

Choose a reason for hiding this comment

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

The PR's title is misleading. It is not a clang 17 issue.

The truth is that on Android execinfo.h can be present (detected) but still nthe functions are not available until raising the API level.

And the fix proposed here fixes the static lib build, but users will hit the wall when they try to link executables.

@BillyONeal BillyONeal removed the info:reviewed Pull Request changes follow basic guidelines label Mar 18, 2024
@Cheney-W Cheney-W changed the title [gklib] Fix build error with clang 17 [gklib] Fix build error with Android triplet Mar 19, 2024
@Cheney-W
Copy link
Contributor Author

@BillyONeal Is this modification the final solution to this issue? If it is, I will close my PR.

@BillyONeal
Copy link
Member

@BillyONeal Is this modification the final solution to this issue? If it is, I will close my PR.

I'm not sure this is correct either; it depends on how that macro gets actually used.

@LilyWangLL LilyWangLL marked this pull request as draft March 26, 2024 08:25
@dg0yt
Copy link
Contributor

dg0yt commented Mar 26, 2024

I'm not sure this is correct either; it depends on how that macro gets actually used.

I wouldn't have introduced the API level check if I hadn't tested it that time.
It somewhat mirrors my original comment here: It is not enough to see a declaration --- or header. You need an implementation.

@Cheney-W
Copy link
Contributor Author

Cheney-W commented Apr 1, 2024

Duplicate of #37877

@Cheney-W Cheney-W marked this as a duplicate of #37877 Apr 1, 2024
@Cheney-W Cheney-W closed this Apr 1, 2024
BillyONeal pushed a commit that referenced this pull request Apr 1, 2024
Fixes #36791. (Alternative to
#37416)
Update, remove obsolete patches, cleanup.
Enable shared linkage on !windows.
@Cheney-W Cheney-W deleted the Dev/Cheney/36791 branch December 18, 2024 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support info:internal This PR or Issue was filed by the vcpkg team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[gklib] Build error on arm64-android
4 participants