OS Specific Toolchain: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
Added binutils commands
Added gcc commands
Line 67:
${GENSCRIPTS} myos_i386 "$(tdir_myos_i386)"
Note that some parts of the line use normal brackets () whereas other parts use curly braces {}. Also, the second line is indented with a tab, not spaces.
You can also add 'emyos_i386.o' to the dependencies of 'ALL_EMULATIONS' if you like, but it is not essential.
 
 
== GCC ==
=== config.sub ===
Similar modification to config.sub in binutils.
 
=== gcc/config.gcc ===
This file defines what needs to be built for each particular target and what to include in the final executable. There are two main sections: one which defines generic options for your operating system, and those which define options specific to your operating system on each individual machine type. For the first part, find the section starting 'Common parts for widely ported systems ... case ${target} in' and add something like:
*-*-myos*)
extra_parts="crtbegin.o crtend.o"
gas=yes
gnu_ld=yes
default_use_cxa_atexit=yes
;;
This basically says: build the static versions of crtbegin and crtend (important for various parts of libgcc), our operating system by default uses the GNU linker and assembler and that we will provide __cxa_atexit (newlib will actually provide it).
The section section we need to add to is the architecture-specific one. Find the section starting 'case ${target} in ... Support site-specific machine types' and add
i[3-7]86-*-myos*)
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h i386/i386elf.h myos.h"
tmake_file="i386/t-i386elf t-svr4"
use_fixproto=yes
;;
Which defines some extra include files and makefile fragments to use. We will create the myos.h next.
 
=== gcc/config/myos.h ===
Now we create a header file which sets some os-specific stuff in gcc. This currently just sets some variables which state that the c preprocessor should #define some macros, make some asserts and set the default system name when we are compiling an application for our os. Something like the following should be fine.
#undef TARGET_OS_CPP_BUILTINS
#define TARGET_OS_CPP_BUILTINS() \
do { \
builtin_define_std ("myos"); \
builtin_define_std ("unix"); \
builtin_assert ("system=myos"); \
builtin_assert ("system=unix"); \
} while(0);
 
#undef TARGET_VERSION
#define TARGET_VERSION fprintf(stderr, " (i386 myos)");
 
=== libstdc++-v3/crossconfig.m4 ===
Only necessary if you are compiling the GNU C++ compiler AND you wish to cross-compile the standard C++ library for your os. You can experiment with adding more options (ala the Linux case) if you wish. Add a case similar to
*-myos*)
AC_CHECK_HEADERS([sys/types.h locale.h float.h])
GLIBCXX_CHECK_BUILTIN_MATH_SUPPORT
GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT
GLIBCXX_CHECK_STDLIB_SUPPORT
;;