Page 1 of 1

Help Building Binutils

Posted: Thu Nov 26, 2020 10:37 am
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 :-| )

Re: Help Building Binutils

Posted: Thu Nov 26, 2020 10:53 am
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.

Re: Help Building Binutils

Posted: Thu Nov 26, 2020 11:06 am
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>

Re: Help Building Binutils

Posted: Thu Nov 26, 2020 11:49 am
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...

Re: Help Building Binutils

Posted: Thu Nov 26, 2020 1:16 pm
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.

Re: Help Building Binutils

Posted: Thu Nov 26, 2020 2:28 pm
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

Re: Help Building Binutils

Posted: Fri Nov 27, 2020 7:54 am
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.

Re: Help Building Binutils

Posted: Fri Nov 27, 2020 8:27 am
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!