Getting started with programming again/

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5387
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 1 time
Been liked: 12 times
Contact:

Re: Getting started with programming again/

Post by BlueCrab » Tue Jun 15, 2010 8:27 pm

So... I committed patches to support GCC 4.4.0 and 4.4.4, as well as Newlib 1.18.0 to the KOS repo. Lemme know if you have any troubles building with them.

Also, just as reference, here's the flags I used to configure for building the final step of GCC 4.4.4

../gcc-4.4.4/configure --target=sh-elf --prefix=/usr/local/dc/sh-elf --with-newlib --enable-languages=c,c++,objc,obj-c++ --disable-libssp --disable-tls --disable-nls --with-multilib-list=m4-single-only,m4-nofpu,m4 --with-endian=little --with-cpu=m4-single-only --enable-threads=kos

It should be pretty easy to derive what to build the first step with from that (basically, take out the languages other than c, the --enable-threads stuff and add a --without-headers).
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has liked: 0
Been liked: 2 times

Re: Getting started with programming again/

Post by Chilly Willy » Tue Jun 15, 2010 11:16 pm

The toolchain went okay, but compiling kos with it yields

Code: Select all

make[3]: Leaving directory `/home/jlfenton/Projects/Dreamcast/cadcdev/kos/kernel/libc/koslib'
make -C  newlib
make[3]: Entering directory `/home/jlfenton/Projects/Dreamcast/cadcdev/kos/kernel/libc/newlib'
kos-cc  -c lock_common.c -o lock_common.o
In file included from /home/jlfenton/Projects/Dreamcast/cadcdev/kos/include/sys/_types.h:4,
                 from /home/jlfenton/Tools/dc/sh-elf/lib/gcc/sh-elf/4.4.4/../../../../sh-elf/include/sys/reent.h:14,
                 from /home/jlfenton/Projects/Dreamcast/cadcdev/kos/include/kos/thread.h:20,
                 from /home/jlfenton/Projects/Dreamcast/cadcdev/kos/kernel/arch/dreamcast/include/arch/spinlock.h:17,
                 from lock_common.c:11:
