mstorsjo/msvc-wine

`/analyze` Causes Errors When Used

Chris3606 opened this issue · 5 comments

Using the /analyze flag to cl.exe fails. With a trivial main.cpp:

#include <iostream>

int main(int argc, const char* argv[])
{
    std::cout << "Hello world!" << std::endl;
    return 0;
}

If you run the following command within the docker container built by Dockerfile from this repo:

/opt/msvc/bin/x64/cl /analyze /EHsc main.cpp

You get the following error:

Microsoft (R) C/C++ Optimizing Compiler Version 19.39.33523 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

main.cpp
?? : warning C28297: Model validation error: Failed to create read stream for source model file. System Error Message: File not found..
c1xx : fatal error C1253: Unable to load model file '\xe738\x124f'.

Based on the error message, this sounds like something which may be a temporary wine bug, possibly fixed by https://gitlab.winehq.org/wine/wine/-/commit/fb0fa9aacf0d58b3fd5f26255858a744b29ee000.

I just tested this command with a recent git version of wine, and the command ran fine.

Ok, hm. I guess I can custom compile wine for now for local builds (or try to create a docker container using a newer version of ubuntu which has a newer version of wine available in its repositories). Thanks!

Unfortunately, the fix for this is fairly recent - I tested and noticed that we need Wine 8.3 or newer (the fix is in https://gitlab.winehq.org/wine/wine/-/commit/aafef01cc2a0c49ed902e63edac6da4b0278e53f); even Ubuntu 23.10 doesn't have that version out of the box.

For reference, I was able to use the winehq repositories to get this working in an Ubuntu 20.04 container. The dockerfile (modified from the one in this repo):

FROM ubuntu:20.04

# Install dependencies
RUN apt-get update && \
    apt-get install -y python3 msitools ca-certificates wget

# Set up winehq PPA and install wine
RUN dpkg --add-architecture i386 && \
    mkdir -pm755 /etc/apt/keyrings && \
    wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key && \
    wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/focal/winehq-focal.sources && \
    apt-get update -y && \
    apt-get install -y --install-recommends winehq-stable

# Clean up
RUN apt-get clean -y && \
    apt-get autoremove -y && \
    rm -rf /var/lib/apt/lists/*

# Initialize the wine environment. Wait until the wineserver process has
# exited before closing the session, to avoid corrupting the wine prefix.
RUN $(command -v wine64 || command -v wine || false) wineboot --init && \
    while pgrep wineserver > /dev/null; do sleep 1; done

WORKDIR /opt/msvc

COPY lowercase fixinclude install.sh vsdownload.py msvctricks.cpp ./
COPY wrappers/* ./wrappers/

RUN PYTHONUNBUFFERED=1 ./vsdownload.py --accept-license --dest /opt/msvc && \
    ./install.sh /opt/msvc && \
    rm lowercase fixinclude install.sh vsdownload.py && \
    rm -rf wrappers

COPY msvcenv-native.sh /opt/msvc

# Later stages which actually uses MSVC can ideally start a persistent
# wine server like this:
#RUN wineserver -p && \
#    $(command -v wine64 || command -v wine || false) wineboot && \

If you wanted me to PR this I can, it would be trivial. Either way just wanted to post it here at least in case anybody else wants a quick fix.

Thanks! I'm not sure I want to merge this into the main repo right now, but thanks for sharing it!