OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 9:19 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Native build of binutils/gcc
PostPosted: Wed Jan 21, 2015 11:20 am 
Offline
Member
Member

Joined: Sat Oct 16, 2010 3:38 pm
Posts: 587
This question may seem very simple but I cannot find information about this on the wiki and the answer is probably stupidly obvious, sorry.

I've got a C library, and a cross-compiler to my OS (x86_64-glidix). The --prefix I use is /glidix (the exec-prefix for binutils and gcc is /usr, so I can access them without modifying the PATH). Porting libraries is obviously very easy (e.g. the ones that GCC depends on): I just have to give them the prefix and simply install; they'll be in the cross-compiler search path.

But how do I configure binutils and GCC to actually do native builds for my OS? I don't want to install the Glidix executables on my Linux system for obvious reasons... so what configuration options am I supposed to use, and which files shall I copy and where to, on the filesystem that Glidix runs on?

I hope the question is understandable...


Top
 Profile  
 
 Post subject: Re: Native build of binutils/gcc
PostPosted: Wed Jan 21, 2015 12:31 pm 
Offline
Member
Member

Joined: Wed Oct 30, 2013 1:57 pm
Posts: 306
Location: Germany
I'm a tiny little bit confused by your question. I'll try my best to ask specific questions to get some information.

1st: What's 'x86_64-glidix'? Is it a renamed 'x86_64-elf' or what?
2nd: Why don't you want to install your OS-Specific toolchain on your machine? It doesn't conflict with any other gcc or binutils install ...
3rd: Have you already taken a look at the OS Specific Toolchain wiki page?

_________________
managarm


Top
 Profile  
 
 Post subject: Re: Native build of binutils/gcc
PostPosted: Wed Jan 21, 2015 1:46 pm 
Offline
Member
Member

Joined: Thu Mar 25, 2010 11:26 pm
Posts: 1801
Location: Melbourne, Australia
You need something like this..
Code:
../binutils-$BINUTILS_VER/configure --target=x86_64-glidix --prefix=/usr --with-sysroot=/ --with-build-sysroot=~/build-sysroot --host=x86_64-glidix
DESTDIR=~/build-sysroot make all
DESTDIR=~/build-sysroot make install
Note that ~/build-sysroot is the folder that contains the root file system that you are building for your OS. That is to say that everything under ~/build-sysroot will be installed onto your OS's root file system on the target machine eventually.

_________________
If a trainstation is where trains stop, what is a workstation ?


Top
 Profile  
 
 Post subject: Re: Native build of binutils/gcc
PostPosted: Wed Jan 21, 2015 1:53 pm 
Offline
Member
Member

Joined: Sat Oct 16, 2010 3:38 pm
Posts: 587
no92 wrote:
I'm a tiny little bit confused by your question. I'll try my best to ask specific questions to get some information.

1st: What's 'x86_64-glidix'? Is it a renamed 'x86_64-elf' or what?
2nd: Why don't you want to install your OS-Specific toolchain on your machine? It doesn't conflict with any other gcc or binutils install ...
3rd: Have you already taken a look at the OS Specific Toolchain wiki page?