/home/jlfenton/Tools/dc/sh-elf/lib/gcc/sh-elf/4.4.4/../../../../sh-elf/include/sys/lock.h:15: error: conflicting types for '__newlib_recursive_lock_t'
lock_common.h:15: note: previous declaration of '__newlib_recursive_lock_t' was here
/home/jlfenton/Tools/dc/sh-elf/lib/gcc/sh-elf/4.4.4/../../../../sh-elf/include/sys/lock.h:44: error: conflicting types for '__newlib_lock_init_recursive'
lock_common.h:28: note: previous declaration of '__newlib_lock_init_recursive' was here
/home/jlfenton/Tools/dc/sh-elf/lib/gcc/sh-elf/4.4.4/../../../../sh-elf/include/sys/lock.h:45: error: conflicting types for '__newlib_lock_close_recursive'
lock_common.h:29: note: previous declaration of '__newlib_lock_close_recursive' was here
/home/jlfenton/Tools/dc/sh-elf/lib/gcc/sh-elf/4.4.4/../../../../sh-elf/include/sys/lock.h:46: error: conflicting types for '__newlib_lock_acquire_recursive'
lock_common.h:30: note: previous declaration of '__newlib_lock_acquire_recursive' was here
/home/jlfenton/Tools/dc/sh-elf/lib/gcc/sh-elf/4.4.4/../../../../sh-elf/include/sys/lock.h:47: error: conflicting types for '__newlib_lock_try_acquire_recursive'
lock_common.h:31: note: previous declaration of '__newlib_lock_try_acquire_recursive' was here
/home/jlfenton/Tools/dc/sh-elf/lib/gcc/sh-elf/4.4.4/../../../../sh-elf/include/sys/lock.h:48: error: conflicting types for '__newlib_lock_release_recursive'
lock_common.h:32: note: previous declaration of '__newlib_lock_release_recursive' was here
lock_common.c:34: error: conflicting types for '__newlib_lock_init_recursive'
lock_common.h:28: note: previous declaration of '__newlib_lock_init_recursive' was here
lock_common.c:40: error: conflicting types for '__newlib_lock_close_recursive'
lock_common.h:29: note: previous declaration of '__newlib_lock_close_recursive' was here
lock_common.c:44: error: conflicting types for '__newlib_lock_acquire_recursive'
lock_common.h:30: note: previous declaration of '__newlib_lock_acquire_recursive' was here
lock_common.c:67: error: conflicting types for '__newlib_lock_try_acquire_recursive'
lock_common.h:31: note: previous declaration of '__newlib_lock_try_acquire_recursive' was here
lock_common.c:71: error: conflicting types for '__newlib_lock_release_recursive'
lock_common.h:32: note: previous declaration of '__newlib_lock_release_recursive' was here
make[3]: *** [lock_common.o] Error 1
make[3]: Leaving directory `/home/jlfenton/Projects/Dreamcast/cadcdev/kos/kernel/libc/newlib'
make[2]: *** [_dir_newlib] Error 2
make[2]: Leaving directory `/home/jlfenton/Projects/Dreamcast/cadcdev/kos/kernel/libc'
make[1]: *** [_dir_libc] Error 2
make[1]: Leaving directory `/home/jlfenton/Projects/Dreamcast/cadcdev/kos/kernel'
exit: 1: Illegal number: -1
make: *** [all] Error 2
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has liked: 0
Been liked: 2 times

Re: Getting started with programming again/

Post by Chilly Willy » Wed Jun 16, 2010 12:16 am

Oh, one thing I noticed while looking over the kos code - there's still no way to set the bios font color when printing. If you remember, I did a patch for that back when I did Doom (not applied at the moment - I'm trying a clean checkout of kos).

Here is that diff again if you wanted to look it over. At the time, you said you were considering a different way to do the font color. Maybe this will jog your memory. :grin:

Code: Select all

--- hardware/biosfont.c	2009-07-31 15:25:09.000000000 -0600
+++ hardware/biosfont-new.c	2009-07-27 17:11:26.000000000 -0600
@@ -21,11 +21,42 @@
 
 All the Japanese code is by Kazuaki Matsumoto.
 
+Foreground and background colors, and pixel mode support added by Chilly
+Willy.
+
 */
 
 /* Our current conversion mode */
 int bfont_code_mode = BFONT_CODE_ISO8859_1;
 
+/* Current foreground and background colors */
+uint32 bfont_fgcolor = 0xFFFFFF;
+uint32 bfont_bgcolor = 0x000000;
+
+/* Current pixel mode */
+int bfont_pmode = 1; /* video defaults to 565 */
+
+/* Set pixel mode - returns previous pixel mode */
+int bfont_set_pmode(int pmode) {
+	int old_pmode = bfont_pmode;
+	bfont_pmode = pmode;
+	return old_pmode;
+}
+
+/* Set foreground color - returns previous color */
+uint32 bfont_set_fgcolor(uint32 color) {
+	int old_color = bfont_fgcolor;
+	bfont_fgcolor = color;
+	return old_color;
+}
+
+/* Set background color - returns previous color */
+uint32 bfont_set_bgcolor(uint32 color) {
+	int old_color = bfont_bgcolor;
+	bfont_bgcolor = color;
+	return old_color;
+}
+
 /* Select an encoding for Japanese (or disable) */
 void bfont_set_encoding(int enc) {
 	if (enc < BFONT_CODE_ISO8859_1 || enc > BFONT_CODE_SJIS) {
@@ -142,36 +173,74 @@
 	else
 		ch = bfont_find_char(c);
 
-	for (y=0; y<24; ) {
-		/* Do the first row */
-		word = (((uint16)ch[0]) << 4) | ((ch[1] >> 4) & 0x0f);
-		for (x=0; x<12; x++) {
-			if (word & (0x0800 >> x))
-				*buffer = 0xffff;
-			else {
-				if (opaque)
-					*buffer = 0x0000;
+	if (bfont_pmode == 0 || bfont_pmode == 1) {
+		uint16 fc = bfont_pmode == 0 ? MAKE_RGB555(bfont_fgcolor) : MAKE_RGB565(bfont_fgcolor);
+		uint16 bc = bfont_pmode == 0 ? MAKE_RGB555(bfont_bgcolor) : MAKE_RGB565(bfont_bgcolor);
+
+		for (y=0; y<24; ) {
+			/* Do the first row */
+			word = (((uint16)ch[0]) << 4) | ((ch[1] >> 4) & 0x0f);
+			for (x=0; x<12; x++) {
+				if (word & (0x0800 >> x))
+					*buffer = fc;
+				else {
+					if (opaque)
+						*buffer = bc;
+				}
+				buffer++;
 			}
-			buffer++;
-		}
-		buffer += bufwidth - 12;
-		y++;
+			buffer += bufwidth - 12;
+			y++;
 
-		/* Do the second row */
-		word = ( (((uint16)ch[1]) << 8) & 0xf00 ) | ch[2];
-		for (x=0; x<12; x++) {
-			if (word & (0x0800 >> x))
-				*buffer = 0xffff;
-			else {
-				if (opaque)
-					*buffer = 0x0000;
+			/* Do the second row */
+			word = ( (((uint16)ch[1]) << 8) & 0xf00 ) | ch[2];
+			for (x=0; x<12; x++) {
+				if (word & (0x0800 >> x))
+					*buffer = fc;
+				else {
+					if (opaque)
+						*buffer = bc;
+				}
+				buffer++;
 			}
-			buffer++;
+			buffer += bufwidth - 12;
+			y++;
+
+			ch += 3;
 		}
-		buffer += bufwidth - 12;
-		y++;
+	} else {
+		uint32 *lbuffer = (uint32 *)buffer;
+		for (y=0; y<24; ) {
+			/* Do the first row */
+			word = (((uint16)ch[0]) << 4) | ((ch[1] >> 4) & 0x0f);
+			for (x=0; x<12; x++) {
+				if (word & (0x0800 >> x))
+					*lbuffer = bfont_fgcolor;
+				else {
+					if (opaque)
+						*lbuffer = bfont_bgcolor;
+				}
+				lbuffer++;
+			}
+			lbuffer += bufwidth - 12;
+			y++;
+
+			/* Do the second row */
+			word = ( (((uint16)ch[1]) << 8) & 0xf00 ) | ch[2];
+			for (x=0; x<12; x++) {
+				if (word & (0x0800 >> x))
+					*lbuffer = bfont_fgcolor;
+				else {
+					if (opaque)
+						*lbuffer = bfont_bgcolor;
+				}
+				lbuffer++;
+			}
+			lbuffer += bufwidth - 12;
+			y++;
 
-		ch += 3;
+			ch += 3;
+		}
 	}
 }
 
@@ -186,33 +255,68 @@
 	uint16	word;
 	int	x, y;
 
-	for (y=0; y<24; ) {
-		/* Do the first row */
-		word = (((uint16)ch[0]) << 4) | ((ch[1] >> 4) & 0x0f);
-		for (x=0; x<12; x++) {
-			if (word & (0x0800 >> x))
-				*buffer = 0xffff;
-			else {
-				if (opaque)
-					*buffer = 0x0000;
+	if (bfont_pmode == 0 || bfont_pmode == 1) {
+		uint16 fc = bfont_pmode == 0 ? MAKE_RGB555(bfont_fgcolor) : MAKE_RGB565(bfont_fgcolor);
+		uint16 bc = bfont_pmode == 0 ? MAKE_RGB555(bfont_bgcolor) : MAKE_RGB565(bfont_bgcolor);
+
+		for (y=0; y<24; ) {
+			/* Do the first row */
+			word = (((uint16)ch[0]) << 4) | ((ch[1] >> 4) & 0x0f);
+			for (x=0; x<12; x++) {
+				if (word & (0x0800 >> x))
+					*buffer = fc;
+				else {
+					if (opaque)
+						*buffer = bc;
+				}
+				buffer++;
 			}
-			buffer++;
-		}
 
-		word = ( (((uint16)ch[1]) << 8) & 0xf00 ) | ch[2];
-		for (x=0; x<12; x++) {
-			if (word & (0x0800 >> x))
-				*buffer = 0xffff;
-			else {
-				if (opaque)
-				*buffer = 0x0000;
+			word = ( (((uint16)ch[1]) << 8) & 0xf00 ) | ch[2];
+			for (x=0; x<12; x++) {
+				if (word & (0x0800 >> x))
+					*buffer = fc;
+				else {
+					if (opaque)
+						*buffer = bc;
+				}
+				buffer++;
 			}
-			buffer++;
+			buffer += bufwidth - 24;
+			y++;
+
+			ch += 3;
 		}
-		buffer += bufwidth - 24;
-		y++;
+	} else {
+		uint32 *lbuffer = (uint32 *)buffer;
+		for (y=0; y<24; ) {
+			/* Do the first row */
+			word = (((uint16)ch[0]) << 4) | ((ch[1] >> 4) & 0x0f);
+			for (x=0; x<12; x++) {
+				if (word & (0x0800 >> x))
+					*lbuffer = bfont_fgcolor;
+				else {
+					if (opaque)
+						*lbuffer = bfont_bgcolor;
+				}
+				lbuffer++;
+			}
+
+			word = ( (((uint16)ch[1]) << 8) & 0xf00 ) | ch[2];
+			for (x=0; x<12; x++) {
+				if (word & (0x0800 >> x))
+					*lbuffer = bfont_fgcolor;
+				else {
+					if (opaque)
+						*lbuffer = bfont_bgcolor;
+				}
+				lbuffer++;
+			}
+			lbuffer += bufwidth - 24;
+			y++;
 
-		ch += 3;
+			ch += 3;
+		}
 	}
 }
 
@@ -245,21 +349,20 @@
 			default:
 				assert_msg( 0, "Unknown bfont encoding mode" );
 			}
-			
+
 			if (nFlag == 1) {
 				str++;
 				nChr = (nChr << 8) | (*str & 0xff);
 				bfont_draw_wide(buffer, width, opaque, nChr);
-				buffer += 24;
+				buffer += bfont_pmode == 3 ? 48 : 24;
 			} else {
 				bfont_draw_thin(buffer, width, opaque, nChr, 1);
-				buffer += 12;
+				buffer += bfont_pmode == 3 ? 24 : 12;
 			}
 		} else {
 			bfont_draw_thin(buffer, width, opaque, nChr, 0);
-			buffer += 12;
+			buffer += bfont_pmode == 3 ? 24 : 12;
 		}
 		str++;
 	}
 }
-
--- include/dc/biosfont.h	2009-07-31 15:24:58.000000000 -0600
+++ include/dc/biosfont-new.h	2009-07-24 10:38:13.000000000 -0600
@@ -20,6 +20,19 @@
 #define BFONT_CODE_EUC		1
 #define BFONT_CODE_SJIS		2
 
+/* Defines to convert colors */
+#define MAKE_RGB555(c) (((c & 0xF80000)>>9)|((c & 0x00F800)>>6)|((c & 0x0000F8)>>3))
+#define MAKE_RGB565(c) (((c & 0xF80000)>>8)|((c & 0x00FC00)>>5)|((c & 0x0000F8)>>3))
+
+/* Set pixel mode - returns previous pixel mode */
+int bfont_set_pmode(int pmode);
+
+/* Set foreground color - returns previous color */
+uint32 bfont_set_fgcolor(uint32 color);
+
+/* Set background color - returns previous color */
+uint32 bfont_set_bgcolor(uint32 color);
+
 /* Select an encoding for Japanese (or disable) */
 void bfont_set_encoding(int enc);
 
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5387
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 1 time
Been liked: 12 times
Contact:

Re: Getting started with programming again/

Post by BlueCrab » Wed Jun 16, 2010 7:58 am

I had honestly forgotten all about the font stuff... Sorry about that. As for the error in compiling, update your KOS tree. It should have been fixed in r664.
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has liked: 0
Been liked: 2 times

Re: Getting started with programming again/

Post by Chilly Willy » Wed Jun 16, 2010 1:49 pm

No problem - I forgot, too. :lol:

Updated to r665! It went through this time. Now compiling kos-ports... and that went fine. Looks like I'm back in business. 8-)

Thanks for the help!
patbier
DC Developer
DC Developer
Posts: 152
Joined: Fri Aug 29, 2003 1:25 am
Has liked: 0
Been liked: 0

Re: Getting started with programming again/

Post by patbier » Wed Jun 16, 2010 4:17 pm

I'll really appreciate if you update the Makefile of the toolchain.
Indeed, i try to rebuild a toolchain with the last SVN version, and I have errors with cygwin.
I try to use the gcc version 4.3.4 and the gcc 3.4.4 and I have the error :

Code: Select all

make[5]: Entering directory `/home/Julien/cacdev2010/kos/utils/dc-chain/build-binutils-sh-elf-2.17/gas/po'
make[5]: Nothing to be done for `all'.
make[5]: Leaving directory `/home/Julien/cacdev2010/kos/utils/dc-chain/build-binutils-sh-elf-2.17/gas/po'
make[5]: Entering directory `/home/Julien/cacdev2010/kos/utils/dc-chain/build-binutils-sh-elf-2.17/gas'
gcc -DHAVE_CONFIG_H -I. -I../../binutils-2.17/gas -I. -D_GNU_SOURCE -I. -I../../binutils-2.17/gas -I../bfd -I../../binutils-2.17/gas/config -I../../binutils-2.17/gas/../include -I../../binutils-2.17/gas/.. -I../../binutils-2.17/gas/../bfd -I../../binutils-2.17/gas/../intl -I../intl -DLOCALEDIR="\"/usr/local/dc2010/sh-elf/share/locale\""   -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror -g -O2  -c ../../binutils-2.17/gas/app.c
cc1: warnings being treated as errors
../../binutils-2.17/gas/app.c: In function ‘do_scrub_chars’:
../../binutils-2.17/gas/app.c:566: error: array subscript is below array bounds
make[5]: *** [app.o] Error 1
make[5]: Leaving directory `/home/Julien/cacdev2010/kos/utils/dc-chain/build-binutils-sh-elf-2.17/gas'
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory `/home/Julien/cacdev2010/kos/utils/dc-chain/build-binutils-sh-elf-2.17/gas'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/home/Julien/cacdev2010/kos/utils/dc-chain/build-binutils-sh-elf-2.17/gas'
make[2]: *** [all-gas] Error 2
make[2]: Leaving directory `/home/Julien/cacdev2010/kos/utils/dc-chain/build-binutils-sh-elf-2.17'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/Julien/cacdev2010/kos/utils/dc-chain/build-binutils-sh-elf-2.17'
Thanks for your updates !
ImageAlice Dreams Tournament Dreamcast fans : http://www.facebook.com/alicedreamst
In August 2015, we had to change "Dynamite Dreams" name to "Alice Dreams Tournament"
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has liked: 0
Been liked: 2 times

