Help Building Binutils

Programming, for all ages and all languages.
Post Reply
Sect0r
Posts: 6
Joined: Tue Nov 17, 2020 9:14 am

Help Building Binutils

Post by Sect0r »

Hello!
I've been following the wiki tutorial on how to build my compiler and im running into a bit of a problem,

Code: Select all

mkdir build-binutils
cd build-binutils
../binutils-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
do i need to have '/binutils-x.y.z/configure' in my '/src' directory, is it already on the cygwin system or am i just dumb?

Thanks in advance!
(sorry if this isn't the correct place to post this issue :-| )
sj95126
Member
Member
Posts: 151
Joined: Tue Aug 11, 2020 12:14 pm

Re: Help Building Binutils

Post by sj95126 »

It's hard to say because you didn't post any error messages, but here's how I built binutils on cygwin:

Code: Select all

export PREFIX=/usr/local/x86_64-elf
export TARGET=x86_64-elf
export PATH="$PREFIX/bin:$PATH"

cd build-binutils
../binutils-2.34/configure --target=$TARGET --prefix=$PREFIX --with-sysroot --disable-nls --disable-werror
make ; make install
There may be some library prerequisites. I'm not remembering which at the moment, but I think I remember that the cygwin repository didn't offer all of them and some had to be built from source.
foliagecanine
Member
Member
Posts: 148
Joined: Sun Aug 23, 2020 4:35 pm

Re: Help Building Binutils

Post by foliagecanine »

binutils-x.y.z is a placeholder for whatever version of binutils you are building.

For example, for binutils 2.31, you would download and extract it.
It should produce the binutils-2.31 folder.
Then you would create and cd into your build-binutils folder.
Then you would execute the configure script in the binutils-2.31 folder by doing ../binutils-2.31/configure <arguments>
My OS: TritiumOS
https://github.com/foliagecanine/tritium-os
void warranty(laptop_t laptop) { if (laptop.broken) return laptop; }
I don't get it: Why's the warranty void?
Sect0r
Posts: 6
Joined: Tue Nov 17, 2020 9:14 am

Re: Help Building Binutils

Post by Sect0r »

sj95126 wrote:It's hard to say because you didn't post any error messages, but here's how I built binutils on cygwin:

Code: Select all

export PREFIX=/usr/local/x86_64-elf
export TARGET=x86_64-elf
export PATH="$PREFIX/bin:$PATH"

cd build-binutils
../binutils-2.34/configure --target=$TARGET --prefix=$PREFIX --with-sysroot --disable-nls --disable-werror
make ; make install
There may be some library prerequisites. I'm not remembering which at the moment, but I think I remember that the cygwin repository didn't offer all of them and some had to be built from source.
Oh, i'm sorry.
I'm using Cygwin and installed binutils with the package selection thing, i just need to build it.

Code: Select all

../binutils-2.34/configure --target=$TARGET --prefix=$PREFIX --with-sysroot --disable-nls --disable-werror
-bash: ../binutils-2.34/configure: No such file or directory

is there a specific directory it is in or...
sj95126
Member
Member
Posts: 151
Joined: Tue Aug 11, 2020 12:14 pm

Re: Help Building Binutils

Post by sj95126 »

configure should definitely be at the top level of the binutils-x.y.z directory.

I would just download the binutils-x.y.z sources from gnu.org and build them. That's what I did (binutils 2.34 on cygwin64/Win10). Both it and gcc built just fine for both 32-bit and 64-bit elf targets.
foliagecanine
Member
Member
Posts: 148
Joined: Sun Aug 23, 2020 4:35 pm

Re: Help Building Binutils

Post by foliagecanine »

The tree should look something like this:

Code: Select all

|
├── binutils-2.31.1
│   └── configure
├── build-binutils
├── build-gcc
└── gcc-7.3.0
    └── configure
To build binutils, cd into build-binutils, then run the ../binutils-2.31.1/configure command.
To build gcc, cd into build-gcc, then run the ../gcc-7.3.0/configure command
My OS: TritiumOS
https://github.com/foliagecanine/tritium-os
void warranty(laptop_t laptop) { if (laptop.broken) return laptop; }
I don't get it: Why's the warranty void?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Help Building Binutils

Post by Solar »

Sect0r wrote:I'm using Cygwin and installed binutils with the package selection thing, i just need to build it.
The binutils you install via your platform's package manager -- no matter whether that's Cygwin, Windows, Linux or something else -- is a ready-built package of binutils binaries that are targeted for your platform. That is fine if you want to use the binutils to handle binaries for your platform. For building your "My Own OS" compiler, they are not necessary.

If you want to build your own binutils, targeting your own "My Own OS" platform, you start with the sources for binutils, which you can (and should!) download directly from the GNU.org FTP server.

The "binutils-x.y.z" directory mentioned in the Wiki How-To is the directory where those sources are located.
Every good solution is obvious once you've found it.
Sect0r
Posts: 6
Joined: Tue Nov 17, 2020 9:14 am

Re: Help Building Binutils

Post by Sect0r »

Solar wrote:
Sect0r wrote:I'm using Cygwin and installed binutils with the package selection thing, i just need to build it.
The binutils you install via your platform's package manager -- no matter whether that's Cygwin, Windows, Linux or something else -- is a ready-built package of binutils binaries that are targeted for your platform. That is fine if you want to use the binutils to handle binaries for your platform. For building your "My Own OS" compiler, they are not necessary.

If you want to build your own binutils, targeting your own "My Own OS" platform, you start with the sources for binutils, which you can (and should!) download directly from the GNU.org FTP server.

The "binutils-x.y.z" directory mentioned in the Wiki How-To is the directory where those sources are located.
Oooooh..
That makes much more sense now, sorry.

Thanks for explaining it to me!
Post Reply