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

Nearly Everything is Broken #2718

Closed
time-killer-games opened this issue Dec 3, 2021 · 15 comments
Closed

Nearly Everything is Broken #2718

time-killer-games opened this issue Dec 3, 2021 · 15 comments

Comments

@time-killer-games
Copy link

time-killer-games commented Dec 3, 2021

Describe the issue

Literally none of my my projects build anymore after recent update. Apparently _WIN32 is no longer defined along with a crap ton of other functions that used to work now are undefined references -- mainly windows-specific posix-like functions such as wcsncpy_s and _wfopen_s, _close, _read, _write, etc. literally all of the posix functions with an underscore prefix no longer compile - with zero changes to my code made. This has been confirmed on two different of my machines.

Steps to Reproduce the Problem

  1. Build this with the shell scripts provided: https://github.com/time-killer-games/libfilesystem
  2. Watch MSYS2 complain about millions of undefined references that used to work.
  3. Try Building with MSVC and watch it all magically work again without any issue

Tried on Windows 11 and Windows 10

@Biswa96
Copy link
Member

Biswa96 commented Dec 3, 2021

I can compile your project in my msys2/mingw64 setup. Try this simple way

  1. Run this command in Command Prompt C:\msys64\msys2_shell.cmd -defterm -no-start -ucrt64. Assume msys2 is installed in C:\msys64 folder.
  2. Compile the project there. I ran this command from your build.sh file.
g++ "filesystem.cpp" "gamemaker.cpp" -o "libfilesystem.dll" -shared -std=c++17 -static-libgcc -static-libstdc++ -static

@1480c1
Copy link
Contributor

1480c1 commented Dec 3, 2021

As a note, this is MSYS2-packages, so for the msys2 subsystem, not mingw64 etc, so _WIN32, should not be defined for the gcc provided here as the gcc provided here should closer emulate cygwin's gcc, which would compile linux/posix code usually. (the else in a ifdef _WIN32 elif defined(__APPLE__) else chain)

gcc -dM -E - < /dev/null | sort -u | grep -i win
#define __CYGWIN__ 1
#define __SIZEOF_WINT_T__ 4
#define __WINT_MAX__ 0xffffffffU
#define __WINT_MIN__ 0U
#define __WINT_TYPE__ unsigned int
#define __WINT_WIDTH__ 32

and

gcc -dM -E - < /dev/null | sort -u | grep -i nix
#define __unix 1
#define __unix__ 1
#define unix 1

If you have an issue with one of the mingw-w64 or clang (non-msys2) compilers, you probably are looking for https://github.com/msys2/MINGW-packages

@MehdiChinoune
Copy link
Collaborator

You know that MSYS2 and MSYS2/MINGW are rolling-based platforms. They have the latest release of every package. So don't expect any stability here. If something go wrong investigate it and see if the issue is from MSYS2/MINGW side or is it from the upstream side, If the former then contributors will try to fix it, if the later then you should report it to the upstream and then if there is a quick fix it can be backported here.
Also Don't expect to have an enterprise-level packages from a project that is developed by non-paid volunteers.

@time-killer-games
Copy link
Author

time-killer-games commented Dec 3, 2021

As a note, this is MSYS2-packages, so for the msys2 subsystem, not mingw64 etc, so _WIN32, should not be defined for the gcc provided here as the gcc provided here should closer emulate cygwin's gcc, which would compile linux/posix code usually. (the else in a ifdef _WIN32 elif defined(__APPLE__) else chain)

gcc -dM -E - < /dev/null | sort -u | grep -i win
#define __CYGWIN__ 1
#define __SIZEOF_WINT_T__ 4
#define __WINT_MAX__ 0xffffffffU
#define __WINT_MIN__ 0U
#define __WINT_TYPE__ unsigned int
#define __WINT_WIDTH__ 32

and

gcc -dM -E - < /dev/null | sort -u | grep -i nix
#define __unix 1
#define __unix__ 1
#define unix 1

If you have an issue with one of the mingw-w64 or clang (non-msys2) compilers, you probably are looking for https://github.com/msys2/MINGW-packages

the odd thing though, is up until now, _WIN32 was defined along with all the functions I mentioned, I'm not doing anything different from what i usually do with this. I didn't know MINGW and MSYS2 had different compilers. However, regardless of whether I run it from a MSYS2 or MINGW terminal, the result is the same errors.