Re: Getting started with programming again/

Post by Chilly Willy » Wed Jun 16, 2010 4:44 pm

Why are you trying to build binutils 2.17? You should be building 2.20.1.

Here's my updated makefile for building everything... not sure how it will work in cygwin. You have to at least change the paths from my paths to your own. Note the versions...

Code: Select all

binutils_ver=2.20.1
gcc_ver=4.4.4
newlib_ver=1.18.0
gdb_ver=7.0.1
insight_ver=6.8-1
Whole thing:

Code: Select all

# Dreamcast toolchain makefile    by Jim Ursetto
# adapted from Stalin's build script version 0.3
#
# Interesting parameters:
# erase=0|1                   Erase build directories on the fly to save space
# thread_model=posix|single   Set gcc threading model
# verbose=0|1                 Display
#
# Interesting targets (you can 'make' any of these):
# all: patch build
# patch: patch-gcc patch-newlib patch-kos
# build: build-sh4 build-arm
# build-sh4: build-sh4-binutils build-sh4-gcc
# build-arm: build-arm-binutils build-arm-gcc
# build-sh4-gcc: build-sh4-gcc-pass1 build-sh4-newlib build-sh4-gcc-pass2
# build-arm-gcc: build-arm-gcc-pass1
# build-sh4-newlib: build-sh4-newlib-only fixup-sh4-newlib
# gdb
# insight

# User configuration
sh_target=sh-elf
arm_target=arm-elf
sh_prefix  := /home/jlfenton/Tools/dc/$(sh_target)
arm_prefix := /home/jlfenton/Tools/dc/$(arm_target)
# kos_root: KOS subversion root (contains kos/ and kos-ports/)
kos_root=$(CURDIR)/../../..
# kos_base: equivalent of KOS_BASE (contains include/ and kernel/)
kos_base=$(kos_root)/kos
binutils_ver=2.20.1
gcc_ver=4.4.4
newlib_ver=1.18.0
gdb_ver=7.0.1
insight_ver=6.8-1
#thread_model=posix
erase=0
verbose=0

