From d1196c0eba5d38f42fddb7519dcf83a793184af8 Mon Sep 17 00:00:00 2001 From: bebbo Date: Tue, 11 Jul 2017 13:05:21 +0200 Subject: [PATCH] @R using -Os --- examples/Makefile | 6 +++- examples/test-exceptions.cpp | 58 ++++++++++++++++++++++++++++++++++++ toolchain-m68k | 12 ++++---- 3 files changed, 69 insertions(+), 7 deletions(-) create mode 100755 examples/test-exceptions.cpp diff --git a/examples/Makefile b/examples/Makefile index e304dcf..f802d42 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -2,12 +2,13 @@ CC = m68k-amigaos-gcc CXX = m68k-amigaos-g++ CFLAGS = -Os -Wall -fomit-frame-pointer CXXFLAGS = -Os -Wall -fomit-frame-pointer -fno-rtti -fno-exceptions +CXXFLAGSX = -Os -Wall BINS = hello-ks13 hello-ks20 hello-ks20.clib2 \ hello-stdio hello-stdio.clib2 hello-stdio.nix13 \ hello-mui test-mmu \ simple.library simple.library_r simple.device \ - test-ctors hello-iostream + test-ctors hello-iostream test-exceptions all: $(BINS) $(OBJS) @@ -38,6 +39,9 @@ test-ctors: test-ctors.cpp $(CXX) -noixemul -m68020 $(CXXFLAGS) -c -o test-ctors.o $< $(CXX) -noixemul -m68020 $(CXXFLAGS) -o $@ test-ctors*.o +test-exceptions: test-exceptions.cpp + $(CXX) -noixemul $(CXXFLAGSX) -o $@ $^ + hello-mui: hello-mui.c $(CC) -noixemul -m68020 -msmall-code $(CFLAGS) -o $@ $< -lmui diff --git a/examples/test-exceptions.cpp b/examples/test-exceptions.cpp new file mode 100755 index 0000000..93c0c84 --- /dev/null +++ b/examples/test-exceptions.cpp @@ -0,0 +1,58 @@ +#include +struct A +{ + int x; + + A (A const & a) : + x (a.x) + { + printf ("copy ctor A %d\n", x); + } + A (int i) : + x (i) + { + printf ("ctor A %d\n", x); + } + + ~A () + { + printf ("dtor A %d\n", x); + } +}; + +void +foo (int x) +{ + A a (42); + try + { + A ax (x); + if (x == 1) + throw x; + if (x == 3) + throw ax; + } + catch (int y) + { + printf ("foo catch %d\n", y); + } +} + +int +main () +{ + try + { + for (int i = 0; i < 4; ++i) + { + printf ("call foo(%d)\n", i); + foo (i); + } + } + catch (A const & a) + { + printf ("main catch A %d\n", a.x); + } + printf (" back in main\n"); + return 0; +} diff --git a/toolchain-m68k b/toolchain-m68k index 1131696..e2e51da 100755 --- a/toolchain-m68k +++ b/toolchain-m68k @@ -540,9 +540,9 @@ def _build(pull): from_dir='{submodules}/{gcc}' if fill_in('{gcc}') != 'gcc-3.4.6' else '{sources}/{gcc}') touch_genfiles('{submodules}/{gcc}' if fill_in('{gcc}') != 'gcc-3.4.6' else '{sources}/{gcc}') make('{gcc}', 'all-gcc', - MAKEINFO='makeinfo', CFLAGS_FOR_TARGET='-noixemul -Ofast') + MAKEINFO='makeinfo', CFLAGS_FOR_TARGET='-noixemul -Os') make('{gcc}', 'install-gcc', - MAKEINFO='makeinfo', CFLAGS_FOR_TARGET='-noixemul -Ofast') + MAKEINFO='makeinfo', CFLAGS_FOR_TARGET='-noixemul -Os') headers_install() @@ -551,8 +551,8 @@ def _build(pull): if fill_in('{gcc}') != 'gcc-3.4.6': with env(CC=CC, CXX=CXX, CFLAGS=FLAGS, CXXFLAGS=FLAGS): - make('{gcc}', 'all-target-libgcc', MAKEINFO='makeinfo', CFLAGS_FOR_TARGET='-noixemul -Ofast') - make('{gcc}', 'install-target-libgcc', MAKEINFO='makeinfo', CFLAGS_FOR_TARGET='-noixemul -Ofast') + make('{gcc}', 'all-target-libgcc', MAKEINFO='makeinfo', CFLAGS_FOR_TARGET='-noixemul -Os') + make('{gcc}', 'install-target-libgcc', MAKEINFO='makeinfo', CFLAGS_FOR_TARGET='-noixemul -Os') configure('{libnix}', @@ -667,7 +667,7 @@ def add_stubs(src): libdir, 'libnix/libstubs.a') info('stubs: "%s" -> "%s"', obj, lib) cflags = list(cflags) + ['-noixemul', '-c', '-o', obj, src] - execute('m68k-amigaos-gcc', '-Wall', '-O3', '-fomit-frame-pointer', *cflags) + execute('m68k-amigaos-gcc', '-Wall', '-Os', '-fomit-frame-pointer', *cflags) execute('m68k-amigaos-ar', 'rs', lib, obj) remove(obj) @@ -679,7 +679,7 @@ def add_lib(src, libname): lib = path.join('{prefix}/{target}/lib', libdir, libname) info('lib: "%s" -> "%s"', obj, lib) cflags = list(cflags) + ['-noixemul', '-c', '-o', obj, src] - execute('m68k-amigaos-gcc', '-Wall', '-O3', '-fomit-frame-pointer', *cflags) + execute('m68k-amigaos-gcc', '-Wall', '-Os', '-fomit-frame-pointer', *cflags) execute('m68k-amigaos-ar', 'rcs', lib, obj) remove(obj)