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

Inline constructor support #78

Closed
PathogenDavid opened this issue Oct 21, 2020 · 2 comments
Closed

Inline constructor support #78

PathogenDavid opened this issue Oct 21, 2020 · 2 comments
Labels
Area-OutputGeneration Issues concerning the process of generating output from Biohazrd Area-Translation Issues concerning the translation from libclang into Biohazrd Concept-CppFeatures Issues concerning unsupported C++ features Concept-InlineExpectation Issues concerning problems around C++'s expectation for something to be inlined.

Comments

@PathogenDavid
Copy link
Member

Inline constructors are problematic to force export because we can't take a pointer to them.

In theory we can just make a trampoline function for them, but that's not The Biohazrd Way™. (This is probably what we'll do in the end for the sake of not relying on compiler weirdness.)

One of the things that I forgot about from the original PhysX prototype is that it requires PhysX to be built in debug mode or none of the constructors would be exported from the DLL. (The trick of simply calling them in the InlineReferenceFileGenerator output file didn't work outside of debug.)

At the time I did not investigate why this was, but knew it was a problem that would eventually need to be solved. (And forgot about it entirely until it ruined my life today.)

The reason the trick only worked in the first place was debug builds get /Ob0 specified. We could explicitly build the inline reference file with /Ob0, but this means functions called by the inline constructors would not get inlined. (This is what I'm doing for now though.)

We can get similar effects for everything that isn't marked as __forceinline with the following two pragmas:

#pragma inline_depth(0)
#pragma optimize("", off)
@PathogenDavid PathogenDavid added Concept-CppFeatures Issues concerning unsupported C++ features Area-Translation Issues concerning the translation from libclang into Biohazrd Area-OutputGeneration Issues concerning the process of generating output from Biohazrd Concept-InlineExpectation Issues concerning problems around C++'s expectation for something to be inlined. labels Oct 21, 2020
@PathogenDavid PathogenDavid mentioned this issue Nov 9, 2020
6 tasks
@PathogenDavid
Copy link
Member Author

I've been revisiting this today and I think we're gonna have to go with the trampolines. I'm experimenting with a new more elegant implementation to InlineReferenceFileGenerator with InfectedImGui.

Currently I generate the inline exports file right before the static library resolver runs and then re-build InfectedImGui.Native so everything will be exported.

For libraries which do not wish to/cannot re-build their target library, we will instead recommend (and provide assistance for) building the inline exports file as its own DLL.

PathogenDavid added a commit that referenced this issue Feb 21, 2021
…tors, destructors, operator overloads, and conversion overloads.

Relates to #78 and #12
@PathogenDavid
Copy link
Member Author

Finished in 23c4edd

Improving friendliness of constructing/destructing C++ objects in general is tracked by #161

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-OutputGeneration Issues concerning the process of generating output from Biohazrd Area-Translation Issues concerning the translation from libclang into Biohazrd Concept-CppFeatures Issues concerning unsupported C++ features Concept-InlineExpectation Issues concerning problems around C++'s expectation for something to be inlined.
Projects
None yet
Development

No branches or pull requests

1 participant