# Makefile variables
install=$(prefix)/bin
pwd := $(shell pwd)
patches := $(pwd)/patches
logdir := $(pwd)/logs
PATH := $(sh_prefix)/bin:$(arm_prefix)/bin:$(PATH)
binutils_dir=binutils-$(binutils_ver)
gcc_dir=gcc-$(gcc_ver)
newlib_dir=newlib-$(newlib_ver)

all: patch build

# ---- patch {{{
binutils_patches    := $(wildcard $(patches)/binutils-$(binutils_ver)*.diff)
gcc_patches    := $(wildcard $(patches)/gcc-$(gcc_ver)*.diff)
newlib_patches := $(wildcard $(patches)/newlib-$(newlib_ver)*.diff)
kos_patches    := $(wildcard $(patches)/kos-*.diff)

patch_targets=patch-binutils patch-gcc patch-newlib patch-kos

patch: $(patch_targets)
patch-binutils: $(binutils_patches)
patch-gcc: $(gcc_patches)
patch-newlib: $(newlib_patches)
patch-kos: $(kos_patches)

$(newlib_patches):
	cd $(newlib_dir); patch -p1 < $@

$(binutils_patches):
	cd $(binutils_dir); patch -p1 < $@

$(gcc_patches):
	cd $(gcc_dir); patch -p1 < $@

$(kos_patches):
	cd $(kos_root); patch -p1 < $@

# ---- }}}

# ---- build {{{

build: build-sh4 build-arm
build-sh4: build-sh4-binutils build-sh4-gcc
build-arm: build-arm-binutils build-arm-gcc build-arm-libgcc
build-sh4-gcc: build-sh4-gcc-pass1 build-sh4-newlib build-sh4-gcc-pass2
build-arm-gcc: build-arm-gcc-pass1
	$(clean_arm_hack)
build-sh4-newlib: build-sh4-newlib-only fixup-sh4-newlib

# Ensure that, no matter where we enter, prefix and target are set correctly.
build_sh4_targets=build-sh4-binutils build-sh4-gcc build-sh4-gcc-pass1 build-sh4-newlib build-sh4-newlib-only build-sh4-gcc-pass2
build_arm_targets=build-arm-binutils build-arm-gcc build-arm-gcc-pass1 build-arm-libgcc
$(build_sh4_targets): prefix = $(sh_prefix)
$(build_sh4_targets): target = $(sh_target)
$(build_sh4_targets): thread_model = kos
$(build_sh4_targets): extra_configure_args = --disable-libssp --disable-tls --disable-nls --with-multilib-list=m4-single-only,m4-nofpu,m4 --with-endian=little --with-cpu=m4-single-only
$(build_arm_targets): prefix = $(arm_prefix)
$(build_arm_targets): target = $(arm_target)
$(build_arm_targets): thread_model = posix
$(build_arm_targets): extra_configure_args = --with-arch=armv4

# To avoid code repetition, we use the same commands for both
# architectures.  But we can't create a single target called
# build-binutils for both sh4 and arm, because phony targets
# can't be run multiple times.  So we create multiple targets.
build_binutils     = build-sh4-binutils  build-arm-binutils
build_gcc_pass1    = build-sh4-gcc-pass1 build-arm-gcc-pass1
build_newlib       = build-sh4-newlib-only
build_gcc_pass2    = build-sh4-gcc-pass2
build_arm_libgcc   = build-arm-libgcc

# Here we use the essentially same code for multiple targets,
# differing only by the current state of the variables below.
$(build_binutils): build = build-binutils-$(target)-$(binutils_ver)
$(build_binutils): src_dir = binutils-$(binutils_ver)
$(build_binutils): log = $(logdir)/$(build).log
$(build_binutils): logdir
	@echo "+++ Building $(src_dir) to $(build)..."
	-mkdir -p $(build)
	> $(log)
	cd $(build); ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) $(to_log)
	make -C $(build) all install DESTDIR=$(DESTDIR) $(to_log)
	make -C $(build)/bfd install DESTDIR=$(DESTDIR) $(to_log)
	$(clean_up)

$(build_arm_libgcc): build = build-arm-libgcc
$(build_arm_libgcc): src_dir = gcc-$(gcc_ver)
$(build_arm_libgcc): log = $(logdir)/$(build).log
$(build_arm_libgcc): logdir
	@echo "+++ Building $(src_dir) to $(build)..."
	-mkdir -p $(build)
	> $(log)
	cd $(build);  ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) --without-headers \
		--with-newlib --enable-languages=c $(extra_configure_args) $(to_log)
	make -C $(build) all-target-libgcc install-target-libgcc DESTDIR=$(DESTDIR) $(to_log)

$(build_gcc_pass1) $(build_gcc_pass2): build = build-gcc-$(target)-$(gcc_ver)
$(build_gcc_pass1) $(build_gcc_pass2): src_dir = gcc-$(gcc_ver)
$(build_gcc_pass1): log = $(logdir)/$(build)-pass1.log
$(build_gcc_pass1): logdir
	@echo "+++ Building $(src_dir) to $(build) (pass 1)..."
	-mkdir -p $(build)
	> $(log)
	cd $(build);  ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) --without-headers \
		--with-newlib --enable-languages=c $(extra_configure_args) $(to_log)
	make -C $(build) all-gcc install-gcc DESTDIR=$(DESTDIR) $(to_log)

$(build_newlib): build = build-newlib-$(target)-$(newlib_ver)
$(build_newlib): src_dir = newlib-$(newlib_ver)
$(build_newlib): log = $(logdir)/$(build).log
$(build_newlib): logdir
	@echo "+++ Building $(src_dir) to $(build)..."
	-mkdir -p $(build)
	> $(log)
	cd $(build); ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) $(to_log)
	make -C $(build) all install CC_FOR_TARGET=$(install)/$(target)-gcc AS_FOR_TARGET=$(install)/$(target)-as \
		LD_FOR_TARGET=$(install)/$(target)-ld AR_FOR_TARGET=$(install)/$(target)-ar \
		RANLIB_FOR_TARGET=$(install)/$(target)-ranlib DESTDIR=$(DESTDIR) $(to_log)
	$(clean_up)

fixup-sh4-newlib: newlib_inc=$(DESTDIR)$(sh_prefix)/$(sh_target)/include
fixup-sh4-newlib:
	@echo "+++ Fixing up sh4 newlib includes..."
# KOS pthread.h is modified
# to define _POSIX_THREADS
# pthreads to kthreads mapping
# so KOS includes are available as kos/file.h
# kos/thread.h requires arch/arch.h
# arch/arch.h requires dc/video.h
	cp $(kos_base)/include/pthread.h $(newlib_inc)
	cp $(kos_base)/include/sys/_pthread.h $(newlib_inc)/sys
	cp $(kos_base)/include/sys/sched.h $(newlib_inc)/sys
	ln -nsf $(kos_base)/include/kos $(newlib_inc)
	ln -nsf $(kos_base)/kernel/arch/dreamcast/include/arch $(newlib_inc)
	ln -nsf $(kos_base)/kernel/arch/dreamcast/include/dc   $(newlib_inc)