x86_64-glidix is the OS specific toolchain. That is installed on my machine (so the GCC that makes executable for my OS is x86_64-glidix-gcc). I was asking about how I would use that cross-compiler to build itself to run ON my OS, as well as TARGET my OS. I think the other user just answered my question, so thanks to him (sorry, I can't look at what your username was while typing this).


Top
 Profile  
 
 Post subject: Re: Native build of binutils/gcc
PostPosted: Wed Jan 21, 2015 2:14 pm 
Offline
Member
Member
User avatar

Joined: Wed Mar 21, 2012 3:01 pm
Posts: 930
Hi mariuszp. Congratulations on getting this far!

I've ported a lot of software to my OS, including a fully functional gcc and binutils toolchain. I've written, or contributed to, a bunch of wiki articles on this matter that should be relevant.

http://wiki.osdev.org/OS_Specific_Toolchain - This was already linked and I gather you already have one, might as well check you are up to date with recent changes.
http://wiki.osdev.org/Hosted_GCC_Cross-Compiler - You say you already have a libc, so it sounds like you're already setting up your cross-compiler in this matter, but you probably want to doublecheck.
http://wiki.osdev.org/Cross-Porting_Software - This is the important tutorial I want to make sure you've seen. It documents how to reliably cross-compile third party software the *right* way. From your original post, I get the impression you're doing this entirely wrong. You are meant to set --prefix to the location on your OS where it will be installed, it has nothing to do with your local build machine. After building, set DESTDIR in the make install step to add a second prefix for the purpose of installation. This is useful for package management, but also for cross-compilation where you want to install into your system root.

I don't think you know exactly what a exec-prefix is. A package installs often both machine independent files (man pages, images, documentation, headers, ...) and machine dependent files (programs, libraries, ...). You might want to install those in different places, such as on systems where multiple architectures can co-exist peacefully. Then you can --prefix=/usr -exec-prefix=/usr/x88_64 and get /usr/include/foo.h and /usr/x86_64/lib/libfoo.a.

I'm not entirely sure if you use sysroots and whether you understand their use. They're crucial for proper cross-compilation and you should use them.

If you are a bit curious how sysroots and such should be used:
http://wiki.osdev.org/Meaty_Skeleton - This is my template operating system and uses a sysroot.

As for your original question, to cross-compile a native compiler (binutils, gcc) for your OS, you follow the instructions in Cross-Porting Software. However, you want to use a sysroot while building binutils and gcc, but you don't want the packages to remember that sysroot after installation. Use --with-build-sysroot=/home/you/youros/sysroot and --with-sysroot=/. That effectively disables the system root after installation. I don't think I've yet written a wiki article on a native gcc, but it's basically to combine OS Specific Toolchain with Cross-Porting Software and this paragraph.

I hope that helped, let me know if you have further question.


Top
 Profile  
 
 Post subject: Re: Native build of binutils/gcc
PostPosted: Wed Jan 21, 2015 4:12 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2014 9:11 am
Posts: 901
Location: Maadi, Cairo, Egypt
sortie wrote:
I've ported a lot of software to my OS, including a fully functional gcc and binutils toolchain.

Please have mercy to those who wish to port anything to their OS :mrgreen: :twisted:

_________________
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: Native build of binutils/gcc
PostPosted: Mon Jan 26, 2015 12:52 pm 
Offline
Member
Member

Joined: Thu May 06, 2010 4:34 am
Posts: 116
Location: Leiden, The Netherlands
sortie wrote:
http://wiki.osdev.org/Cross-Porting_Software - This is the important tutorial I want to make sure you've seen. It documents how to reliably cross-compile third party software the *right* way. From your original post, I get the impression you're doing this entirely wrong. You are meant to set --prefix to the location on your OS where it will be installed, it has nothing to do with your local build machine. After building, set DESTDIR in the make install step to add a second prefix for the purpose of installation. This is useful for package management, but also for cross-compilation where you want to install into your system root.
I'm not entirely sure if you use sysroots and whether you understand their use. They're crucial for proper cross-compilation and you should use them.

If you are a bit curious how sysroots and such should be used:
http://wiki.osdev.org/Meaty_Skeleton - This is my template operating system and uses a sysroot.


Since when do these resources exist? I couldn't find anything when I was working on this and am still left with a very messy cross compilation system.

_________________
posnk ( a simple unix clone )
twitter profile - security research, die shots and IC reverse engineering, low level stuff


Top
 Profile  
 
 Post subject: Re: Native build of binutils/gcc
PostPosted: Tue Jan 27, 2015 1:40 pm 
Offline
Member
Member
User avatar

Joined: Wed Mar 21, 2012 3:01 pm
Posts: 930
Meaty Skeleton is a year old. Cross-Porting Software is some months old. I basically created the articles to show how to cross-compile operating systems and ports properly. I know what you mean by a messy cross compile system, it took me a while to get to these recommendations. Be sure to let me know if you have further questions or desire further wiki articles on similar subjects.

Porting is half making your cross scripts more intelligent and robust at setting up the environment so it plays by the rules, and half fixing the bullshit that third party software does so they also play by the rules.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 20 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group