Cleanup: unified GCC compilation flags for Linux builds
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 21 Mar 2017 13:00:49 +0000
changeset 126 9cd66b79ca54
parent 125 aaafde2b6c31
child 127 664296ccdb4a
child 162 199235cbc717
Cleanup: unified GCC compilation flags for Linux builds ...and make sure code is compiled with optimizations (`-O2` as of now)
makelib/config-linux-i386.make
makelib/config-linux-x86_64.make
makelib/config-linux.make
specs/stx-jv.rbspec
--- a/makelib/config-linux-i386.make	Mon Mar 06 21:21:07 2017 +0000
+++ b/makelib/config-linux-i386.make	Tue Mar 21 13:00:49 2017 +0000
@@ -17,17 +17,8 @@
 DEFS=-D__amd64_mode32__ -DELF
 DLDEFS=-DHAS_DLOPEN
 
+CCCONFOPT=-m32
 
-#
-# ATTENTION: with gcc3.2 fPIC + O6 generates wrong code in stc - sigh
-#
-CCCONFOPT=-m32
-OPT=-fPIC -O2 -fomit-frame-pointer -fno-stack-protector
-# avoid tree-loop-vectorize in librun for now as is makes librun/md5.c segfault
-# also, do not call it tree-loop-vectorize, but combine tree-vectorize 
-# and ftree-slp-vectorize for gcc version before 4.9
-# LIBRUN_OPT=$(OPT) -fno-tree-vectorize -ftree-slp-vectorize
-LIBRUN_OPT=-fPIC -O0 -fomit-frame-pointer -fno-stack-protector -fno-tree-vectorize
 AS_CC=as
 AS_CC_CFLAG=
 ASFLAGS=--32
@@ -60,8 +51,6 @@
 # END FFI kludge
 FFI_CFLAGS=$(CCCONFOPT)
 #------------------ end of linux-elf/amd64_mode32 ---------------------
-OPT?=-pipe -fno-omit-frame-pointer -fno-stack-protector -fno-strict-aliasing -fwrapv -fPIC -O -ggdb3
-LIBRUN_OPT?=$(OPT)
 O_RULE=__STANDARD_O_RULE__
 EXTRA_LIBS=-ldl -lX11 -lXext
 
--- a/makelib/config-linux-x86_64.make	Mon Mar 06 21:21:07 2017 +0000
+++ b/makelib/config-linux-x86_64.make	Tue Mar 21 13:00:49 2017 +0000
@@ -26,14 +26,6 @@
 	-Wl,-z,now,-Bsymbolic,-rpath,'$$ORIGIN',-rpath,'$$ORIGIN/lib',-rpath,'$$ORIGIN/../lib'
 EXTRA_SHARED_LIBS=-ldl
 
-#
-# ATTENTION: with gcc3.2 fPIC + O6 generates wrong code in stc - sigh
-# gcc toplevel-reorder breaks relative function offset generation (leads to SIGSEGV)
-OPT=-O2 -fno-toplevel-reorder -fno-stack-protector
-
-# workaround for failing longjmp check: undefine FORTIFY_SOURCE, which is enabled by default on Gentoo. Remove when fixed.
-LIBRUN_OPT=-g -O -fno-stack-protector -U_FORTIFY_SOURCE -Wno-comment -Wno-pointer-sign -Wno-unused-variable -Wno-unused-parameter -Wno-unused-label -Wall
-
 #OPTIONAL_DL_LIB=-ldl
 #OPTIONAL_LIBDL_TARGET=libdld
 
@@ -76,8 +68,6 @@
 #	$(LD) -shared $(LDFLAGS) -o $*.so $*.o $(LOCAL_SHARED_LIBS)
 
 #------------------ end of linux-elf/x86_64 ---------------------
-OPT?=-pipe -fno-omit-frame-pointer -fno-stack-protector -fno-strict-aliasing -fwrapv -fPIC  -ggdb3
-LIBRUN_OPT?=$(OPT)
 O_RULE=__STANDARD_O_RULE__
 EXTRA_LIBS=-ldl -lX11 -lXext
 MAKE_ZLIB_ARG= "CFLAGS=-fPIC -O3 -DUSE_MMAP"
--- a/makelib/config-linux.make	Mon Mar 06 21:21:07 2017 +0000
+++ b/makelib/config-linux.make	Tue Mar 21 13:00:49 2017 +0000
@@ -31,11 +31,27 @@
 
 CC=gcc
 
-STC_LEXLIB=
-STC_OPT=-O -fno-stack-protector
+#
+# * `-fno-strict-aliasing` since it's almost impossible to write a memory
+#   manager without breaking C's aliasing rules. Better be on a safe side.
+#   Nice post about these things: http://blog.regehr.org/archives/1307
+#
+# * `-Wno-strict-aliasing` to turn of warnings about breaking aliasing rules. 
+#   While one would think these wanings should be turned off when 
+#   `-fno-strict-aliasing` is passed, apparently some GCCs bark anyway. 
+#
+# * `-fno-stack-protector` is (was) required on Ubuntu brands where it's 
+#   by default on. Smalltalk/X green thread implementation does not wotk
+#   well with it. 
+#
+# * `-U_FORTIFY_SOURCE` is (was) required on Gentoo as a workaround for failing 
+#   longjmp check when _FORTIFY_SOURCE is defined (which is enabled by default 
+#   on Gentoo. Remove when fixed.
+#
+OPT=-fPIC -O2 -fno-strict-aliasing -Wno-strict-aliasing -fno-stack-protector -ggdb3 -pipe -U_FORTIFY_SOURCE
 
-# There are problems with -O3 in gcc3.0, gcc3.3, gcc3.3.1
-LIBRUN_OPT=-O2 -fPIC -fomit-frame-pointer -fno-stack-protector
+STC_LEXLIB=
+
 OS=-DLINUX
 
 FFI_ARCH=x86
--- a/specs/stx-jv.rbspec	Mon Mar 06 21:21:07 2017 +0000
+++ b/specs/stx-jv.rbspec	Tue Mar 21 13:00:49 2017 +0000
@@ -128,9 +128,9 @@
       if PROJECT == 'stx:jv-branch' then  
         chdir BUILD_DIR / 'stx' / 'projects' / 'smalltalk' do
           if win32?
-            cmd = "smalltalk.bat -I --quick --eval \"Stdout nextPutLine:'OKay, VM runs'. Smalltalk exit: 0\""
+            cmd = "smalltalk.bat --abortOnSEGV -I --quick --eval \"Stdout nextPutLine:'OKay, VM runs'. Smalltalk exit: 0\""
           else
-            cmd = "./smalltalk -I --quick --eval \"Stdout nextPutLine:'OKay, VM runs'. Smalltalk exit: 0\""
+            cmd = "./smalltalk --abortOnSEGV -I --quick --eval \"Stdout nextPutLine:'OKay, VM runs'. Smalltalk exit: 0\""
           end
           if not system cmd
             raise Exception.new("Cannot run smalltalk!")