$(build_gcc_pass2): log = $(logdir)/$(build)-pass2.log
$(build_gcc_pass2): logdir
	@echo "+++ Building $(src_dir) to $(build) (pass 2)..."
	-mkdir -p $(build)
	> $(log)
	cd $(build);  ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) --with-newlib \
		--enable-threads=$(thread_model) --enable-languages=c,c++,objc,obj-c++ $(extra_configure_args) $(to_log)
	make -C $(build) all install DESTDIR=$(DESTDIR) $(to_log)
	$(clean_up)

# ---- }}}}

# GDB building

gdb-$(gdb_ver).tar.bz2:
	@echo "+++ Downloading GDB..."
	wget -c ftp://ftp.gnu.org/gnu/gdb/gdb-$(gdb_ver).tar.bz2

unpack_gdb: gdb-$(gdb_ver).tar.bz2 unpack_gdb_stamp

unpack_gdb_stamp:
	@echo "+++ Unpacking GDB..."
	rm -f $@
	rm -rf gdb-$(gdb_ver)
	tar jxf gdb-$(gdb_ver).tar.bz2
	touch $@

build_gdb: log = $(logdir)/gdb-$(gdb_ver).log
build_gdb: logdir
build_gdb: unpack_gdb build_gdb_stamp

build_gdb_stamp:
	@echo "+++ Building GDB..."
	rm -f $@
	> $(log)
	rm -rf build-gdb-$(gdb_ver)
	mkdir build-gdb-$(gdb_ver)
	cd build-gdb-$(gdb_ver); ../gdb-$(gdb_ver)/configure \
		--prefix=$(sh_prefix) \
		--target=$(sh_target) $(to_log)
	make -C build-gdb-$(gdb_ver) $(to_log)
	touch $@

install_gdb: log = $(logdir)/gdb-$(gdb_ver).log
install_gdb: logdir
install_gdb: build_gdb install_gdb_stamp

install_gdb_stamp:
	@echo "+++ Installing GDB..."
	rm -f $@
	make -C build-gdb-$(gdb_ver) install DESTDIR=$(DESTDIR) $(to_log)
	touch $@

gdb: install_gdb


# INSIGHT building

insight-$(insight_ver).tar.bz2:
	@echo "+++ Downloading INSIGHT..."
	wget -c ftp://sourceware.org/pub/insight/releases/insight-$(insight_ver).tar.bz2

unpack_insight: insight-$(insight_ver).tar.bz2 unpack_insight_stamp

unpack_insight_stamp:
	@echo "+++ Unpacking INSIGHT..."
	rm -f $@
	rm -rf insight-$(insight_ver)
	tar jxf insight-$(insight_ver).tar.bz2
	touch $@

build_insight: log = $(logdir)/insight-$(insight_ver).log
build_insight: logdir
build_insight: unpack_insight build_insight_stamp

build_insight_stamp:
	@echo "+++ Building INSIGHT..."
	rm -f $@
	> $(log)
	rm -rf build-insight-$(insight_ver)
	mkdir build-insight-$(insight_ver)
	cd build-insight-$(insight_ver); ../insight-$(insight_ver)/configure \
		--prefix=$(sh_prefix) \
		--target=$(sh_target) $(to_log)
	make -C build-insight-$(insight_ver) $(to_log)
	touch $@

install_insight: log = $(logdir)/insight-$(insight_ver).log
install_insight: logdir
install_insight: build_insight install_insight_stamp

install_insight_stamp:
	@echo "+++ Installing INSIGHT..."
	rm -f $@
	make -C build-insight-$(insight_ver) install DESTDIR=$(DESTDIR) $(to_log)
	touch $@

insight: install_insight


# ---- support {{{

clean:
	-rm -rf build-newlib-$(sh_target)-$(newlib_ver)
	-rm -rf build-newlib-$(arm_target)-$(newlib_ver)
	-rm -rf build-gcc-$(sh_target)-$(gcc_ver)
	-rm -rf build-gcc-$(arm_target)-$(gcc_ver)
	-rm -rf build-binutils-$(sh_target)-$(binutils_ver)
	-rm -rf build-binutils-$(arm_target)-$(binutils_ver)
	-rm -rf build-gdb-$(gdb_ver) install_gdb_stamp build_gdb_stamp
	-rm -rf build-insight-$(gdb_ver) install_insight_stamp build_insight_stamp

logdir:
	@mkdir -p $(logdir)

# If erase=1, erase build directories on the fly.
ifeq (1,$(erase))
  define clean_up
	@echo "+++ Cleaning up $(build)..."
	-rm -rf $(build)
  endef
  # Hack to clean up ARM gcc pass 1
  define clean_arm_hack
	@echo "+++ Cleaning up build-gcc-$(arm_target)-$(gcc_ver)..."
	-rm -rf build-gcc-$(arm_target)-$(gcc_ver)
  endef
endif

# If verbose=1, display output to screen as well as log files
ifeq (1,$(verbose))
  to_log = 2>&1 | tee -a $(log)
else
  to_log = >> $(log) 2>&1
endif

# ---- }}}

# ---- phony targets {{{

.PHONY: $(patch_targets)
.PHONY: $(newlib_patches) $(binutils_patches) $(gcc_patches) $(kos_patches)
.PHONY: all build patch build-sh4 build-arm $(build_sh4_targets) $(build_arm_targets) clean
.PHONY: build-binutils build-newlib build-gcc-pass1 build-gcc-pass2 fixup-sh4-newlib
.PHONY: gdb install_gdb build_gdb unpack_gdb
.PHONY: insight install_insight build_insight unpack_insight

# ---- }}}}

# vim:tw=0:fdm=marker:fdc=2:fdl=1
patbier
DC Developer
DC Developer
Posts: 152
Joined: Fri Aug 29, 2003 1:25 am
Has liked: 0
Been liked: 0

Re: Getting started with programming again/

Post by patbier » Thu Jun 17, 2010 6:12 am

OK thanks, with your makefile, i achieved in compiling the toolchain and kos !

For information, I had to replace the tabulations in the Makefile (this forum has replaced them by spaces). Moreover, i had to install libiconv, gmp, mpfr, libgmp and libmpfr.

Now I have a problem when I try to compile kos/examples/dreamcast :

For example :

Code: Select all

