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 extern "C" naming issues on OSX #3020

Merged
merged 2 commits into from
Oct 4, 2018

Conversation

nbhuiyan
Copy link
Member

This is the other side of #3004, where references from c/cpp to assembly symbols should not have a leading underscore, since Clang adds an underscore to them anyway. Currently, this fix is implemented just for macOS, but in the future, there will be a cleaner, more unified solution once NASM is used across all x86 operating systems.

Signed-off-by: Nazim Uddin Bhuiyan nazim.uddin.bhuiyan@ibm.com

Issue: #36

Signed-off-by: Nazim Uddin Bhuiyan <nazimudd@ualberta.ca>
Clang adds another underscore to these names, and results in
linker issues. While global/extern symbols written in assembly
need to have leading underscores on OSX, they can not be referred
to with leading underscores in c/cpp.

Signed-off-by: Nazim Uddin Bhuiyan <nazimudd@ualberta.ca>
@0xdaryl
Copy link
Contributor

0xdaryl commented Sep 25, 2018

Jenkins test sanity xlinux,win

@@ -4707,7 +4707,11 @@ bool TR::CompilationInfo::isQueuedForCompilation(J9Method * method, void *oldSta
return linkageInfo->isBeingCompiled();
}

#if defined(OSX)
JIT_HELPER(initialInvokeExactThunkGlue);
Copy link
Member

Choose a reason for hiding this comment

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

Can the JIT_HELPER macro be updated to include _ on OSX? That would minimize the other required changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

The leading _ is needed for platforms other than OSX. So what we would need is to have JIT_HELPER(x) defined to extern "C" void x() on mac and extern "C" void _x() on other platforms. We would then also need to enclose any calls to these functions in C/C++ in another macro, say, CALL_JIT_HELPER.

However, I did not go with that solution because the problem is that there is a lack of consistency here. The method calls/declarations with leading underscore in C also are named with leading underscores in the MASM code. Most of the methods are missing a leading underscore (and also in the assembly code), and so using our single JIT_HELPER macro that expands differently on OSX would not work. We would then need to divide them into 2 different categories, requiring 4 different macros: JIT_HELPER(x), JIT_HELPER_UNDERSCORE(x), CALL_JIT_HELPER(x), CALL_JIT_HELPER_UNDERSCORE(x).

Did you have a different idea in mind?

Copy link
Member

Choose a reason for hiding this comment

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

The VM handles this somewhat differently by hiding the platform differences in the macros. Looking at the JIT code, the approach there is to handle it with ifdefs throughout.

I don't want this to block this PR from moving forward. Though I think it would be worth looking at cleaning this up in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

This will be cleaned up once the NASM assembly files are set up to be used by Windows and xLinux. We will no longer need to have the code in the #else blocks of #if defined(OSX) in this PR.

@0xdaryl
Copy link
Contributor

0xdaryl commented Oct 4, 2018

Jenkins test sanity

@0xdaryl
Copy link
Contributor

0xdaryl commented Oct 4, 2018

I agree with @DanHeidinga that hiding the macOS specifics behind the SET and JIT_HELPERS would be a cleaner solution. But you've already agreed to do that by end of October so I don't think it's needed in this PR.

@0xdaryl 0xdaryl self-assigned this Oct 4, 2018
@0xdaryl 0xdaryl merged commit e436fbd into eclipse-openj9:master Oct 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants