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

Rust cross compiling using MinGW #594

Open
xdm67x opened this issue Jun 22, 2023 · 13 comments
Open

Rust cross compiling using MinGW #594

xdm67x opened this issue Jun 22, 2023 · 13 comments

Comments

@xdm67x
Copy link

xdm67x commented Jun 22, 2023

Hi,

I cross compile my code from Mac OS to Windows using MinGW and the target x86_64-pc-windows-gnu.
I use the RUSTFLAGS="-g -C opt-level=3" to generate debug information when being in release mode.
Then, I run the command,

x86_64-w64-mingw32-objcopy --only-keep-debug library.dll library.debug
x86_64-w64-mingw32-objcopy --strip-debug library.dll
x86_64-w64-mingw32-objcopy --add-gnu-debuglink=library.debug library.dll

After that, I use to have the library.debug file containing all the debug information but when I want to check if it is usable by Sentry using sentry-cli difutil check library.debug I have this result,

Debug Info File Check
  Type: pe
  Contained debug identifiers:
  Contained debug information:
    > none
  Usable: no (missing debug identifier, likely stripped)

Do you know, what I can do to get the debug information send to Sentry correctly to be able to map it with my library?

@Swatinem
Copy link
Member

I believe this is because we do not (yet) support DWARF in PE.
If you want to use DWARF as debug format, it has to be in an ELF or Mach-O file. Otherwise, Windows Debug Info usually is in PDB format.
I’m not too familiar with MinGW myself, but you would have to teach it to output dwarf in an elf file I presume.

@xdm67x
Copy link
Author

xdm67x commented Jun 22, 2023

Also when I use the .dll file without stripping I got this result with the sentry-cli command,

Debug Info File Check
  Type: pe library
  Contained debug identifiers:
    > Debug ID: 00000000-0000-0000-0000-000000000000
      Code ID:  6494408637f90000
      Arch:     x86_64
  Contained debug information:
    > symtab, debug, unwind
  Usable: no (missing debug identifier, likely stripped)

I have the feature debug-images.

@Swatinem
Copy link
Member

Another problem here is also that the file is missing a DebugId.

@xdm67x
Copy link
Author

xdm67x commented Jun 22, 2023

Yep, but why is it missing? I only cross compile using Rust and MinGW.

@xdm67x
Copy link
Author

xdm67x commented Jun 23, 2023

The issue is similar with #354, wdyt?

@xdm67x
Copy link
Author

xdm67x commented Jun 27, 2023

Any news, please?

@Swatinem
Copy link
Member

It might have something to do with the mingw tools. The issue you linked above is using cv2pdb to create a pdb file, which appears to be usable.

Another member of our team is trying to reproduce this.

@xdm67x
Copy link
Author

xdm67x commented Jun 27, 2023

Ok, thx, if you need any help please keep in touch with me.

@Swatinem
Copy link
Member

The team has had a look at this and we were able to reproduce this, though did not find a proper way to make this work.

In general we appreciate community contributions related to MinGW very much, but we do not actively support it, neither for the native SDK nor for Rust.

MinGW in general is a very broad target with a diverse set of tools. In general we need debug files/formats in their "native" container type. Which means that PDB needs to be in a PDB file, and DWARF needs to be in either an ELF or Mach-O container. We do support using ELF/DWARF debug info in combination with a PE executable though.

@xdm67x
Copy link
Author

xdm67x commented Jul 4, 2023

So you mean I need to convert the dwarf debug info to PDB?

@Swatinem
Copy link
Member

Swatinem commented Jul 4, 2023

Either convert the whole debuginfo to pdb, or just make sure that the DWARF is in a container format that is appropriate for it, like ELF.

@xdm67x
Copy link
Author

xdm67x commented Sep 19, 2023

Is it normal that after I used the ELF debug information format, I'm also missing the Debug ID?

Debug Info File Check
  Type: elf debug companion
  Contained debug identifiers:
    > Debug ID: 00000000-0000-0000-0000-000000000000
      Arch:     x86_64
  Contained debug information:
    > symtab, debug, unwind
  Usable: no (missing debug identifier, likely stripped)

@xdm67x
Copy link
Author

xdm67x commented Sep 19, 2023

I don't know how to read 😄 , everything is written here, https://docs.sentry.io/platforms/native/guides/minidumps/data-management/debug-files/identifiers/#gnu-build-identifiers.

But after doing that, I got the identifier for the executable, such as,

Debug Info File Check
  Type: pe library
  Contained debug identifiers:
    > Debug ID: c8627651-8de4-7cb7-f6ba-dc6faa7317b0-1
      Code ID:  65099b543f203000
      Arch:     x86_64
  Contained debug information:
    > symtab, debug, unwind
  Usable: yes

But when I used the command x86_64-w64-mingw32-objcopy --only-keep-debug -O elf64-x86-64 mylib.dll mylib.dbg, I lost the debug identifier.

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

2 participants