Julien@pc ~/cacdev2010/kos/examples/dreamcast/pvr/modifier_volume
$ make
rm -f modifier.elf
/usr/local/dc2010/sh-elf/bin/sh-elf-gcc -O2 -fomit-frame-pointer -ml -m4-single-
only -fno-crossjumping -I/home/Julien/cacdev2010/kos//../kos-ports/include -I/ho
me/Julien/cacdev2010/kos//include -I/home/Julien/cacdev2010/kos//kernel/arch/dre
amcast/include -I/home/Julien/cacdev2010/kos//addons/include -D_arch_dreamcast -
D_arch_sub_navi -Wall -g -fno-builtin -fno-strict-aliasing  -ml -m4-single-only
-Wl,-Ttext=0x8c010000 -nostartfiles -nostdlib -L/home/Julien/cacdev/kos//lib/dre
amcast -L/home/Julien/cacdev/kos//addons/lib/dreamcast -ml -m4-single-only -Wl,-
Ttext=0x8c010000 -T/home/Julien/cacdev2010/kos//utils/ldscripts/shlelf.xc -nodef
aultlibs -L/home/Julien/cacdev2010/kos//lib/dreamcast -L/home/Julien/cacdev2010/
kos//addons/lib/dreamcast -o modifier.elf  \
                modifier.o  -Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-gro
up
/usr/local/dc2010/sh-elf/lib/gcc/sh-elf/4.4.4/../../../../sh-elf/bin/ld: warning
: cannot find entry symbol start; defaulting to 000000008c010000
modifier.o: In function `setup':
/home/Julien/cacdev2010/kos/examples/dreamcast/pvr/modifier_volume/modifier.c:30
: undefined reference to `_pvr_poly_cxt_col_mod'
/home/Julien/cacdev2010/kos/examples/dreamcast/pvr/modifier_volume/modifier.c:30
: undefined reference to `_pvr_mod_compile'
/home/Julien/cacdev2010/kos/examples/dreamcast/pvr/modifier_volume/modifier.c:30
: undefined reference to `_pvr_poly_mod_compile'
/home/Julien/cacdev/kos//lib/dreamcast/libkallisti.a(init.o): In function `arch_
return':
/home/Ju/cacdev/kos/kernel/arch/dreamcast/kernel/init.c:266: undefined reference
 to `_arch_real_exit'
/home/Julien/cacdev/kos//lib/dreamcast/libkallisti.a(init.o): In function `arch_
abort':
/home/Ju/cacdev/kos/kernel/arch/dreamcast/kernel/init.c:304: undefined reference
 to `_arch_real_exit'
/home/Julien/cacdev/kos//lib/dreamcast/libkallisti.a(exec.o): In function `arch_
exec_at':
/home/Ju/cacdev/kos/kernel/arch/dreamcast/kernel/exec.c:40: undefined reference
to `__arch_old_stack'
/home/Ju/cacdev/kos/kernel/arch/dreamcast/kernel/exec.c:40: undefined reference
to `__arch_old_sr'
/home/Ju/cacdev/kos/kernel/arch/dreamcast/kernel/exec.c:40: undefined reference
to `__arch_old_vbr'
/home/Ju/cacdev/kos/kernel/arch/dreamcast/kernel/exec.c:40: undefined reference
to `__arch_old_fpscr'
/usr/local/dc2010/sh-elf/lib/gcc/sh-elf/4.4.4/../../../../sh-elf/lib/libc.a(lib_
a-makebuf.o): In function `__smakebuf_r':
/home/Julien/cacdev2010/kos/utils/dc-chain/build-newlib-sh-elf-1.18.0/sh-elf/new
lib/libc/stdio/../../../../../newlib-1.18.0/newlib/libc/stdio/makebuf.c:113: und
efined reference to `__isatty_r'
collect2: ld returned 1 exit status
make: *** [modifier.elf] Error 1
Thanks for your help !
ImageAlice Dreams Tournament Dreamcast fans : http://www.facebook.com/alicedreamst
In August 2015, we had to change "Dynamite Dreams" name to "Alice Dreams Tournament"
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5387
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 1 time
Been liked: 12 times
Contact:

Re: Getting started with programming again/

Post by BlueCrab » Thu Jun 17, 2010 8:09 am

Strange... it builds just fine for me...

Code: Select all

ljsdcdev-2:modifier_volume lj$ make
rm -f modifier.elf
kos-cc  -c modifier.c -o modifier.o
/usr/local/dc/sh-elf/bin/sh-elf-gcc -O2 -DFRAME_POINTERS -ml -m4-single-only -fno-crossjumping -I/Users/lj/Projects/clean/cadcdev/kos/../kos-ports/include -I/Users/lj/Projects/clean/cadcdev/kos/include -I/Users/lj/Projects/clean/cadcdev/kos/kernel/arch/dreamcast/include -I/Users/lj/Projects/clean/cadcdev/kos/addons/include -D_arch_dreamcast -D_arch_sub_pristine -Wall -g -fno-builtin -fno-strict-aliasing  -ml -m4-single-only -Wl,-Ttext=0x8c010000 -T/Users/lj/Projects/clean/cadcdev/kos/utils/ldscripts/shlelf.xc -nodefaultlibs -L/Users/lj/Projects/clean/cadcdev/kos/lib/dreamcast -L/Users/lj/Projects/clean/cadcdev/kos/addons/lib/dreamcast -o modifier.elf  \
		modifier.o  -Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group
The only few things I see of the top of my head that are different between my output and yours is that you for some reason have the navi subarch defined, and you seem to have a stray / at the end of your KOS_BASE variable... All of the missing symbols that its complaining about in your output are from libkallisti.a or the crt0.s file that GCC should be including by default... For some reason, its definitely looking like its not including the crt0.s file, but I wouldn't really have any idea why... The only things I can suggest are to fix the KOS_BASE variable (there shouldn't be a / at the end of it in your environ.sh file), and try re-checking out and rebuilding KOS.
nymus
DC Developer
DC Developer
Posts: 955
Joined: Tue Feb 11, 2003 4:12 pm
Location: In a Dream
Has liked: 0
Been liked: 1 time

Re: Getting started with programming again/

Post by nymus » Thu Jun 17, 2010 10:06 am

I must be very unlucky or just lack basic compilation acumen. I used chilly willy's Makefile above and got this:

"kos is an unknown thread package"

Seems like an a potentially easy fix.... I'll just stick with the DDE
behold the mind
inspired by Dreamcast
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has liked: 0
Been liked: 2 times

Re: Getting started with programming again/

Post by Chilly Willy » Thu Jun 17, 2010 12:18 pm

nymus wrote:I must be very unlucky or just lack basic compilation acumen. I used chilly willy's Makefile above and got this:

"kos is an unknown thread package"

