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

how to build MinGW? #238

Closed
irov opened this issue Apr 17, 2020 · 31 comments
Closed

how to build MinGW? #238

irov opened this issue Apr 17, 2020 · 31 comments

Comments

@irov
Copy link
Contributor

irov commented Apr 17, 2020

i try to compile MinGW and get many errors.
I tried to fix them, but to no avail.

-crashpad
/util/win/exception_handler_server.cc - miss include
/util/process/process_memory.h - double typedef ssize_t
/client/crash_report_database_win.cc - error with _wstat64

and other

i bassed on msys2.

Tell me how to do it and is it possible now?

Thanks!

@Amphaal
Copy link
Contributor

Amphaal commented Apr 17, 2020

Hello mate ! I have not tested yet the latest crashpad merged version from the Sentry team (I'm the main contributor for the MinGW compatibility btw), so I am not surprised you encountered some issues. Let me investigate first so I may fix some unexpected incompatibilities.

By the way, you need to use LLVM to compile sentry-native. Ninja is also kind of a must have for LLVM, so get it too from MSYS2.

@Amphaal
Copy link
Contributor

Amphaal commented Apr 17, 2020

In the meantime, have a look at https://github.com/Amphaal/rpgrpz/blob/master/cmake/toolchains/msys.cmake. This is the toolchain file I use with CMake to build sentry-native, it might help you to setup the build.

@Amphaal
Copy link
Contributor

Amphaal commented Apr 17, 2020

Alright, I managed to build it locally once the missing header issue is adressed getsentry/crashpad#13. The rest might be related to a CMake missconfiguration on your side. I will propose a pull request soon to help you setup this the right way ;)

@Amphaal
Copy link
Contributor

Amphaal commented Apr 17, 2020

@irov There you go :) #239

@irov
Copy link
Contributor Author

irov commented Apr 18, 2020

Thanks! I found my issue - i compile mingw32, it is broken build.
But if i compile mingw64 i need fix only

  • /util/win/exception_handler_server.cc - miss #include <memory>

std::unique_ptr place in header file

memory

proof: https://en.cppreference.com/w/cpp/memory/unique_ptr

maybe fix mingw32 build too? ;)

P.S. and i build gcc, and CMake Generator MinGW Makefiles

@Amphaal
Copy link
Contributor

Amphaal commented Apr 18, 2020

But if i compile mingw64 i need fix only

  • /util/win/exception_handler_server.cc - miss #include <memory>

std::unique_ptr place in header file

memory

proof: https://en.cppreference.com/w/cpp/memory/unique_ptr

Yeah, here is the awaiting patch : getsentry/crashpad#13.

maybe fix mingw32 build too? ;)

Is 32bits a requirement for you ? I could take a look tomorrow.

P.S. and i build gcc, and CMake Generator MinGW Makefiles

You absolutely need to use Clang because only Clang is able to generate .pdb files which are required by sentry-native/Crashpad to create Sentry bug reports !

@irov
Copy link
Contributor Author

irov commented Apr 21, 2020

Yeah, here is the awaiting patch : getsentry/crashpad#13.

Good! Thanks!

Is 32bits a requirement for you ? I could take a look tomorrow.

Due to some libraries like astralax in old projects, I have to compile in mingw32.

You absolutely need to use Clang because only Clang is able to generate .pdb files which are required by sentry-native/Crashpad to create Sentry bug reports !

thank you for saving a couple of days of my life ;)

@Amphaal
Copy link
Contributor

Amphaal commented Apr 21, 2020

Due to some libraries like astralax in old projects, I have to compile in mingw32.

Alright, I have a bit of time ahead this afternoon, I'll give it a try ;)

@Amphaal
Copy link
Contributor

Amphaal commented Apr 21, 2020

Well as expected, the 32bits headers definitions expected by sentry-native are [missing / outdated / plain wrong] on mingw-w64.

  • _FLOATING_SAVE_AREA in winnt.h
  • CONTEXT_XSTATE in winnt.h

We could hack the assert declarations that find these errors, but IMO we should not.
And good luck having the header files updated by the upstream mingw-w64 project... Maybe try a pull request there ? https://sourceforge.net/projects/mingw-w64/

I think your best bet here is to wait from the sentry-native team to offer an alternative to Crashpad for Windows 😥

@irov
Copy link
Contributor Author

irov commented Apr 24, 2020

I think your best bet here is to wait from the sentry-native team to offer an alternative to Crashpad for Windows 😥

Is there any information or a roadmap?

@Swatinem
Copy link
Member

Is there any information or a roadmap?

