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

minGW Windows support in-scope? #30

Closed
JesseRMeyer opened this issue Jan 10, 2021 · 3 comments
Closed

minGW Windows support in-scope? #30

JesseRMeyer opened this issue Jan 10, 2021 · 3 comments

Comments

@JesseRMeyer
Copy link

Hi,

Cosmopolitan currently assumes a Linux environment to build ape programs. However, my primary development is on and for Windows. Is minGW support within the scope of this project (assuming global 'minGW' support is even possible)? Apparently gcc on minGW is currently configured exclusively for elf output, so certain assembler directives simply do not exist. Recognizing that beggars cannot be choosers, is there a possibility of more general Clang compiler support, which already supports Windows? Would an integrated linker resolve these issues (I noticed a related remark in a recent commit message)?

> gcc -g -O -static -fno-pie -mno-red-zone -nostdlib -nostdinc -o hello.com hello.c -Wl,--oformat=binary -Wl,--gc-sections -Wl,-z,max-page-size=0x1000 -fuse-ld=bfd -Wl,-T,ape.lds -include cosmopolitan.h crt.o ape.o cosmopolitan.a

C:\Users\JESSEM~1\AppData\Local\Temp\cckTmCRU.s: Assembler messages:
C:\Users\JESSEM~1\AppData\Local\Temp\cckTmCRU.s:35: Error: unknown pseudo-op: `.pushsection'
C:\Users\JESSEM~1\AppData\Local\Temp\cckTmCRU.s:37: Error: unknown pseudo-op: `.popsection'

Thanks!

@jart
Copy link
Owner

jart commented Jan 10, 2021

You can compile an x86_64-linux-gnu cross compiler toolchain for Windows. But I recommend just running Linux in a virtual machine and using that to compile. Builds actually go faster in a virtual machine on Windows than on Windows itself. It's not possible to support a MinGW toolchain because it uses COFF, which imposes restrictions on things like the length of section names that would otherwise make Actually Portable Executable impossible. The same is true of Mach-O. You have to use an ELF toolchain. It's totally possible to have an ELF toolchain on Windows. It's just prebuilt binaries for such a thing are hard to find online and it's hard to configure a build from scratch to create them.

@jart jart closed this as completed Jan 10, 2021
jart added a commit that referenced this issue Jan 10, 2021
@jart
Copy link
Owner

jart commented Jan 10, 2021

Regarding the integrated linker, I'm assuming you're referring to 81ef162 which is discussed further in https://github.com/jart/cosmopolitan/blob/master/third_party/chibicc/README.cosmo An integrated linker would be nice, since the chibicc compiler can be built as an actually portable executable. Keep in mind it's not a replacement for GCC which has decades of development behind it and can generally produce code that's twice as fast.

@jart
Copy link
Owner

jart commented Jan 18, 2021

There's now a tutorial on the website on how to build Actually Portable Executables on Windows. Static binaries are provided of an x86_64-linux-gnu cross-compiler toolchain which runs on Windows. https://justine.lol/cosmopolitan/windows-compiling.html

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