Seems like an a potentially easy fix.... I'll just stick with the DDE
You need to checkout the latest cadcdev subversion. It has the patches for everything. Place the makefile above in the kos/utils/dc-chain/ directory and change the spaces to tabs (makefiles won't work with spaces at the start of lines).

Once you've gotten the toolchain compiled, you need to copy the environ.sh.sample from kos/doc to kos as environ.sh, then edit the paths in it. Leave it at "pristine" - don't change it to "navi".

Then from the terminal run "source environ.sh". Make sure you are in the kos directory and run "make", then "make kos-ports_all".
nymus
DC Developer
DC Developer
Posts: 955
Joined: Tue Feb 11, 2003 4:12 pm
Location: In a Dream
Has liked: 0
Been liked: 1 time

Re: Getting started with programming again/

Post by nymus » Thu Jun 17, 2010 4:53 pm

*facepalm. I missed a typo in the midst of all the editing. I had to edit Makefile.rules but managed to compile KOS. It seems, however, that something went horribly wrong:

libkallisti.a(cache.o): compiled for a big endian system and target is little endian

Wait, I think it's because of those needed changes to Makefile.rules...
behold the mind
inspired by Dreamcast
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has liked: 0
Been liked: 2 times

Re: Getting started with programming again/

Post by Chilly Willy » Thu Jun 17, 2010 5:04 pm

:lol:

You must have set the wrong architecture, or edited on the files a little too much. My makefile, for example, does just what Blue Crab said and sets "--with-endian=little" for building the sh4 toolchain. If you set the kos architecture for Dreamcast and leave it on pristine, you should wind up with everything little-endian.

If you HAD to edit Makefile.rules, you edited something you shouldn't have. If you do things correctly, you don't have to edit that file.

The only things you should have to do are edit the makefile I posted for tabs and paths, and the environ.sh.sample for paths (for SH and ARM toolchains, and KOS_BASE).
nymus
DC Developer
DC Developer
Posts: 955
Joined: Tue Feb 11, 2003 4:12 pm
Location: In a Dream
Has liked: 0
Been liked: 1 time

Re: Getting started with programming again/

Post by nymus » Thu Jun 17, 2010 5:49 pm

I don't think I changed the dc-chain Makefile much... (couldn't attach it)

As for Makefile.rules, KOS wouldn't compile because the build rules for %.o were calling "kos-cc" which doesn't exist and asking for "${CFLAGS} and ${CXX_FLAGS}" so I changed that to "${KOS_CC}, "${KOS_CFLAGS}, ${KOS_CPPFLAGS}"

Also, the Makefile for examples/2ndmix.o was asking for "kos-cc" again...

I might be missing something or doing something wrong and would greatly appreciate your assistance.
behold the mind
inspired by Dreamcast
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has liked: 0
Been liked: 2 times

Re: Getting started with programming again/

Post by Chilly Willy » Thu Jun 17, 2010 7:22 pm

You might have forgotten to change the path to KOS_CC_BASE and/or DC_ARM_BASE in environ.sh. Remember that you need NOTHING set to compile the toolchain, then you need to run "source environ.sh" before you try to make kos and kos-ports.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5387
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 1 time
Been liked: 12 times
Contact:

Re: Getting started with programming again/

Post by BlueCrab » Thu Jun 17, 2010 7:31 pm

nymus wrote:I don't think I changed the dc-chain Makefile much... (couldn't attach it)

As for Makefile.rules, KOS wouldn't compile because the build rules for %.o were calling "kos-cc" which doesn't exist and asking for "${CFLAGS} and ${CXX_FLAGS}" so I changed that to "${KOS_CC}, "${KOS_CFLAGS}, ${KOS_CPPFLAGS}"

Also, the Makefile for examples/2ndmix.o was asking for "kos-cc" again...

I might be missing something or doing something wrong and would greatly appreciate your assistance.
kos-cc is a script that is included with KOS in the utils/gnu_wrappers directory. Its been pretty much the easiest way to get everything working for quite a while now, as long as you're using some sane shell (like Bash).
nymus
DC Developer
DC Developer
Posts: 955
Joined: Tue Feb 11, 2003 4:12 pm
Location: In a Dream
Has liked: 0
Been liked: 1 time

Re: Getting started with programming again/

Post by nymus » Thu Jun 17, 2010 7:56 pm

BlueCrab wrote: kos-cc is a script that is included with KOS in the utils/gnu_wrappers directory. Its been pretty much the easiest way to get everything working for quite a while now, as long as you're using some sane shell (like Bash).
OIC! I copied those scripts over to my dcdev/bin directory and it worked! :D Thanks!

There just seems to be a conflict b/w libc and libkallisti __assert in the c++ examples but it should be easy to sort out.
behold the mind
inspired by Dreamcast
patbier
DC Developer
DC Developer
Posts: 152
Joined: Fri Aug 29, 2003 1:25 am
Has liked: 0
Been liked: 0

Re: Getting started with programming again/

Post by patbier » Fri Jun 18, 2010 6:27 am

BlueCrab wrote:Strange... it builds just fine for me...

Code: Select all

ljsdcdev-2:modifier_volume lj$ make
rm -f modifier.elf
kos-cc  -c modifier.c -o modifier.o
/usr/local/dc/sh-elf/bin/sh-elf-gcc -O2 -DFRAME_POINTERS -ml -m4-single-only -fno-crossjumping -I/Users/lj/Projects/clean/cadcdev/kos/../kos-ports/include -I/Users/lj/Projects/clean/cadcdev/kos/include -I/Users/lj/Projects/clean/cadcdev/kos/kernel/arch/dreamcast/include -I/Users/lj/Projects/clean/cadcdev/kos/addons/include -D_arch_dreamcast -D_arch_sub_pristine -Wall -g -fno-builtin -fno-strict-aliasing  -ml -m4-single-only -Wl,-Ttext=0x8c010000 -T/Users/lj/Projects/clean/cadcdev/kos/utils/ldscripts/shlelf.xc -nodefaultlibs -L/Users/lj/Projects/clean/cadcdev/kos/lib/dreamcast -L/Users/lj/Projects/clean/cadcdev/kos/addons/lib/dreamcast -o modifier.elf  \
		modifier.o  -Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group
The only few things I see of the top of my head that are different between my output and yours is that you for some reason have the navi subarch defined, and you seem to have a stray / at the end of your KOS_BASE variable... All of the missing symbols that its complaining about in your output are from libkallisti.a or the crt0.s file that GCC should be including by default... For some reason, its definitely looking like its not including the crt0.s file, but I wouldn't really have any idea why... The only things I can suggest are to fix the KOS_BASE variable (there shouldn't be a / at the end of it in your environ.sh file), and try re-checking out and rebuilding KOS.
Thanks, i found the problem : in my PATH variable, i had a path to my old toolchain, so there was a conflict. As soon as I correct the PATH variable, it worked ! I also defined "pristine" for the subarch.

For the kos/examples, some don't compile : example :

Code: Select all