Not really. We discussed it briefly, but crashpad is the best option on windows.

@irov
Copy link
Contributor Author

irov commented Apr 24, 2020

Is there any information or a roadmap?

Not really. We discussed it briefly, but crashpad is the best option on windows.

Thank you, and I’ll go pray for crashpad to support mingw clang x86 ^^

@djdron
Copy link

djdron commented Apr 24, 2020

You absolutely need to use Clang because only Clang is able to generate .pdb files which are required by sentry-native/Crashpad to create Sentry bug reports !

No, you can obtain syms from any dwarf debug info using tools from google breakpad.

@Amphaal
Copy link
Contributor

Amphaal commented Apr 24, 2020

I tried to poke at the crashpad team about mingw compatibility, but without success yet... https://groups.google.com/a/chromium.org/forum/#!mydiscussions/crashpad-dev/Y2tt6dDNIBI any ideas on how to reach them ?

@Amphaal
Copy link
Contributor

Amphaal commented Apr 24, 2020

You absolutely need to use Clang because only Clang is able to generate .pdb files which are required by sentry-native/Crashpad to create Sentry bug reports !

No, you can obtain syms from any dwarf debug info using tools from goolge breakpad.

I had no idea about that ! You should fix my modifications, I'd be interested to see how you make this work :)

@djdron
Copy link

djdron commented Apr 24, 2020

I had no idea about that ! You should fix my modifications, I'd be interested to see how you make this work :)

Use cv2pdb.exe to convert dwarf debug info from mingw/old clang to pdb, then use dump_syms.exe with this pdb to convert it to sym. Then upload all this to sentry as usual with sentry-cli.
https://github.com/rainers/cv2pdb
https://github.com/google/breakpad/tree/master/src/tools/windows/binaries

@Amphaal
Copy link
Contributor

Amphaal commented Apr 24, 2020

Ok, it just requires to compile cv2pdb as tool utility and then use it as a post build command. Seems doable.

@djdron
Copy link

djdron commented Apr 24, 2020

Ok, it just requires to compile cv2pdb as tool utility and then use it as a post build command. Seems doable.

https://github.com/rainers/cv2pdb/releases

@Amphaal
Copy link
Contributor

Amphaal commented Apr 28, 2020

Alright, I checked cv2pdb more closely this time : it uses deferred dll loading of VC++ exclusive libraries such as msobj{ver}.dll, mspdb{ver}.dll, making cross-compilation impossible. This is a deal-breaker for my use case :(

@Amphaal
Copy link
Contributor

Amphaal commented Apr 28, 2020

@irov I've seen that the mingw-w64 headers have been updated few days ago, to a testing 8.0 version https://packages.msys2.org/package/mingw-w64-i686-headers-git?repo=mingw32. Still does not fix your requirements tho...

@irov
Copy link
Contributor Author

irov commented Apr 28, 2020

@Amphaal Oh, can you tell me how to get 'pdb' with the help of the clang and mingw64 to send to the server?

@Amphaal
Copy link
Contributor

Amphaal commented Apr 28, 2020

There are the 2 mandatory options you must set on your executable target when using Clang :

target_compile_options(${yourTarget} PRIVATE -gcodeview)  
target_link_options(${yourTarget} PRIVATE -Wl,-pdb=)

Theses ensure that lld, the linker shipped with LLVM, generate the associated .pdb with the appropriate format.
As LLD is not shipped with the LLVM MSYS2 package, you need to install mingw64/mingw-w64-x86_64-lld to get it.
To use LLD instead of the default GNU linker, add -fuse-ld=lld to your CMAKE_<LANG>_FLAGS.

Let me know if you succeded ;)

@irov
Copy link
Contributor Author

irov commented Apr 29, 2020

Let me know if you succeded ;)

Thanks! I did it!

It's okey if i get on Release mode only top function name, without callstack?
On debug i have on same test crash - callstack

@Amphaal
Copy link
Contributor

Amphaal commented Apr 29, 2020

Yeah, i've had misformated reports before, but with the entire callstack and threads. Maybe try to set the CMake options to the subjacents libs your main executable may use to get their callstack too ?

@irov irov closed this as completed Apr 29, 2020
@irov irov reopened this Apr 29, 2020
@irov
Copy link
Contributor Author

irov commented Apr 29, 2020

Yeah, i've had misformated reports before, but with the entire callstack and threads. Maybe try to set the CMake options to the subjacents libs your main executable may use to get their callstack too ?

Oh, I tried several times and it worked! Thanks!

P.S. I missclick and closed issue, sorry ^^

