Skip to content

Conversation

mikmart
Copy link
Contributor

@mikmart mikmart commented Aug 17, 2025

This PR introduces a nob build and uses it to add MSVC support.

Motivation:

I wanted to add an MSVC build for the B compiler. It would be convenient with my WIP MSVC codegen plugin so you can work on Windows without any GNU toolchain. Trying to do that in the Makefile was a huge mess.

Since we already require both a C compiler and nob.h to build the B compiler, it seemed like a natural choice to introduce a nob build that could eventually replace the Makefile.

Cons:

  • No incremental builds.

Pros:

  • No incremental builds.
  • No dependency on make -- one less moving part.
  • Real programming language to handle build complexities.

Tested on:

  • Windows 10 with TARGET_MSVC
  • WSL Ubuntu with TARGET_MINGW32
  • WSL Ubuntu with TARGET_POSIX

I know you've said on stream and in #283 that you'd prefer to extend bgen for the build. But as bgen still needs to be bootstrapped and the C files need to be compiled, I think switching to nob for that would still have tangible benefits.

What do you think?

@nullnominal
Copy link
Contributor

I think ./nob should bootstrap, then ./build/bgen should do the rest

@mikmart
Copy link
Contributor Author

mikmart commented Aug 19, 2025

That makes sense conceptually. But consider that the bgen bootstrapper needs to be able to:

  1. Build the thirdparty objects.
  2. Build a Crust executable.
  3. Do 1-2 using for the toolchain/OS of your choice.

Those are the same capabilities that are currently required to build b and btest. By necessity the bootstrapper has them, but right now bgen doesn't. So at least right now I don't see the benefit of asking bgen to learn to do those as well.

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

Successfully merging this pull request may close these issues.

2 participants