Skip to content

Conversation

@JinShil
Copy link
Contributor

@JinShil JinShil commented Aug 28, 2018

I'm not all that confident in this fix. If this isn't the right fix, please help me with some advise. Thanks.

@JinShil JinShil added the Review:WIP Work In Progress - not ready for review or pulling label Aug 28, 2018
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @JinShil!

Bugzilla references

Auto-close Bugzilla Severity Description
18955 normal extern(C++) default struct mangling is overridden when interacting with a cppmangle = class template

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + dmd#8631"

@JinShil JinShil removed the Review:WIP Work In Progress - not ready for review or pulling label Aug 28, 2018
@JinShil
Copy link
Contributor Author

JinShil commented Aug 28, 2018

There's some strange difference between Appveyor and the auto-tester. If I adjust the test to make Appveyor pass, then auto-tester fails. If I adjust the test to make the auto-tester pass, then Appveyor fails. Can anyone explain the discrepancy?

@JinShil JinShil added the Review:WIP Work In Progress - not ready for review or pulling label Aug 29, 2018
@TurkeyMan
Copy link
Contributor

I think this LGTM, but I didn't do it because I didn't understand the surrounding code enough to have confidence. It kinda looked like the original code was deliberate.

@JinShil
Copy link
Contributor Author

JinShil commented Aug 29, 2018

auto-tester Win32_64 expects:
?test@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@@std@@@Z

auto-tester Win32 expects:
?test@@YAXABV?$basic_string@std@DU?$char_traits@std@D@1@@std@@@Z

appveyor (Win32 - I think) expects:
?test@@YAXABV?$basic_string@DU?$char_traits@D@std@@@std@@@Z

There's no way I can satisfy that. Any idea why the auto-tester and appveyor expect different results?

@TurkeyMan
Copy link
Contributor

Did you get those mangled names from MSVC? It's not like DMC vs MSVC proper is it?

@JinShil
Copy link
Contributor Author

JinShil commented Aug 29, 2018

I took them from the error messages generated by the auto-tester and Appveyor. I don't know which C++ compilers they are employing.

@TurkeyMan
Copy link
Contributor

TurkeyMan commented Aug 29, 2018

I just tried MSVC2015, it emits:

// 64bit
?test@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@@std@@@Z

//32bit
?test@@YAXABV?$basic_string@DU?$char_traits@D@std@@@std@@@Z

That's what we should expect...

@JinShil
Copy link
Contributor Author

JinShil commented Aug 29, 2018

Thanks, Then it must be the auto-tester's Win32 host that's giving the wrong result. @braddr, Any ideas?

@JinShil JinShil removed the Review:WIP Work In Progress - not ready for review or pulling label Aug 29, 2018
@rainers
Copy link
Member

rainers commented Aug 29, 2018

autotester's Win32 test is the only server building with dmc.

Looking at cppmanglewin.d, there's a flag IS_DMC showing that dmc's mangling is slightly different than VS. You'll have to version the check with version(CRuntime_DigitalMars).

@rainers
Copy link
Member

rainers commented Aug 29, 2018

auto-tester Win32 expects:
?test@@YAXABV?$basic_string@std@DU?$char_traits@std@D@1@@std@@@Z

This string doesn't demangle with UnDecorateSymbolName.

@JinShil
Copy link
Contributor Author

JinShil commented Aug 29, 2018

auto-tester and Appveyor are all green now. Thank you, @rainers.

@JinShil JinShil changed the title Fix Issue 18955 - extern(C++) default struct mangling is ove rridden when interacting with a cppmangle = class template Fix Issue 18955 - extern(C++) default struct mangling is overridden when interacting with a cppmangle = class template Aug 29, 2018
@PetarKirov
Copy link
Member

DAutoTest failed, due to a timeout:

.generated/stable_dmd-2.081.1/dmd2/linux/bin64/dub build --compiler=.generated/stable_dmd-2.081.1/dmd2/linux/bin64/dmd --root=ddoc && \
	mv ddoc/ddoc_preprocessor .generated/ddoc_preprocessor
Fetching stdx-allocator 2.77.2 (getting selected version)...
Fetching libdparse 0.8.7 (getting selected version)...
Timeout was reached on handle DF7600
posix.mak:920: recipe for target '.generated/ddoc_preprocessor' failed

Restarting...

@PetarKirov PetarKirov closed this Aug 31, 2018
@PetarKirov PetarKirov reopened this Aug 31, 2018
@PetarKirov
Copy link
Member

@JinShil, can you rebase to restart DAutoTest?

@PetarKirov
Copy link
Member

@rainers is this PR good to go now?

…hen interacting with a cppmangle = class template
@rainers
Copy link
Member

rainers commented Sep 1, 2018

@rainers is this PR good to go now?

Looks reasonable, but I'm not too familiar with the code.

I wonder why the tests are limited to Windows (I know mangling for structs and classes only differs there, but something else might break on other platforms).

Wouldn't it be better to actually try linking against the respective C++ code?

@JinShil
Copy link
Contributor Author

JinShil commented Sep 1, 2018

I wonder why the tests are limited to Windows

The bug was specific to Windows. I could add a test for other platforms, but I'm not knowledgeable enough to know if the mangling produced is correct, so I may add a test that is verifying an incorrect result.

Wouldn't it be better to actually try linking against the respective C++ code?

We need the C++ bindings created first. That's currently getting under way at dlang/druntime#2286.

@JinShil
Copy link
Contributor Author

JinShil commented Sep 1, 2018

@TurkeyMan If you could write a test case that links to libstdc++, I'll incorporate it into the PR and extend the test to multiple platforms.

@rainers
Copy link
Member

rainers commented Sep 1, 2018

I was rather thinking of adjusting the definition in cppa.d and add something matching in cppb.cpp:, e.g. rainers@194cdc1

That also matches the definition in <string> for MSC, but dmc doesn't seem to be able to compile its own stl.

@TurkeyMan
Copy link
Contributor

@JinShil Writing any tests that link to stdc++ is super hard, since there are a lot of C++ tests that all use different C++ compilers, and different STL's, and most of the machinery to make correct decisions isn't merged yet (see my recent PR's).
What Rainer says is the right thing to do... or the test you have here is fine... hopefully it'll be self-testing with proper C++ link tests pretty soon.

@thewilsonator
Copy link
Contributor

@JinShil https://godbolt.org/z/6QZzsf using MSVC 2015

@TurkeyMan
Copy link
Contributor

Why isn't this merged? Is something holding it up?

@PetarKirov
Copy link
Member

@JinShil can you incorporate the tests suggested by @rainers?

@rainers
Copy link
Member

rainers commented Sep 16, 2018

@JinShil can you incorporate the tests suggested by @rainers?

Maybe it's simpler to merge this and I make rainers@194cdc1 another PR? It might expose some non-Windows issues, though.

@PetarKirov
Copy link
Member

@rainers sounds good, in this case feel free to approve and merge this PR.

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.

6 participants