Subject: bug#9705: 24.0.90; cannot compile GNU Emacs with Apple modified GCC 4.0 and 4.2

From: Peter Dyballa <[email-masked]>
Date: Sun, 9 Oct 2011 12:31:14 +0200

Am 09.10.2011 um 01:26 schrieb Peter Dyballa:

> Both compilers compile OK when used with -O0 and -Os.

They work OK with -O3.

The documentation for both Apple modified compilers describes:

	http://developer.apple.com/library/mac/#documentation/DeveloperTools/ 
gcc-4.2.1/gcc/index.html
	http://developer.apple.com/library/mac/#documentation/DeveloperTools/ 
gcc-4.0.1/gcc/index.html
	
	4.2.1				4.0.1
	=====				=====
	-O turns on the following optimization flags:
	
	-fdefer-pop			-fdefer-pop
	-fdelayed-branch		-fdelayed-branch
	-fguess-branch-probability	-fguess-branch-probability
	-fcprop-registers		-fcprop-registers
					-floop-optimize
	-fif-conversion			-fif-conversion
	-fif-conversion2		-fif-conversion2
	-ftree-ccp			-ftree-ccp
	-ftree-dce			-ftree-dce
	-ftree-dominator-opts		-ftree-dominator-opts
	-ftree-dse			-ftree-dse
	-ftree-ter			-ftree-ter
	-ftree-lrs			-ftree-lrs
	-ftree-sra			-ftree-sra
	-ftree-copyrename		-ftree-copyrename
	-ftree-fre			-ftree-fre
	-ftree-ch			-ftree-ch
	-fmerge-constants		-fmerge-constants
	-funit-at-a-time
	
	-O also turns on -fomit-frame-pointer on machines where doing so does  
not interfere with debugging.

	-O2 turns on all optimization flags specified by -O. It also turns on  
the following optimization flags:
	
	-fthread-jumps			-fthread-jumps
	-fcrossjumping			-fcrossjumping
	-foptimize-sibling-calls	-foptimize-sibling-calls
	-fcse-follow-jumps		-fcse-follow-jumps
	-fcse-skip-blocks		-fcse-skip-blocks
	-fgcse				-fgcse
	-fgcse-lm			-fgcse-lm
	-fexpensive-optimizations	-fexpensive-optimizations
					-fstrength-reduce
	-frerun-cse-after-loop		-frerun-cse-after-loop
					-frerun-loop-opt
	-fcaller-saves			-fcaller-saves
					-fforce-mem
	-fpeephole2			-fpeephole2
	-fschedule-insns		-fschedule-insns
	-fschedule-insns2		-fschedule-insns2
	-fsched-interblock		-fsched-interblock
	-fsched-spec			-fsched-spec
	-fregmove			-fregmove
	-fstrict-aliasing		-fstrict-aliasing
	-fstrict-overflow
	-fdelete-null-pointer-checks	-fdelete-null-pointer-checks
	-freorder-blocks		-freorder-blocks
	-freorder-functions		-freorder-functions
					-funit-at-a-time
	-falign-functions		-falign-functions
	-falign-jumps			-falign-jumps
	-falign-loops			-falign-loops
	-falign-labels			-falign-labels
	-ftree-vrp
	-ftree-pre			-ftree-pre
	
	Please note the warning under -fgcse about invoking -O2 on programs  
that use computed gotos.

	-O3 turns on all optimizations specified by -O2 and also turns on
	
	-finline-functions		-finline-functions
	-funswitch-loops		-funswitch-loops
	-fgcse-after-reload		-fgcse-after-reload

	-Os enables all -O2 optimizations that do not typically increase code  
size. It also performs further optimizations designed to reduce code  
size. -Os disables the following optimization flags:
	
	-falign-functions		-falign-functions
	-falign-jumps			-falign-jumps
	-falign-loops			-falign-loops
	-falign-labels			-falign-labels
	-freorder-blocks		-freorder-blocks
	-freorder-blocks-and-partition	-freorder-blocks-and-partition
	-fprefetch-loop-arrays		-fprefetch-loop-arrays
	-ftree-vect-loop-version

	-fast
	Optimize for maximum performance. -fast changes the overall  
