-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
Create a Cross Compiler for a Bare Bones Freestanding Program (Bootloader/OS) #28160
Comments
Ah that osdev tutorial. Is
|
Also, not sure if you saw the comment in |
@Ericson2314 I'm not sure if
So if LLVM supports such a target flag, then perhaps I did have a skim over the llvm source, but I'm not familiar with LLVM's codebase, so I don't have a comment there. But where did you mean when you said "I guess there is an The other issue is that there is no One more question. How does crossSystem translate to buildPlatform, hostPlatform and targetPlatform? Because I'm running on x86_64-unknown-linux-gnu. And so I expect that buildPlatform and hostPlatform to be both x86_64-unknown-linux-gnu, because I am building the compiler and running the compiler on the same system, but I'm targeting code to a freestanding i686-elf. I did have a read of the new manual regarding these three properties, but I didn't quite understand this particular situation. |
@Ericson2314 is there some documentation regarding the usage of |
http://llvm.org/doxygen/classllvm_1_1Triple.html#a83e907e55fa50e093caa96a0aff96201a456b64e26b8bcdbd8294689615d8a055 is the enum variant or whatever, |
https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/misc/binutils/default.nix#L94 means we do pass it when it differs from |
See https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/cross/default.nix. This adds two additional bootstrapping stages, the first of which changes just the target platform, and the second of which also changes the host platform. If you have any suggestions on how I could make the docs clearer, I'd love to hear them! |
Examples for common use cases would be good. Kind of like. If I want to build on A, run on B, targeting C, how would I write a shell.nix/default.nix to do such a thing. Cross system specifications basically. Currently I only learned about the format of I would like the simple specification of
I see, so this means basically either I build and run on the same A, while targeting B, or I build on A, while running on B targeting B. Is there no use case for building on A, running on B and targeting C? In the mean time, I've been trying to just build the cross compilers directly using |
Ok, I'll keep that in mind.
Did you see
Well, the parser needs to understand it, not merely accept it. Based on the LLVM, understanding would be adding a new field in |
Correct. It would be cool if individual packages worked in that case, but I don't see why such a bootstrapping stage would be necessary. It might seem like it would save work, but as it stands, compilers like gcc are built with their own runtime for emitted programs, so a A->B->C gcc would require an A->A->C gcc anyways. What's' the point of B when one can just use that? |
This is A->A->B, not A->B->B? If we need to do it for any set of platforms, we should probably just |
I did finally build the gcc cross compiler but outside of the nixpkgs infrastructure. This required using sources of its dependencies gmp mpfr libmpc that was brought in from the the This was A->A->B. I kind of see what you mean by A->B->C being not necessary, but hopefully that can also be made clear on the manual as well.
What is |
sorry by "thingy" I meant any of I can't predict what autoconf with gcc and binutils would do with that config---but evidently something interesting based on the build failures you ran into. Then again, it could be cross compilation will generally be broken until #26805 is merged. |
#48286 might help you |
Yeah 52dbd33 should fix this. Let me know if there are issues using it. |
We don't precompile the i686-pc-elf target yet though. You can add it by adding it to examples.nix. |
Issue description
Hey @Ericson2314 I've been following your work on
lib.systems
, and I looked up the http://wiki.osdev.org/GCC_Cross-Compiler tutorial, and I found that the basic target ofi686-elf
ori686-pc-none-elf
doesn't seem supported by NixOS at the moment.The error message is simply:
error: Unknown ABI: elf
.The main issue here is that
lib.systems.elaborate
cannot parse the bare bones target. And from looking at the nix expressions for gcc and binutils, it appears that bare bones target hasn't been considered.What are your thoughts on this?
The text was updated successfully, but these errors were encountered: