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

Nuke MSYS2 #1049

Open
jpgpng opened this issue Aug 31, 2022 · 12 comments
Open

Nuke MSYS2 #1049

jpgpng opened this issue Aug 31, 2022 · 12 comments

Comments

@jpgpng
Copy link

jpgpng commented Aug 31, 2022

I managed to build and use cm3 without MSYS2. This turns out to be easier than you think.

Requirements: mingw64 + cmake + ninja, all added to Windows PATH and of course Python 3

In concierge.py (https://github.com/modula3/cm3/blob/master/scripts/concierge.py) at line 1538 commented out all of these lines to be something like this:

        # Special considerations for NT.
        #if self.config() == "AMD64_NT":
            #setup = setup + ["-A", "x64"]
        #elif self.config() == "I386_NT":
            #setup = setup + ["-A", "Win32"]

Reasons: Generator Ninja does not support platform specification, but platform x64 was specified. It's also true for NMake Makefiles.

Have to specify --target AMD64_MINGW to concierge.py otherwise it will default to AMD64_NT and error because of not found cl.exe.

So finally, the command is something like this:

python ..\cm3-dist\scripts\concierge.py install --prefix [where you want to install cm3] -G "Ninja" --target AMD64_MINGW

Now, this is about building from latest git source. On pylib.py (https://github.com/modula3/cm3/blob/master/scripts/python/pylib.py) at line 1862 commented out all of these lines to be something like this:

        #_SetupEnvironmentVariableAll(
            #"PATH",
            #["sh", "sed", "gawk", "make"],
            #os.path.join(SystemDrive, "msys", "1.0", "bin"))

Reasons: we are using mingw64 and we don't have msys 1.0 or any needs of msys 1.0.

Everything later is just straight forward.

@jaykrell @VictorMiasnikov

@jpgpng
Copy link
Author

jpgpng commented Aug 31, 2022

Note: Still have to delete these two lines in cm3.cfg and replace with hardcoded HOST and TARGET like #1029

Delete:

if not defined("HOST") HOST = "AMD64_MINGW" end
if not defined("TARGET") TARGET = HOST end

Replace with:

HOST = "AMD64_MINGW"
TARGET = HOST

Have to redo this after boot2.py as it overwrote cm3.cfg.

@jaykrell
Copy link
Contributor

Thank you your extra work and reporting here.
I will try to improve things.
What you point out in pylib.py is a bit of a hack, I agree, and is hurting not helping.
We can/should probably just remove those lines.

Host really shouldn't be needed in cm3.cfg. That is wierd.
I have tiried to simplify cm3.cfg in general, and host/target specifically but it is possible this area needs more work.

Host really is supposed to be known by the executable itself, and it isn't even supposed to matter much.
The main thing was to put forward or backward slashes in places, even though forward always work. Silly.
There is a lot of legacy in the system. Like where host mattered too much. We have more work to do...

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Aug 31, 2022 via email

@jpgpng
Copy link
Author

jpgpng commented Aug 31, 2022

Update: build also fine with Clang (https://github.com/mstorsjo/llvm-mingw). But need editing pylib.py (https://github.com/modula3/cm3/blob/master/scripts/python/pylib.py) to comment out these lines (starting at line 1841) to be something like this:

        #_SetupEnvironmentVariableAll(
            #"PATH",
            #["gcc", "as", "ld"],
            #os.path.join(SystemDrive, "mingw", "bin"))

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Aug 31, 2022

( Possible duplicate . . . )

Cm3 AMD64_NT can be build with clang.exe too
( "as information")


This document here said Visual Studio is needed. I don't want to install Visual Studio and GCC was said to be also supported so I want to use cm3 with GCC on my Windows. I'm using winlibs.com GCC build, but if MSYS2 is required I could install MSYS2 too.

https://github.com/modula3/cm3/wiki/Getting-Started%3A-Windows

+

{{

Winlibs.com GCC builds were designed to use with MSYS2 but if we are on MSYS2 why don't just use it GCC packages instead? Everything will be easier to be managed by just the pacman package manager. BTW, there seems to be a POSIX environment is needed so we will need MSYS2 (a distribution of MinGW-W64 alone like Winlibs.com's builds are not enough).

}}

} Visual Studio is needed

We are need some libs and "build tools" from / related Visual Studio for targets AMD64_NT, I386_NT.
We can choice between cl.exe and clang.exe

} MSYS2 (a distribution of MinGW-W64

MinGW environment is need for targets AMD64_MINGW, I386_MINGW.
( 2022-08-31: ^^^^^^^^ I save text as "history artifact")

CygWin - for targets AMD64_CYGWIN, I386_CYGWIN

@jpgpng
Copy link
Author

jpgpng commented Aug 31, 2022

This Clang (https://github.com/mstorsjo/llvm-mingw) as it name tell you it's mingw based. It's different from the Clang you mentioned. AMD64_NT will always need MSVC.

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Aug 31, 2022 via email

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Aug 31, 2022 via email

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Aug 31, 2022 via email

@ghost
Copy link

ghost commented Aug 31, 2022

Oh man, clang-cl is a completely different compiler to clang. Yes, it's clang under the hood and understand most of clang switches. It's indeed a modified clang to mimic cl.exe. The story is Microsoft's very own compiler cl.exe is too sucks and not as standard compliant as clang so they decided to wrap clang in clang-cl to support cl.exe switches. But, clang-cl and cl.exe are not completely compatible and clang-cl can't be used as a drop-in replacement for cl.exe. Proprietary vendors all did it when there own home grown compiler too sucks they fork open source ones, make them closed source (perfectly fine as llvm license allows that) and make wrappers like that. Borland (or now Embarcadero) did the same with bcc32c is the original compiler and bcc32 is the clang wrapper. Not just Microsoft.

@VictorMiasnikov
Copy link
Contributor

VictorMiasnikov commented Sep 1, 2022

Oh man, clang-cl is a completely different compiler to clang. Yes, it's clang under the hood and understand most of clang switches. It's indeed a modified clang to mimic cl.exe. The story is Microsoft's very own compiler cl.exe is too sucks and not as standard compliant as clang so they decided to wrap clang in clang-cl to support cl.exe switches. But, clang-cl and cl.exe are not completely compatible and clang-cl can't be used as a drop-in replacement for cl.exe. Proprietary vendors all did it when there own home grown compiler too sucks they fork open source ones, make them closed source (perfectly fine as llvm license allows that) and make wrappers like that. Borland (or now Embarcadero) did the same with bcc32c is the original compiler and bcc32 is the clang wrapper. Not just Microsoft.

It looks like we should "migrate" "Clang-cl sub-issue" to another ( new?) Issue . . .

ToDo: search it Or create

P.S. 2022-09-02:

} different between clang.exe and clang-cl.exe

It's interested topic, but best placed it inside dedicated issue ( or discussion)

@ghost
Copy link

ghost commented Sep 1, 2022

It looks like we should "migrate" "Clang-cl sub-issue" to another ( new?) Issue . . .

ToDo: search it Or create

Oh nonsense man. I'm trying to explain to you the different between clang.exe and clang-cl.exe and it seems you are confused between the two. If you don't want it, I will shut up.

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