Building the required toolchains for Sega Dreamcast development: Difference between revisions

From dreamcast.wiki
Jump to navigation Jump to search
(Created page with "== DRAFT == In order to develop for the Sega Dreamcast console, you will need 3 different toolchains: * A sh-elf toolchain, which is the main toolchain. It targets the CPU of...")
 
(Reformatting page)
Line 1: Line 1:
== DRAFT ==
In order to produces binaries targetting the Sega Dreamcast hardware, you will need 3 different toolchains:
In order to develop for the Sega Dreamcast console, you will need 3 different toolchains:
* A ''sh-elf'' toolchain, which will be the main toolchain. It targets the CPU of the Dreamcast, i.e. the Hitachi SH-4 CPU (SuperH).
* A sh-elf toolchain, which is the main toolchain. It targets the CPU of the Dreamcast, i.e. the Hitachi SH-4 CPU (SuperH).
* An ''arm-eabi'' toolchain, which is the toolchain used only for the Yamaha Super Intelligent Sound Processor (AICA). This processor is based on an ARM7 core. It will mainly be used to compile the [[KallistiOS]] sound driver.
* An arm-eabi toolchain, which is the toolchain used only for the Yamaha Super Intelligent Sound Processor (AICA). This processor is based on an ARM7 core.
* The host toolchain from your computer in order to produce some additional tools (i.e. the regular ''gcc'' of your computer).
* The host toolchain from your computer in order to produce some additional tools (i.e. the regular gcc of your computer).


The sh-elf and arm-eabi toolchains may be produced by the dc-chain tool provided with KallistiOS.
The ''sh-elf'' and ''arm-eabi'' toolchains may be produced by the ''dc-chain'' tool provided with KallistiOS. It's located in the ''utils'' directory. This package contains a ''Makefile'' which both simplifies building the whole Sega Dreamcast toolchain, and gives you substantial control. The dc-chain ''Makefile'' is ready to build everything you need to compile KallistiOS and then develop for the Sega Dreamcast system.


This package contains a Makefile which both simplifies building the whole
== About toolchain components versions ==
Sega Dreamcast toolchain, and gives you substantial control.
Components that are included in a toolchain are:
The toolchain is composed by:


* '''Binutils''': mainly ld plus other tools;
* '''GNU Compiler Collection''' (''gcc'');
* '''Newlib''': mainly libc plus other libraries (for ''sh-elf'' only);
* '''GNU Debugger''' (''gdb''): (for ''sh-elf'' only).


As we are building two toolchains (sh-elf and arm-eabi), all these components will be installed twice, for both targets.


The dc-chain Makefile is ready to build everything you need to compile
Speaking about the best versions to use for the Sega Dreamcast development, they are already declared in the Makefile. This is particulary true for gcc: the best version to use at this time is the 4.7.3. We know that today this version is pretty old but greater versions have serious issues so it's better to stick with that version.
KallistiOS and then develop for the Sega Dreamcast system.


About toolchain components versions
Plus, gcc's bugtracker has a lot of bugs marked as [6/7/8/9 Regression] for the sh-elf target which have not been resolved. Newer isn't always better, especially with gcc targets that aren't high-priority.
Components that are included in a toolchain are:
* Binutils (mainly ld plus other tools)
* GNU Compiler Collection (gcc)
* Newlib (mainly libc plus other libraries)
* GNU Debugger (gdb) - Optional


As we are building two toolchains (sh-elf and arm-eabi), all these
== Advanced options ==
components will be installed twice, for both targets.
You may attempt to spawn multiple jobs with make. Using make -j4 is recommended for speeding up the building of the toolchain. There is an option inside the Makefile to set the number of jobs for the building phases.
Speaking about the best versions to use for the Sega Dreamcast development,
they are already declared in the Makefile. This is particulary true for gcc:
the best version to use at this time is the 4.7.3. We know that today this
version is pretty old but greater versions have serious
issues so it's better
to stick with that version.
Plus, gcc's bugtracker has a lot of bugs marked as [6/7/8/9 Regression] for
the sh-elf target which have not been resolved. Newer isn't always better,
especially with gcc targets that aren't high-priority.


Advanced options
Set the makejobs variable in the Makefile to whatever you would normally feel the need to use on the command line, and it will do the right thing. In the old times, this option may breaks things, so, if you run into trouble, you should clear this variable and try again with just one job running.
You may attempt to spawn multiple jobs with make. Using make -j4 is
recommended for speeding up the building of the toolchain. There is an option
inside the Makefile to set the number of jobs for the building phases.
Set the makejobs variable in the Makefile to whatever you would normally
feel the need to use on the command line, and it will do the right thing.
In the old times, this option may breaks things, so, if you run into
trouble, you should clear this variable and try again with just one
job running.
On MinGW/MSYS environment, it has been confirmed that multiple jobs breaks
the toolchain, so please don't try to do that under this environment. This
option is disabled by default in this scenario. This doesn't apply to the
others environments, including MinGW-w64/MSYS2.


Usage
On MinGW/MSYS environment, it has been confirmed that multiple jobs breaks the toolchain, so please don't try to do that under this environment. This option is disabled by default in this scenario. This doesn't apply to the others environments, including MinGW-w64/MSYS2.
Before you start, please browse the ./doc directory and check if they are
full instructions for building the whole toolchain for your environment.


Making the toolchain
== Usage ==
Below you will find some generic instructions:
Before you start, please browse the ./doc directory and check if they are full instructions for building the whole toolchain for your environment.