make[2]: Entering directory `/home/Julien/cacdev2010/kos/examples/dreamcast/coni
o/adventure'
rm -f adventure.elf
/usr/local/dc2010/sh-elf/bin/sh-elf-gcc -O2 -fomit-frame-pointer -ml -m4-single-
only -fno-crossjumping -I/home/Julien/cacdev2010/kos/../kos-ports/include -I/hom
e/Julien/cacdev2010/kos/include -I/home/Julien/cacdev2010/kos/kernel/arch/dreamc
ast/include -I/home/Julien/cacdev2010/kos/addons/include -D_arch_dreamcast -D_ar
ch_sub_pristine -Wall -g -fno-builtin -fno-strict-aliasing  -ml -m4-single-only
-Wl,-Ttext=0x8c010000 -T/home/Julien/cacdev2010/kos/utils/ldscripts/shlelf.xc -n
odefaultlibs -L/home/Julien/cacdev2010/kos/lib/dreamcast -L/home/Julien/cacdev20
10/kos/addons/lib/dreamcast -o adventure.elf  porthelper.o crc.o done.o init.o i
o.o main.o save.o subr.o vocab.o wizard.o data.o   -lconio -Wl,--start-group -lk
allisti -lc -lgcc -Wl,--end-group
init.o: In function `init':
/home/Julien/cacdev2010/kos/examples/dreamcast/conio/adventure/init.c:64: multip
le definition of `_init'
/usr/local/dc2010/sh-elf/lib/gcc/sh-elf/4.4.4/crti.o:(.init+0x0): first defined
here
collect2: ld returned 1 exit status
make[2]: *** [adventure.elf] Error 1
make[2]: Leaving directory `/home/Julien/cacdev2010/kos/examples/dreamcast/conio
/adventure'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/Julien/cacdev2010/kos/examples/dreamcast/conio
'
make: *** [all] Error 255
I have another question. I compiled my game with my old dc-toolchain (made with kos rev 606 with binutils_ver=2.17 , gcc_ver=3.4.6 , newlib_ver=1.12.0 , gdb_ver=6.7.1 , insight_ver=6.7.1

and with the new one : there's a huge difference in the .elf :

old toolchain : 2 067 Ko
new toochain : 2 829 Ko

Why 800 Ko ?

My game uses 2 files : game.c and dream.c
old toolchain : game.o : 467 Ko and dream.o : 86 Ko
new toolchain : game.o : 576 Ko and dream.o : 124 Ko

For information, here is how the game is compiled with the old toolchain :

Code: Select all

kos-cc  -c al/game.c -o al/game.o
/usr/local/dc/sh-elf/bin/sh-elf-gcc
    -Wall
    -ml
    -m4-single-only
    -O2 
    -fno-builtin 
    -fno-strict-aliasing 
    -fomit-frame-pointer 
    -fno-optimize-sibling-calls 
    -ml 
    -m4-single-only 
    -fno-crossjumping 
    -I/home/Julien/cacdev/kos//
    ../kos-ports/include 
    -I/home/Julien/cacdev/kos//include 
    -I/home/Julien/cacdev/kos//kernel/arch/dreamcast/include 
    -I/home/Julien/cacdev/kos//addons/include 
    -D_arch_dreamcast 
    -D_arch_sub_navi 
    -Wall 
    -g 
    -fno-builtin
    -fno-strict-aliasing  
    -ml 
    -m4-single-only 
    -Wl,-Ttext=0x8c010000 
    -nostartfiles 
    -nostdlib 
    -L/home/Julien/cacdev/kos//lib/dreamcast 
    -L/home/Julien/cacdev/kos//addons/lib/dreamcast
    -o dyna_dc.elf 
    /home/Julien/cacdev/kos//kernel/arch/dreamcast/kernel/startup.o 
    al/gl2d/dream.o
    al/game.o
    -loggvorbisplay 
    -lpng 
    -lz 
    -lm 
    -Wl,--start-group -lkallisti
    -lc 
    -lgcc 
    -Wl,--end-group
and with the new one :

Code: Select all

kos-cc  -c al/game.c -o al/game.o
/usr/local/dc2010/sh-elf/bin/sh-elf-gcc 
    -O2 
    -fomit-frame-pointer 
    -ml 
    -m4-single-only 
    -fno-crossjumping 
    -I/home/Julien/cacdev2010/kos/../kos-ports/include 
    -I/home/Julien/cacdev2010/kos/include 
    -I/home/Julien/cacdev2010/kos/kernel/arch/dreamcast/include 
    -I/home/Julien/cacdev2010/kos/addons/include 
    -D_arch_dreamcast 
    -D_arch_sub_pristine 
    -Wall 
    -g 
    -fno-builtin 
    -fno-strict-aliasing  
    -ml 
    -m4-single-only
    -Wl,-Ttext=0x8c010000 
    -T/home/Julien/cacdev2010/kos/utils/ldscripts/shlelf.xc 
    -nodefaultlibs 
    -L/home/Julien/cacdev2010/kos/lib/dreamcast
    -L/home/Julien/cacdev2010/kos/addons/lib/dreamcast 
    -o dyna_dc.elf  
    al/gl2d/dream.o
    al/game.o
    -loggvorbisplay 
    -lpng 
    -lz 
    -lm 
    -Wl,--start-group -lkallisti 
    -lc 
    -lgcc 
    -Wl,--end-group
Do you have any idea ? Or is it normal ?

[EDIT] I looked into \kos\lib\dreamcast

with old : libk++.a : 5 Ko libkallisti.a : 1468 Ko libkallisti_exports.a : 50 Ko
with new : libk++.a : 5 Ko libkallisti.a : 1949 Ko libkallisti_exports.a : 50 Ko

libkallisti.a has 550 Ko more so the difference is mainly here, but if someone has another idea, don't hesitate :)
ImageAlice Dreams Tournament Dreamcast fans : http://www.facebook.com/alicedreamst
In August 2015, we had to change "Dynamite Dreams" name to "Alice Dreams Tournament"
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5387
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 1 time
Been liked: 12 times
Contact:

Re: Getting started with programming again/

Post by BlueCrab » Fri Jun 18, 2010 8:01 am

.elf files contain debugging information, so they're not a particularly useful means of comparing the actual code size that results. Its quite possible that GCC has changed its default debugging symbol output to be more verbose in that time period. If there's a huge difference in the .bin files that result after pushing them through the sh-elf-objcopy, then I'd be concerned.

As for the example that has its own _init symbol, that should be changed, and I'll try to do it a bit later today so that it will at least compile properly.
patbier
DC Developer
DC Developer
Posts: 152
Joined: Fri Aug 29, 2003 1:25 am
Has liked: 0
Been liked: 0

Re: Getting started with programming again/

Post by patbier » Fri Jun 18, 2010 2:33 pm

BlueCrab wrote:.elf files contain debugging information, so they're not a particularly useful means of comparing the actual code size that results. Its quite possible that GCC has changed its default debugging symbol output to be more verbose in that time period. If there's a huge difference in the .bin files that result after pushing them through the sh-elf-objcopy, then I'd be concerned.

As for the example that has its own _init symbol, that should be changed, and I'll try to do it a bit later today so that it will at least compile properly.
Thanks for the answer, I just tried to make bin files (1ST_READ.BIN) :

with old toolchain : 788 Ko
with new toolchain : 871 Ko

So 83 ko more (10.5%).

I you need more information, don't hesitate.
ImageAlice Dreams Tournament Dreamcast fans : http://www.facebook.com/alicedreamst
In August 2015, we had to change "Dynamite Dreams" name to "Alice Dreams Tournament"
Post Reply