optimization strategy of GCC in order to produce the fastest possible  
running code for PPC7450 and G5 architectures. By default, -fast  
optimizes for G5. Programs optimized for G5 will not run on PPC7450.  
To optimize for PPC7450, add -mcpu=7450 on command line.
	-fast currently enables the following optimization flags (for G5 and  
PPC7450). These flags may change in the future. You cannot override  
any of these options if you use -fast except by setting -mcpu=7450 (or  
-fPIC, see below).
	
	-O3				-O3
	-falign-loops-max-skip=15	-falign-loops-max-skip=15
	-falign-jumps-max-skip=15	-falign-jumps-max-skip=15
	-falign-loops=16		-falign-loops=16
	-falign-jumps=16		-falign-jumps=16
	-falign-functions=16		-falign-functions=16
	-malign-natural (except when…)	-malign-natural (except when -fastf is  
specified)
	-ffast-math			-ffast-math
	-fstrict-aliasing		-fstrict-aliasing
	-funroll-loops			-funroll-loops
	-ftree-loop-linear		-ftree-loop-linear
	-ftree-loop-memset		-ftree-loop-memset
	-mcpu=G5			-mcpu=G5
	-mpowerpc-gpopt			-mpowerpc-gpopt
	-mtune=G5  (unless -mtune=G4… )	-mtune=G5  (unless -mtune=G4 is  
specified).
	-fsched-interblock		-fsched-interblock
	-fgcse-sm			-fgcse-sm
	-mpowerpc64			-mpowerpc64
	
	To build shared libraries with -fast, specify -fPIC on the command  
line as -fast turns on -mdynamic-no-pic otherwise.
	
	Important notes: -ffast-math results in code that is not necessarily  
IEEE-compliant. -fstrict-aliasing is highly likely to break non- 
standard-compliant programs. -malign-natural only works properly if  
the entire program is compiled with it, and none of the standard  
headers/libraries contain any code that changes alignment when this  
option is used.
	
	On Intel target, -fast currently enables the following optimization  
flags:
	
	-O3				-O3
	-fomit-frame-pointer		-fomit-frame-pointer
	-fstrict-aliasing		-fstrict-aliasing
	-momit-leaf-frame-pointer	-momit-leaf-frame-pointer
	-fno-tree-pre			-fno-tree-pre
	-falign-loops			-falign-loops
	
	All choices of flags enabled by -fast are subject to change without  
notice.

My recent series of tests is with:

	env LANG=C PATH=/sw/bin:$PATH ./configure --without-sound --without- 
dbus --without-pop --without-gconf --without-gpm --without-gsettings -- 
without-gif --without-jpeg --without-png --without-rsvg --without-tiff  
--without-xpm --with-wide-int --with-x-toolkit=athena --x-libraries=/ 
usr/X11/lib --x-includes=/usr/X11/include --enable-locallisppath=/ 
Library/Application\ Support/Emacs/calendar24:/Library/Application\  
Support/Emacs

While

	LDFLAGS="-Wl,-dead_strip_dylibs -Wl,-bind_at_load -Wl,-t" CC=gcc-4.2  
CPP=cpp-4.2 PKG_CONFIG_PATH=/sw/lib/xft2/lib/pkgconfig:/sw/share/ 
pkgconfig:/sw/lib/pkgconfig:/usr/X11/lib/pkgconfig:/usr/X11/share/ 
pkgconfig:/usr/lib/pkgconfig

stay unchanged I modify

	CFLAGS="-g -H -pipe -fPIC -fno-common -mcpu=7450 -mtune=G4 -maltivec - 
faltivec -mabi=altivec -O3 -falign-loops-max-skip=15 -falign-loops=16 - 
falign-jumps=16 -falign-functions=16 -ffast-math -fstrict-aliasing - 
mfused-madd -mmultiple -ftree-vectorize -mpowerpc-gfxopt"

Now, at high noon, I already found that -malign-natural produces the  
failure – the documentation warns about its use!

(I wonder whether the sequence of the flags passed to the compiler  
plays a role. I'll also try an additional test à la '-fast -mcpu=7450 - 
mtune=G4' or '-fast -mcpu=7450 -mtune=7450' to be sure that non-G4  
options are effectively suppressed. -fastf is also an option I should  
consider and read again about it.)

--
Greetings

   Pete
               <\
                 \__     O                       __O
                 | O\   _\\/\-%                _`\<,
                 '()-'-(_)--(_)               (_)/(_)