@Swatinem
Copy link
Member

There have been some great contributions to MinGW support, but after all this is not something that we want to actively support.

@zumoshi
Copy link

zumoshi commented Jul 13, 2021

@Amphaal Have this been tested recently?

I know that this is not actively supported but since the instructions have been added to the readme I thought I'd ask here.
I'm terribly sorry if this is my fault but I tried anything I could think of to no avail.

Following the instructions on Readme I get this:

FAILED: crashpad_build/third_party/mini_chromium/CMakeFiles/mini_chromium.dir/utf_string_conversion_utils.mingw.cc.obj
C:\msys64\mingw64\bin\clang++.exe -DCRASHPAD_LSS_SOURCE_EMBEDDED -I../external/crashpad/third_party/mini_chromium/mini_chromium -I../external/crashpad/third_party/mini_chromium -I../external/crashpad -fuse-ld=lld -O3 -g -DNDEBUG -municode -Wno-format -Wno-unknown-pragmas -std=gnu++14 -MD -MT crashpad_build/third_party/mini_chromium/CMakeFiles/mini_chromium.dir/utf_string_conversion_utils.mingw.cc.obj -MF crashpad_build\third_party\mini_chromium\CMakeFiles\mini_chromium.dir\utf_string_conversion_utils.mingw.cc.obj.d -o crashpad_build/third_party/mini_chromium/CMakeFiles/mini_chromium.dir/utf_string_conversion_utils.mingw.cc.obj -c ../external/crashpad/third_party/mini_chromium/utf_string_conversion_utils.mingw.cc
../external/crashpad/third_party/mini_chromium/utf_string_conversion_utils.mingw.cc:24:33: error: unknown type name 'char16'
bool ReadUnicodeCharacter(const char16* src,
                                ^
../external/crashpad/third_party/mini_chromium/utf_string_conversion_utils.mingw.cc:61:51: error: unknown type name 'string16'
size_t WriteUnicodeCharacter(uint32_t code_point, string16* output) {
                                                  ^
../external/crashpad/third_party/mini_chromium/utf_string_conversion_utils.mingw.cc:63:35: error: unknown type name 'char16'
    output->push_back(static_cast<char16>(code_point));
                                  ^
../external/crashpad/third_party/mini_chromium/utf_string_conversion_utils.mingw.cc:103:62: error: unknown type name 'string16'
template void PrepareForUTF16Or32Output(const char*, size_t, string16*);
                                                             ^
../external/crashpad/third_party/mini_chromium/utf_string_conversion_utils.mingw.cc:93:9: error: member reference base type 'int' is not a structure or union
  output->clear();
  ~~~~~~^ ~~~~~
../external/crashpad/third_party/mini_chromium/utf_string_conversion_utils.mingw.cc:103:15: note: in instantiation of function template specialization 'base::PrepareForUTF16Or32Output<int>' requested here
template void PrepareForUTF16Or32Output(const char*, size_t, string16*);
              ^
../external/crashpad/third_party/mini_chromium/utf_string_conversion_utils.mingw.cc:97:11: error: member reference base type 'int' is not a structure or union
    output->reserve(src_len);
    ~~~~~~^ ~~~~~~~
6 errors generated.

Full log here: https://gist.github.com/zumoshi/6a0dee361a1293820f7fae102b3c85fa


My goal is to add native-sdk to a rust program as per this article. But most of my native dependencies are from mingw64 and would be difficult to get them to work with msvc.

Thanks for your time.

@irov
Copy link
Contributor Author

irov commented Jul 13, 2021

@Amphaal Have this been tested recently?

besides this problem I have a number of problems for which I wrote a patch

@Amphaal
Copy link
Contributor

Amphaal commented Jul 13, 2021

Hello guys,

I haven't touched sentry-native for a while now, sorry for that...

https://github.com/getsentry/crashpad might need a little tweek to make things work again, mostly missing header defines. @irov, can you make a pull request to push your patch to master ?

@irov
Copy link
Contributor Author

irov commented Jul 13, 2021

https://github.com/getsentry/crashpad might need a little tweek to make things work again, mostly missing header defines. @irov, can you make a pull request to push your patch to master ?

Yes, tomorrow

@irov
Copy link
Contributor Author

irov commented Jul 14, 2021

Hello guys,

I haven't touched sentry-native for a while now, sorry for that...

https://github.com/getsentry/crashpad might need a little tweek to make things work again, mostly missing header defines. @irov, can you make a pull request to push your patch to master ?

getsentry/crashpad#41

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

No branches or pull requests

5 participants