=== Making the toolchain ===


Change the variables in the User Configuration section of the Makefile
Below you will find some generic instructions:
to match your environment. They can be overridden at the command line as
well. Please note, a lot of conditional instructions have been added, so it
should work most of the time just out-of-the-box for your environment.


Change the variables in the User Configuration section of the Makefile to match your environment. They can be overridden at the command line as well. Please note, a lot of conditional instructions have been added, so it should work most of the time just out-of-the-box for your environment.


Then execute the following for preparing the sources:
Then execute the following for preparing the sources:
  ./download.sh
  ./download.sh
  ./unpack.sh
  ./unpack.sh


Finally, input (for BSD, please use gmake instead):
Finally, input (for BSD, please use gmake instead):
  make
  make


Depending of your environment, this can take a bunch of hours. So please be patient!


Depending of your environment, this can take a bunch of hours. So please be
patient!
If anything goes wrong, check the output in logs/.
If anything goes wrong, check the output in logs/.


Making the GNU Debugger (gdb)
=== Making the GNU Debugger (gdb) ===
For the sh-elf toolchain, if you want to use the GNU Debugger (gdb),
For the sh-elf toolchain, if you want to use the GNU Debugger (gdb), you can make it by entering:
you can make it by entering:
make gdb
make gdb
This will install gdb in the sh-elf toolchain (gdb is used with
This will install gdb in the sh-elf toolchain (gdb is used with dcload/dc-tool programs, which are part of KallistiOS too).
dcload/dc-tool programs, which are part of KallistiOS too).
 
== Removing all useless files ==


Removing all useless files
After the toolchain compilation, you can cleanup everything by entering:
After the toolchain compilation, you can cleanup everything by entering:
./cleanup.sh
./cleanup.sh
This will save a lot of space.
This will save a lot of space.


Final note
== Final note ==
 
Please see the comments at the top of the Makefile for more build options.
Please see the comments at the top of the Makefile for more build options.

Revision as of 17:30, 7 March 2020

In order to produces binaries targetting the Sega Dreamcast hardware, you will need 3 different toolchains:

  • A sh-elf toolchain, which will be the main toolchain. It targets the CPU of the Dreamcast, i.e. the Hitachi SH-4 CPU (SuperH).
  • An arm-eabi toolchain, which is the toolchain used only for the Yamaha Super Intelligent Sound Processor (AICA). This processor is based on an ARM7 core. It will mainly be used to compile the KallistiOS sound driver.
  • The host toolchain from your computer in order to produce some additional tools (i.e. the regular gcc of your computer).

The sh-elf and arm-eabi toolchains may be produced by the dc-chain tool provided with KallistiOS. It's located in the utils directory. This package contains a Makefile which both simplifies building the whole Sega Dreamcast toolchain, and gives you substantial control. The dc-chain Makefile is ready to build everything you need to compile KallistiOS and then develop for the Sega Dreamcast system.

About toolchain components versions

Components that are included in a toolchain are:

  • Binutils: mainly ld plus other tools;
  • GNU Compiler Collection (gcc);
  • Newlib: mainly libc plus other libraries (for sh-elf only);
  • GNU Debugger (gdb): (for sh-elf only).

As we are building two toolchains (sh-elf and arm-eabi), all these components will be installed twice, for both targets.

Speaking about the best versions to use for the Sega Dreamcast development, they are already declared in the Makefile. This is particulary true for gcc: the best version to use at this time is the 4.7.3. We know that today this version is pretty old but greater versions have serious issues so it's better to stick with that version.

Plus, gcc's bugtracker has a lot of bugs marked as [6/7/8/9 Regression] for the sh-elf target which have not been resolved. Newer isn't always better, especially with gcc targets that aren't high-priority.

Advanced options

You may attempt to spawn multiple jobs with make. Using make -j4 is recommended for speeding up the building of the toolchain. There is an option inside the Makefile to set the number of jobs for the building phases.

Set the makejobs variable in the Makefile to whatever you would normally feel the need to use on the command line, and it will do the right thing. In the old times, this option may breaks things, so, if you run into trouble, you should clear this variable and try again with just one job running.

On MinGW/MSYS environment, it has been confirmed that multiple jobs breaks the toolchain, so please don't try to do that under this environment. This option is disabled by default in this scenario. This doesn't apply to the others environments, including MinGW-w64/MSYS2.

Usage

Before you start, please browse the ./doc directory and check if they are full instructions for building the whole toolchain for your environment.

Making the toolchain

Below you will find some generic instructions:

Change the variables in the User Configuration section of the Makefile to match your environment. They can be overridden at the command line as well. Please note, a lot of conditional instructions have been added, so it should work most of the time just out-of-the-box for your environment.

Then execute the following for preparing the sources:

./download.sh
./unpack.sh

Finally, input (for BSD, please use gmake instead):

make

Depending of your environment, this can take a bunch of hours. So please be patient!

If anything goes wrong, check the output in logs/.

Making the GNU Debugger (gdb)

For the sh-elf toolchain, if you want to use the GNU Debugger (gdb), you can make it by entering: make gdb This will install gdb in the sh-elf toolchain (gdb is used with dcload/dc-tool programs, which are part of KallistiOS too).

Removing all useless files

After the toolchain compilation, you can cleanup everything by entering:

./cleanup.sh

This will save a lot of space.

Final note

Please see the comments at the top of the Makefile for more build options.