Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Building on windows #53

Closed
4 of 7 tasks
LaylBongers opened this issue Jan 8, 2016 · 42 comments
Closed
4 of 7 tasks

Building on windows #53

LaylBongers opened this issue Jan 8, 2016 · 42 comments
Labels
first-edition Refers to the first edition of the book

Comments

@LaylBongers
Copy link

Setting up the build on windows isn't actually that hard once you've got the right binaries. Getting the binaries however are the problem. I propose we get together a .zip package containing all the tools needed to start kernel developing. Here's a list of the tools we would need binaries of:

  • Rust: Extremely easy to install and set up, doesn't have to be included
  • qemu: Easy to install, perhaps we should include it anyways though. If not then at least drop a link to it on the windows specific page (edit: because it's not a simple self-contained tool that's easily installed, let's avoid including it)
  • nasm.exe: Pre-compiled already available, I still think we should bundle it
  • x86_64-elf-ld.exe: Should be just a compile of binutils away
  • make.exe: Available through msys2, I still think we should bundle it
  • grub-mkrescue: A nightmare to get it seems, I've heard rumors it builds under cygwin but couldn't confirm. If there's alternative ways to set up the image that would be great.
  • xorriso: Windows alternatives exist but if we can just get xorriso it would be nice, I haven't looked much into this.
@steveklabnik
Copy link
Member

I propose we get together a .zip package containing all the tools needed to start kernel developing.

I like this idea.

@LaylBongers
Copy link
Author

Added a note on qemu, redistributing it probably is more trouble than it's worth. It's easily installed and isn't just a simple single executable.

@LaylBongers
Copy link
Author

I've found more online references to GRUB2 being build-able under windows Cygwin, it may be worth a try but it will definitely take more time than I have spare for this week.

@LaylBongers
Copy link
Author

I've stopped working on getting a toolset together for windows, as I switched to Arch myself. I still think a pre-packaged set of tools would be useful to have however.

@feliwir
Copy link

feliwir commented Apr 11, 2016

I use Msys2 windows 10 which allows to use the package manager pacman. Every required binary can be installed using: pacman -S mingw-w64-x86_64-(binary) (e.g. pacman -S mingw-w64-x86_64-nasm). The only missing binary i have right now is grub-mkrescue, but I'll ask the msys2 maintainers if they might be so kind and add it as a package

EDIT:
I've build grub2 binaries myself using msys2. Which doesn't really work, so you might want to try something else than grub-mkrescue to create the iso on windows

@LaylBongers
Copy link
Author

The problem is that the binaries you need are special ones compiled just for cross-compiling. Installing mingw-w64-x86_64-gcc will not give you a gcc capable of creating a kernel.

@feliwir
Copy link

feliwir commented Apr 11, 2016

yeah, but on mingw it is no problem to compile gcc (or any other package for that matter) as a cross compiler. Also multirust is official supporting msys2 as buildsystem, see the multirust repository. I've also found official grub2 binaries for windows: ftp://alpha.gnu.org/gnu/grub/grub-2.02~beta2-for-windows.zip . They contain grub-mkimage and grub-mkstandalone but not grub-mkrescue for some reason, so maybe it would be viable to use those commands instead of grub-mkrescue?
By the way where exactly is gcc required to build the kernel?
Isn't it just enough to do: multirust add-target x86_64-unknown-linux-gnu ??

@LaylBongers
Copy link
Author

Most of this seems to have become irrelevant with the introduction of ubuntu userspace in windows 10.

@steveklabnik
Copy link
Member

Yes, it's certainly much easier with it. That said, Windows 10 is pretty new, so can we really assume it?

@rylev
Copy link
Contributor

rylev commented May 21, 2016

Having used the subsystem a little bit, I can tell you it's still quite rough. I would be careful relying on it for now.

@ncarrillo
Copy link

There's currently a bug blocking rustc from running on Windows: microsoft/WSL#258

@amanuel2
Copy link

Anyone succeded on doing this? grub-mkrescue? ...

@feliwir
Copy link

feliwir commented Oct 11, 2016

Yes it works without any issues on bash for windows. For grub-mkrescue you need to install the package "grub2-common"

@amanuel2
Copy link

No. I want for cygwin so i can get it for , school since it will be portable

@feliwir
Copy link

feliwir commented Oct 12, 2016

grub-mkrescue can't be compiled with cygwin or msys, so no it isn't possible

@amanuel2
Copy link

Hmm Are you sure? Because last time it was more like "grub cant be compiled in windows" . Turns out , it can.

@feliwir
Copy link

feliwir commented Oct 12, 2016

Grub itself can be built, but last time i checked on msys grub-mkrescue didn't compile. You can of course get the sources and check for yourself

@amanuel2
Copy link

@feliwir hmm dosent seem it dosent , im just gonna change to windows bash

@feliwir
Copy link

feliwir commented Oct 12, 2016

@amanuel2 yes thats by far the easiest&best solution for os development on windows right now

@amanuel2
Copy link

@feliwir yep , i just builded it. Well , right now trying to figure out how to create your own pure cout << like object using namespaces

@LaylBongers
Copy link
Author

Perhaps this should be closed in favor of a guide for setting up Ubuntu on Windows for kernel development? It's going to be a better experience in almost every way than messing your way around windows itself.

@amanuel2
Copy link

@LaylConway No dont close it.. If any other people have question they can always ask!

@LaylBongers
Copy link
Author

@amanuel2 This is an issue focused on solving a specific problem with the guide, not an open-ended Q&A issue.

@amanuel2
Copy link

@LaylConway Yea , and? Btw checkout https://github.com/Bone-Project/BoneOS

@LaylBongers
Copy link
Author

This isn't the time or the place for advertising projects. My point is that this issue isn't meant to be for asking questions, it's for exploring and implementing a specific solution to a certain problem. Given that by now the problem has moved I'm closing this issue as it's not relevant anymore.

@ketsuban
Copy link
Contributor

ketsuban commented Jun 24, 2017

I disagree with this issue being closed - while the Linux subsystem on Windows 10 can and should be the primary recommendation for following intermezzOS due to ease of use, it mustn't be the only one. Not everyone is on Windows 10, for one - I used to be, but starting with Insider Preview build 14958 it bluescreens so frequently on my machine that I can't even finish installing/upgrading. I ended up going back to Windows 7.

Fortunately setting things up on Windows seems mostly doable with only instructions on installing MSYS2 and cross-compiling Binutils. The bit I haven't yet worked out is how to get grub-mkrescue.

@steveklabnik
Copy link
Member

@ketsuban I actually use Windows as my primary platform now, and so have wanted to make stuff work regardless.

@steveklabnik steveklabnik reopened this Jun 27, 2017
@AlexandreRouma
Copy link

Hey guys, I might come a bit late, but it IS possible to build an ISO using grub-mkrescue on windows !
To do it you will need an Ubuntu 16.04 machine (virtual or not, doesn't matter) and copy the folder /usr/lib/grub/i386-pc to the /usr/lib/grub folder on Bash For Windows. It's as easy as that !

I've asked the guys at LSW to include an option to download the grub binaries, hope they will add that in the future !

@LaylBongers
Copy link
Author

If you have bash-for-windows, you can just apt-get install grub-pc-bin iirc

@AlexandreRouma
Copy link

If you have bash-for-windows, you can just apt-get install grub-pc-bin iirc

Tried that and sadly it fails :/
Might be a problem with my LSW though

@steveklabnik
Copy link
Member

Bash For Windows.

I did get stuff working on Bash for Windows, but I'd also like a native build. intermezzOS/kernel#118

@Restioson
Copy link

Restioson commented Mar 5, 2018

Hi! I might take a look at getting this to work. I came up with a few ways to help reduce dependencies:

  1. Switch over from Make to a python build script (python is very readily available for windows). I have this almost finished in my clone locally.
  2. Switch from nasm to the global_asm macro. Also done in clone locally.
  3. Switch from an explicit invocation of ar to letting rustc do it for us. I'm a bit confused about this one - the book does not use ar. Any help would be appreciated here.

Grub does distribute files from their ftp server for windows. Here's what it contains: https://i.imgur.com/qmzazD9.png.
Unfortunately, this does not include grub-mkrescue. It does include grub-mkimage though. Maybe this is similar/a subsitute?

@feliwir
Copy link

feliwir commented Mar 5, 2018

No, it’s not a valid substitute. I think the author knows about those grub binaries for windows already

@Restioson
Copy link

Ok. I think with the changes I've proposed just qemu and grub-mkrescue will be required.

@steveklabnik
Copy link
Member

I am a fan of reducing dependencies; ideally, someday, this would all be 100% rust and just use cargo. one motivation is for exactly this kind of cross-platform issue.

@Restioson I'd be interested in seeing your diffs. My rough feels:

  1. I'd rather switch to say, a custom Cargo subcommand in Rust than add a Python dependency.
  2. Getting rid of nasm would be excellent 👍
  3. "Switch from an explicit invocation of ar to letting rustc do it for us" I... am not sure what this is.

reducing dependencies is good, even if we can't get 100% of the way there.

@Restioson
Copy link

Restioson commented Mar 6, 2018

I haven't finished completely. I'm mostly done, except I don't know what the invocation of ar is for... see response to 3

  1. Perhaps a justfile/cargo make or something similar? I just pulled python out of thin air since rustc uses a python buildscript too and it was easy for me to prototype.
  2. Personally, I'm not really sure what the invocation of ar in the build.rs does :L. The book only mentions ld. I think rustc should be able to do most of this for us anyway. Theoretically we can just build it as a library crate with a custom layout.ld

@steveklabnik
Copy link
Member

Personally, I'm not really sure what the invocation of ar in the build.rs does

OH! I remember now, sorry. So, I was trying to replace some of the make stuff with build scripts to get rid of make.

HOWEVER

At the same time you popped up, this happened over on the kernel repo: intermezzOS/kernel#118 (comment)

I think working toward adopting phil's stuff is probably the best path forward, as it completely eliminates all of this.

@Restioson
Copy link

Restioson commented Mar 7, 2018

Ooh, that looks super nice! I totally agree, I'm just wondering how images to run in qemu will be built... Does his bootloader project include something that could help with that? I think we still need to get rid of make and perhaps replace it with Cargo-make or Just.

@Restioson
Copy link

Looks like it should be able to support building a bootable image with help of objcopy.

@steveklabnik
Copy link
Member

The output of bootimage --target produces a bootimage.bin that's runnable. bootimage does all the work of invoking cargo, etc, so that's just one command to build, no need for make or anything :)

@steveklabnik steveklabnik added the first-edition Refers to the first edition of the book label Mar 25, 2018
@steveklabnik
Copy link
Member

The second edition now builds on Windows: https://ci.appveyor.com/project/steveklabnik/kernel (still gotta fix gnu, but that's a different issue and I'll deal with it soon).

I'm not working on the first edition anymore, so I'm going to give this a close. If someone wants to send in a PR to fix up the first edition, please feel free, but it seems like a lot of effort for very little reward.

@PeyTy
Copy link

PeyTy commented Mar 5, 2020

I'll leave this here, because this page is what Google shows for "xorriso windows"

https://github.com/PeyTy/xorriso-exe-for-windows

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
first-edition Refers to the first edition of the book
Projects
None yet
Development

No branches or pull requests

10 participants