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

Added support for swift demangling #38

Open
wants to merge 5 commits into
base: hotspot
Choose a base branch
from
Open

Conversation

rimim
Copy link

@rimim rimim commented Feb 19, 2025

Added support for swift demangling. It depends on 'swift' being in the current PATH and will locate libswiftDemangle.so to do the actual demangling. No additional shared library needs to be built or included in 'hotspot' to support demangling and if 'libswiftDemangle.so' is not found then swift demangling is just disabled.

Mimir Reynisson and others added 2 commits February 19, 2025 13:12
Copy link
Member

@milianw milianw left a comment

Choose a reason for hiding this comment

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

cool, thanks for this! I have a couple of questions but otherwise would love to see first class swift demangling support!

@@ -38,6 +39,7 @@ Demangler::Demangler()
{
loadDemangleLib(QStringLiteral("rustc_demangle"), "rustc_demangle", QByteArrayLiteral("_R"));
loadDemangleLib(QStringLiteral("d_demangle"), "demangle_symbol", QByteArrayLiteral("_D"));
m_demanglers.push_back({"$s", reinterpret_cast<Demangler::demangler_t>(swift_demangle)});
Copy link
Member

Choose a reason for hiding this comment

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

why is this not using loadDemangleLib like the above?

Copy link
Author

Choose a reason for hiding this comment

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

swift_demangle can be compiled as a standalone shared library and used the same way as you use rustc_demangle or d_mangle.

Copy link
Member

Choose a reason for hiding this comment

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

this does not answer my question. can we or can we not reuse loadDemangleLib? if not, why not?

#ifndef SWIFT_DEMANGLER_H
#define SWIFT_DEMANGLER_H

int swift_demangle(const char* symbol, char* buffer, size_t bufferLength) {
Copy link
Member

Choose a reason for hiding this comment

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

missing closing brace?

// Construct the full path to libswiftDemangle.so:
// SOMEPATH/usr/lib/libswiftDemangle.so
char lib_path[PATH_MAX];
snprintf(lib_path, sizeof(lib_path), "%s/usr/lib/libswiftDemangle.so", base_path);
Copy link
Member

Choose a reason for hiding this comment

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

this seems like it's replicating parts of what we already do for the other demanglers, why can we not integrate with that code? why is the fancy logic to find swift needed, can't we just use normal library lookup instead?

Copy link
Author

Choose a reason for hiding this comment

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

I thought that the upside of doing it this way was to make it future proof as swift seems still to be evolving fairly rapidly. The downside is that it requires swift to be in the PATH, but only for people that are interested in swift demangling. Other developers are not affected. Also I wasn't sure about licensing issues with distributing a binary library libswiftDemangle.so which is Apache licensed in a GPL project.

Copy link
Member

Choose a reason for hiding this comment

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

IANAL but linking gpl to apache is fine but not the other way around?

still, you haven't answered my question - PATH has no impact on the dynamic library loader on linux - or are you saying this proposed approach here needs it? I would instead rather we try to dlopen libswiftDemangle.so directly, just like we do for rustc_demangle e.g. unless this isn't possible (why?) please simplify your patch accordingly.

@milianw
Copy link
Member

milianw commented Feb 21, 2025

please also write clean commits, i.e. use git rebase -i to squash your work into atomic chunks - for now, this looks like one single patch so far. the end result will then rebased and merged without squashing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants