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

Unable to run files build with debugging information (-g option) with mingw on windows 11 after upgrading to version 2.24.0 #6139

Closed
rapte opened this issue Aug 26, 2022 · 5 comments
Assignees
Milestone

Comments

@rapte
Copy link

rapte commented Aug 26, 2022

I am running windows 11. I am using the TDM-GCC-64 compiler. After upgrading to the latest version 2.24.0, I am unable to run programs which are built with debugging information (-g option) while getting a "Access is denied" message. Binaries built without this option continue to run perfectly.

A very simple example

#include <SDL2\SDL.h>

int main(int argc, char* argv[]) {
    SDL_Init(SDL_INIT_VIDEO);
    SDL_Quit();
    return 0;
}
> gcc -g minimum-sdl2.c -lmingw32 -lsdl2main -lSDL2
> a.exe
Access is denied.
@slouken
Copy link
Collaborator

slouken commented Sep 1, 2022

Are you able to use git bisect to find out where this broke?

@madebr
Copy link
Contributor

madebr commented Sep 1, 2022

I can reproduce this by downloading and installing tdm64-gcc-10.3.0-2.exe from https://jmeubank.github.io/tdm-gcc/.

Linking to the MinGW SDL2 sdk gives the following error on Windows 10:
image

When I link to the VC SDK, the executable runs just fine. You can link to .lib files by using full paths.

When I modify the code to the following, the executable builds and runs fine

#define SDL_MAIN_HANDLED
#include "SDL.h"
#include <stdio.h>
int main(int argc, char* argv[]) {
    SDL_Init(SDL_INIT_VIDEO);
    SDL_Quit();
    printf("If you are reading this then nothing went wrong.\n");
    return 0;
}

Also noteworthy, my issue also happens when building in release mode (without -g).

Building SDL2 myself with TDM, and linking to its libraries also works perfectly
So it's really only the MinGW binary SDK release that is giving us/you troubles.

@slouken
Copy link
Collaborator

slouken commented Oct 4, 2022

If I build with mingw using gcc 10.3.0, I get this issue. If I build with mingw using gcc 11.3.0, the executables work fine. The 2.0.22 binaries were built with gcc 11.1.0, and the 2.24.0 binaries were built with gcc 12.1.0, so it seems like it's an issue where gcc 12 binaries can't be linked using gcc 10.

Unfortunately I upgraded to gcc 12 because of a code generation issue in gcc 11 which caused a crash in SDL_ttf.

Let me think about this...

@slouken
Copy link
Collaborator

slouken commented Oct 4, 2022

Actually, it's not quite that simple. The 2.24.0 libSDL2main.a works with mingw gcc version 10.2.0, so it's not strictly a gcc version issue.

@slouken
Copy link
Collaborator

slouken commented Oct 4, 2022

This is the problem:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101377

The newer binutils uses -gdwarf-5 by default, which is broken in the earlier versions of binutils used by TDM and others. I can work around this by passing -gdwarf-4 in the command line options when building the release archive.

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

3 participants