I can compile your project in my msys2/mingw64 setup. Try this simple way

  1. Run this command in Command Prompt C:\msys64\msys2_shell.cmd -defterm -no-start -ucrt64. Assume msys2 is installed in C:\msys64 folder.
  2. Compile the project there. I ran this command from your build.sh file.
g++ "filesystem.cpp" "gamemaker.cpp" -o "libfilesystem.dll" -shared -std=c++17 -static-libgcc -static-libstdc++ -static

I tried that and on my end I'm still getting the same errors. I don't know what information I haven't shared already. All I did was install fresh msys2 to C:\msys2 and ran pacman -Syu to update then I installed gcc with pacman -Sy gcc. After that, I ran the build script. Are you not able to reproduce this issue following the exact steps I mentioned here?

Has anything changed with MSYS2 and its packages that would cause this to happen? Like, a change in expected behavior that wasn't announced on the home page?

@Biswa96
Copy link
Member

Biswa96 commented Dec 3, 2021

Would you like to provide the actual output in your setup? If the error output is too long you can attach a text file here with that log.

@time-killer-games
Copy link
Author

Would you like to provide the actual output in your setup? If the error output is too long you can attach a text file here with that log.

You mean the errors I'm getting with the filesystem example project i provided or something else?

@Biswa96
Copy link
Member

Biswa96 commented Dec 3, 2021

Yes, the errors you get while compiling the project.

@MehdiChinoune
Copy link
Collaborator

We have upgraded MSYS2/gcc recently from 10.2.0 to 11.2.0, Maybe this is the reason!

@time-killer-games
Copy link
Author

time-killer-games commented Dec 3, 2021

I'll provide the version of the errors where I manually define -D_WIN32 hoping that will have more relevant output

g++ "filesystem.cpp" "gamemaker.cpp" -o "libfilesystem.dll" -shared -std=c++17 -static-libgcc -static-libstdc++ -static -D_WIN32

hello world.txt

In case you wanted to know what happens when I don't manually define -D_WiN32:

g++ "filesystem.cpp" "gamemaker.cpp" -o "libfilesystem.dll" -shared -std=c++17 -static-libgcc -static-libstdc++ -static

hello world 2.txt

@time-killer-games
Copy link
Author

time-killer-games commented Dec 3, 2021

We have upgraded MSYS2/gcc recently from 10.2.0 to 11.2.0, Maybe this is the reason!

if that is the case, it would be refreshing to know i'm not just plain stupid and doing something wrong but rather other people are having the same issues. Then again, I hope it was me doing something wrong. I don't want that many people effected by this.

@Biswa96
Copy link
Member

Biswa96 commented Dec 3, 2021

I assume that the build step is using msys2 g++ instead of mingw g++. Did you install $MINGW_PACKAGE_PREFIX-toolchain package group for the compiler? If not please install it and build the project.

$MINGW_PACKAGE_PREFIX is just an environment variable.

@time-killer-games
Copy link
Author

time-killer-games commented Dec 3, 2021

I assume that the build step is using msys2 g++ instead of mingw g++. Did you install $MINGW_PACKAGE_PREFIX-toolchain package group for the compiler? If not please install it and build the project.

$MINGW_PACKAGE_PREFIX is just an environment variable.

Is this a new requirement? I don't remember ever needing to do this in the past, but it definitely is installing new packages so right now I'm 90% sure this is the fix. Thank you so very much!!! I feel so stupid. I'll close this after I've confirmed it.

@time-killer-games
Copy link
Author

I assume that the build step is using msys2 g++ instead of mingw g++. Did you install $MINGW_PACKAGE_PREFIX-toolchain package group for the compiler? If not please install it and build the project.

$MINGW_PACKAGE_PREFIX is just an environment variable.

hands down, sorry guys for the dumb excuse of a bug report, you are my hero

@Biswa96
Copy link
Member

Biswa96 commented Dec 3, 2021

Is this a new requirement?

The required steps are documented here https://www.msys2.org/. If you think the documentation need more clarification please let us know.

As you are using mingw environment, will it be appropriate to move this issue to MINGW-packages repository?

@time-killer-games
Copy link
Author

Seeing as the issue was me and not the software, it really doesn't belong anywhere. But I'll know for the future where to report bugs to more precisely if encounter a real one at some point.

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

4 participants