From dada69c88d50829292c531e04c9eb87e22dc6ddd Mon Sep 17 00:00:00 2001 From: Clifford Matthews Date: Mon, 22 Jun 2009 16:24:05 -0600 Subject: [PATCH] Hack: add -fno-dce when compiling for x86_64 --- TODO | 20 ++++++-------------- configure.ac | 7 +++++++ runtime/Makefile.am | 17 ++++++++++++++++- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/TODO b/TODO index c0ddd1c..fb329dc 100644 --- a/TODO +++ b/TODO @@ -1,23 +1,12 @@ - May be able to avoid dce problems if we use && for labels (that - may also get rid of our need for the cleanup code, too) - - Need to make it so that the minimal required compilation options for +TEST Need to make it so that the minimal required compilation options for x86_64 (-fno-dce) are set up by default - should probably report dead code elimination bug before I - forget the details (I've probably already lost the minimal - test case) (the details being that if you update a global - register and then use a label pointer to jump away, the - update can get eliminated even though the register can - still be accessed - - - cleanup and optimize shouldn't be done via environment variables; +TEST cleanup and optimize shouldn't be done via environment variables; they should be done with AC_ARG_ENABLE and default to be turned on on the architectures where they work (and should be made to work on the architectures they support) - only invoke the x86 cleanup & optimize when compiling for an +TEST only invoke the x86 cleanup & optimize when compiling for an x86 architecture can probably write cleanup scripts for other architectures, @@ -60,3 +49,6 @@ need a .spec file so we can build syn68k and syn68k-devel RPMS + + May be able to avoid dce problems if we use && for labels (that + may also get rid of our need for the cleanup code, too) diff --git a/configure.ac b/configure.ac index 681a311..cebb425 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,13 @@ esac AC_SUBST(host_cpu_class) +# See lengthy explanation in runtime/Makefile.am for dce_fixup explanation + +if test x$host_cpu = xx86_64; then + dce_fixup=-fno-dce +fi + +AC_SUBST(dce_fixup) AC_MSG_CHECKING([Syn68k C flags (TODO: FIXME)]) SYN68K_CFLAGS="${SYN68K_CFLAGS--O2 -fomit-frame-pointer}" diff --git a/runtime/Makefile.am b/runtime/Makefile.am index 9e23ca6..3e47d74 100644 --- a/runtime/Makefile.am +++ b/runtime/Makefile.am @@ -9,6 +9,21 @@ SYN68K_CFLAGS=@SYN68K_CFLAGS@ CLEANUP=@assembly_cleanup_script@ OPTIMIZE=@assembly_optimization_script@ +# The way we use labels in our assembler is out of spec. The gcc info +# pages say that you're not allowed to jump between labels of asm. +# Historically, however, we chose not to put everything into a single +# function and then jump about within spec. IIRC, that was either due +# to the compilation time and memory consumption to be excessive +# and/or due to us running into compiler bugs. This was all back +# around 1995 though and we have more memory and better compilers. As +# such, it may make sense to re-evaluate the decision to split all the +# opcodes into separate functions. However, until we do that, we need +# to deal with the fact that some dead-code-elimination (DCE) +# optimizations will cause our trickery to fail. As such, we include +# "-fno-dce" in the architectures where we know we're going to have trouble. + +dce_fixup=@dce_fixup@ + AM_CFLAGS = -DRUNTIME LOCAL_INCLUDES = @@ -62,7 +77,7 @@ syn68k.o: syn68k.c outgoing=;\ $(CC) -maccumulate-outgoing-args -c -x c /dev/null 2> /dev/null \ && outgoing=-maccumulate-outgoing-args; \ - $(CC) -S $(SYN68K_CFLAGS) -Wall -static -fno-defer-pop -Wno-unused\ + $(CC) -S $(SYN68K_CFLAGS) $(dce_fixup) -Wall -static -fno-defer-pop -Wno-unused\ $(LOCAL_INCLUDES) $$outgoing syn68k.c -o ./syn68k.s if [ x"$(CLEANUP)" != x ] ; then \ $(PERL) $(srcdir)/$(CLEANUP) < syn68k.s > syn68k.s.new && \