Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

No .EXE on Windows 10 #22

Open
sal55 opened this issue Aug 12, 2022 · 9 comments
Open

No .EXE on Windows 10 #22

sal55 opened this issue Aug 12, 2022 · 9 comments

Comments

@sal55
Copy link

sal55 commented Aug 12, 2022

There's now a Windows binary which I tried out. But c3c compile hello.c3 produces only hello_world.obj (plus 20+ other *.obj files), no .exe.

What do I have to do to get hello.exe? compile-run did the same.

(Possibly it might be crashing; on this Windows 10 machine, if does so silently, although sometimes it shows a brief busy cursor which I've noticed here on some attempts.)

@lerno
Copy link
Collaborator

lerno commented Aug 12, 2022

Do you have VS or VS Build Tools installed?

@sal55
Copy link
Author

sal55 commented Aug 13, 2022 via email

@lerno
Copy link
Collaborator

lerno commented Aug 13, 2022

This is because you lack the .lib files C3 needs to link with, so unfortunately it's either the build tools or VS at this point. I'll try to minimize what's needed and see if C3 can't grab those things automatically on windows. But right now it's unfortunately so that an install is needed. Either with VS or the build tools from here: https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022

@lerno
Copy link
Collaborator

lerno commented Aug 14, 2022

To explain a bit more in detail: C3 has a linker built in, so it's not necessary to use link.exe on windows. However, the .lib files to link to windows libc is still necessary. Because linking isn't working, what you're left with are the generated object files, but no linked exe. And the reason why there isn't a linked exe is because the .lib files it needs are missing – and the only way to get those is by downloading them from MS.

@sal55
Copy link
Author

sal55 commented Aug 14, 2022 via email

@lerno
Copy link
Collaborator

lerno commented Aug 14, 2022

To explain:
The linking step needs .lib files on windows to link to windows libc and get all the crt startup etc. These are actually just a small set of files in ucrt and um that you really need. It would be a simple thing to just copy ucrt and um and zip them. That would give msvc cross compilation out of the box. This is what I want to do.

The problem is that while some files can be distributed, some may not and that includes the .lib for linking to the libc runtime.

The only legal way is therefore to ask the user to download these files directly from MS. That is the problem.

For detecting VS, there's a rather short but complicated piece of code doing tricks to try to find VS or VS build tools, since the actual path may vary. I did not author that code, nor did I introduce it to the code base. My suspicion is that this fails silently, giving you the poor user experience you have right now. I'm not set up on MSVC, and I mainly fix things by trial and error using CI, which is why it is poorly tested.

@lerno
Copy link
Collaborator

lerno commented Aug 14, 2022

I have some hope that this will change though. I will try to provide a script to pull in the necessary libraries and collect them in the c3c install folder allowing one to avoid downloading the full build tools and just keep the relevant .libs for compilation.

@lerno
Copy link
Collaborator

lerno commented Aug 14, 2022

Finally, the size of c3c is mainly due to LLVM. Note that it is compiled with full cross compilation capabilities on a wide set of targets. Plus it also bundles linkers in the same platform.

The actual compiler is very small in comparison. Even before linking the adding up the sizes of all object files gives you less than 6 MB of code. The binary is 130 MB on my machine...

@lerno
Copy link
Collaborator

lerno commented Sep 9, 2022

I want to mention that we now have a script to pull in all the dependencies needed to build on windows without the need for downloading the build tools manually.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants