OpenTTD

Tasklist

FS#1928 - OpenTTD 0.6.0 fails to build on stock FreeBSD 6.2-STABLE

Attached to Project: OpenTTD
Opened by sroome (sroome) - Monday, 14 April 2008, 00:33 GMT
Last edited by Jean-Francois Claeys (Belugas) - Monday, 14 April 2008, 01:59 GMT
Type Bug
Category Build system
Status Closed
Assigned To No-one
Operating System *BSD
Severity High
Priority Normal
Reported Version 0.6.0
Due in Version Undecided
Due Date 2008-04-30
Percent Complete 100%
Votes 0
Private No

Details

When trying to build openttd 0.6.0 on FreeBSD the configure script has problems:

a) According to ./configure this version of gcc is unusable:

Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.4.6 [FreeBSD] 20060305

This game was originally assembly and gcc worked fine, why does it now seem to need a hi-tech current compiler, (silly over optimizing flags perhaps?).

b) the supplied configure script on FreeBSD wants to use -fno-strict-overflow when used with gcc42 (which is good enough to compile this clever code!)

e.g.


steve@zebedee 19 0 ~/openttd-0.6.0 % ./configure
checking awk... awk
checking build system type... gcc not found
I couldn't detect any gcc binary on your system
please define the CC/CXX environment to where it is located


steve@zebedee 20 1 ~/openttd-0.6.0 % CC=/usr/bin/gcc ./configure
checking awk... awk
checking build system type... /usr/bin/gcc unusable
the CC environment variable is set, but it doesn't seem to be a gcc binary
please redefine the CC/CXX environment to a gcc binary


steve@zebedee 21 1 ~/openttd-0.6.0 % export CC=/usr/bin/gcc


steve@zebedee 22 0 ~/openttd-0.6.0 % ./configure
checking awk... awk
checking build system type... /usr/bin/gcc unusable
the CC environment variable is set, but it doesn't seem to be a gcc binary
please redefine the CC/CXX environment to a gcc binary


steve@zebedee 23 1 ~/openttd-0.6.0 % /usr/bin/gcc -v
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.4.6 [FreeBSD] 20060305


steve@zebedee 24 0 ~/openttd-0.6.0 % export CC=/usr/local/bin/gcc42


steve@zebedee 25 0 ~/openttd-0.6.0 % /usr/local/bin/gcc42 -v
Using built-in specs.
Target: i386-portbld-freebsd6.3
Configured with: ./..//gcc-4.2-20080116/configure --disable-nls --with-system-zlib --with-libiconv-prefix=/usr/local --with-gmp=/usr/local --program-suffix=42 --libdir=/usr/local/lib/gcc-4.2.3 --with-gxx-include-dir=/usr/local/lib/gcc-4.2.3/include/c++/ --disable-rpath --prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info/gcc42 i386-portbld-freebsd6.3
Thread model: posix
gcc version 4.2.3 20080116 (prerelease)


steve@zebedee 26 0 ~/openttd-0.6.0 % ./configure
checking awk... awk
checking build system type... i386-portbld-freebsd6.3
checking host system type... i386-portbld-freebsd6.3
detecting OS... FREEBSD
checking universal build... no
checking build cc... /usr/local/bin/gcc42
checking host cc... /usr/local/bin/gcc42
checking build c++... g++
checking host c++... g++
checking host strip... strip
checking makedepend... makedepend
detecting cpu-type... 32 bits
checking static... no
checking unicode... no
using debug level... no
using desync debug level... no
checking SDL... found
checking COCOA... not OSX, skipping
checking GDI video driver... not Windows, skipping
checking dedicated... not selected
checking network... found
checking translator... no
checking assert... disabled
checking zlib... found
checking libpng... found
checking libfreetype... found
checking libfontconfig... found
checking iconv... not OSX, skipping
checking psp-config... not PSP, skipping
checking libtimidity... not found
checking direct-music... not Windows, skipping
checking sort... sort
checking endianess... AUTO
suppress language errors... no
checking stripping... strip -s
checking distcc... no (only used when forced)
checking ccache... no (only used when forced)
checking OSX sysroot... not OSX, skipping
checking OSX application bundle... not OSX, skipping
checking revision... release (0.6.0)
personal home directory... .openttd
shared data directory... none
installation directory... /
using CFLAGS... -O2 -fomit-frame-pointer -DFREEBSD -Wall -Wno-multichar -Wsign-compare -Wundef -Wwrite-strings -Wpointer-arith -Wno-uninitialized -W -Wno-unused-parameter -fno-strict-aliasing -fno-strict-overflow -DUNIX -DWITH_SDL -I/usr/local/include/SDL -I/usr/local/include -D_GNU_SOURCE=1 -D_REENTRANT -DWITH_ZLIB -DWITH_PNG -I/usr/local/include/libpng -DWITH_FONTCONFIG -I/usr/local/include -DWITH_FREETYPE -I/usr/local/include/freetype2 -I/usr/local/include -DENABLE_NETWORK -DNDEBUG -DWITH_PERSONAL_DIR -DPERSONAL_DIR=".openttd" -DGLOBAL_DATA_DIR="/usr/local/share/games/openttd" -Wstrict-prototypes -Wdeclaration-after-statement -Wold-style-definition
using LDFLAGS... -lstdc++ -lc -lpthread -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lSDL -pthread -lz -L/usr/local/lib -lpng -lz -lm -L/usr/local/lib -lfontconfig -L/usr/local/lib -Wl,--rpath -Wl,/usr/local/lib -lfreetype -lz
Generating Makefile...
Generating lang/Makefile...
Generating objs/Makefile...



steve@zebedee 29 0 ~/openttd-0.6.0 % gmake
gmake[1]: Entering directory `/home/steve/openttd-0.6.0/objs/lang'
[LANG] Compiling and Linking endian_check
[LANG] Testing endianness for host
[LANG] Compiling core/alloc_func.cpp
[LANG] Compiling string.cpp
[LANG] Compiling strgen/strgen.cpp
[LANG] Compiling and Linking strgen
[LANG] Generating table/strings.h
[LANG] Compiling language afrikaans
[LANG] Compiling language brazilian_portuguese
[LANG] Compiling language bulgarian
[LANG] Compiling language catalan
[LANG] Compiling language croatian
[LANG] Compiling language czech
[LANG] Compiling language danish
[LANG] Compiling language dutch
[LANG] Compiling language english
[LANG] Compiling language english_US
[LANG] Compiling language esperanto
[LANG] Compiling language estonian
[LANG] Compiling language finnish
[LANG] Compiling language french
[LANG] Compiling language galician
[LANG] Compiling language german
[LANG] Compiling language hungarian
[LANG] Compiling language icelandic
[LANG] Compiling language italian
[LANG] Compiling language japanese
[LANG] Compiling language korean
[LANG] Compiling language lithuanian
[LANG] Compiling language norwegian_bokmal
[LANG] Compiling language norwegian_nynorsk
[LANG] Compiling language origveh
[LANG] Compiling language piglatin
[LANG] Compiling language polish
[LANG] Compiling language portuguese
[LANG] Compiling language romanian
[LANG] Compiling language russian
[LANG] Compiling language simplified_chinese
[LANG] Compiling language slovak
[LANG] Compiling language slovenian
[LANG] Compiling language spanish
[LANG] Compiling language swedish
[LANG] Compiling language traditional_chinese
[LANG] Compiling language turkish
[LANG] Compiling language ukrainian
gmake[1]: Leaving directory `/home/steve/openttd-0.6.0/objs/lang'
gmake[1]: Entering directory `/home/steve/openttd-0.6.0/objs/release'
[SRC] Compiling and Linking endian_check
[SRC] Testing endianness for target
[SRC] DEP CHECK (all files)
gmake[1]: Leaving directory `/home/steve/openttd-0.6.0/objs/release'
gmake[1]: Entering directory `/home/steve/openttd-0.6.0/objs/release'
[SRC] Compiling ai/ai.cpp
cc1plus: error: unrecognized command line option "-fno-strict-overflow"
gmake[1]: *** [ai/ai.o] Error 1
gmake[1]: Leaving directory `/home/steve/openttd-0.6.0/objs/release'
gmake: *** [all] Error 2
This task depends upon

Closed by  Remko Bijker (Rubidium)
Thursday, 24 April 2008, 20:06 GMT
Reason for closing:  Fixed
Additional comments about closing:  In r12876.
Comment by Zdeněk Sojka (SmatZ) - Monday, 14 April 2008, 00:41 GMT
As you have written:
please redefine the CC/CXX environment to a gcc binary
Comment by sroome (sroome) - Monday, 14 April 2008, 01:25 GMT
Both /usr/bin/gcc and /usr/local/bin/gcc42 were CC/CXX binaries.

gcc in /usr/bin is 3.4.6 (CC/CXX capable) and works for most other compilations.
gcc in /usr/local/bin (as gcc42) works for compilation as long as the one then edits the Makefiles and removes "-fno-strict-overflow"

This looks to me (sorry) like spurious over optimizing, it may be a fault with the configure script, but both gcc binaries are gcc binaries and should work fine, and were good enough to compile FreeBSD, xorg and a stack of audio apps. Does the -O2 even help at all in any real world scenarios - my laptop runs at 247MHz at only about 5% usage to run OpenTTD.

Or is this a necessary workaround to stop a cheeky memory leak somewhere ?
Comment by Zdeněk Sojka (SmatZ) - Monday, 14 April 2008, 01:33 GMT
Try
export CXX=/usr/local/bin/g++42

also, output of "which g++" might be interesting (since 0.6.0, OTTD uses C++ as the primary language)

-fno-strict-overflow is needed to stop overoptimising of g++ 4.2 (it uses -fstrict-overflow by default) - see "man g++" or google

-O2 helps; try to run a big map with many vehicles, your CPU will run at 100% soon (if you have a single-core CPU)
I would understand if you were surprised by -O3, but -O2 is normal optimisation level used in most of applications
Comment by sroome (sroome) - Monday, 14 April 2008, 01:56 GMT
steve@zebedee 10 0 ~/openttd-0.6.0 % CXX=/usr/bin/g++ 2:54
steve@zebedee 11 0 ~/openttd-0.6.0 % ./configure 2:54
checking awk... awk
checking build system type... gcc not found
I couldn't detect any gcc binary on your system
please define the CC/CXX environment to where it is located
steve@zebedee 12 1 ~/openttd-0.6.0 % export CXX 2:54
steve@zebedee 13 0 ~/openttd-0.6.0 % CC=/usr/bin/cc 2:54
steve@zebedee 14 0 ~/openttd-0.6.0 % CXX -v 2:54
zsh: command not found: CXX
steve@zebedee 15 127 ~/openttd-0.6.0 % $CXX -v 2:54
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.4.6 [FreeBSD] 20060305
steve@zebedee 16 0 ~/openttd-0.6.0 % $CC -v 2:54
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.4.6 [FreeBSD] 20060305
steve@zebedee 17 0 ~/openttd-0.6.0 % ./configure 2:54
checking awk... awk
checking build system type... gcc not found
I couldn't detect any gcc binary on your system
please define the CC/CXX environment to where it is located
steve@zebedee 18 1 ~/openttd-0.6.0 % export CC 2:54
steve@zebedee 19 0 ~/openttd-0.6.0 % export CXX 2:54
steve@zebedee 20 0 ~/openttd-0.6.0 % ./configure 2:54
checking awk... awk
checking build system type... /usr/bin/cc unusable
the CC environment variable is set, but it doesn't seem to be a gcc binary
please redefine the CC/CXX environment to a gcc binary


Setting the environment variables (as I did last time) DOES NOT WORK WITH GCC/G++ 3.4.6

Comment by Jean-Francois Claeys (Belugas) - Monday, 14 April 2008, 02:00 GMT
Unfortunately, our FreeBSD expert dev (Tron) is no longer with us.
SO, can you try to find a way to fix it?
None of the devs are working with this OS.
Comment by Zdeněk Sojka (SmatZ) - Monday, 14 April 2008, 02:00 GMT
export CC=/usr/local/bin/gcc42
export CXX=/usr/local/bin/g++42

./configure

and?
Comment by sroome (sroome) - Monday, 14 April 2008, 02:06 GMT
Using 4.2 (I compiled and played this for an hour this morning before reverting to 0.5.3 due to the signal/semaphores changing and me not finding the options, so I KNOW that it works okay)

As mentioned, the configure script seems to be broken.

It compiles okay with 4.2 if I edit the makefile manually and remove -fno-strict-overflow. The game then compiles and runs fine.

It didn't crash due to any sorts of overflows in the hour I played it for, but I couldn't build a loop I could see with the semaphores and was too hungover to hunt through for the option to turn it back.

I'll create a new port for FreeBSD and include patches to make it build/install nice as 0.6.0 on FreeBSD by default if no-one else is doing it.

Will include link and patches back to here.
Comment by Zdeněk Sojka (SmatZ) - Monday, 14 April 2008, 09:14 GMT
You didn't
export CXX=/usr/local/bin/g++42
in any of the logs you pasted.

What you did was:
steve@zebedee 13 0 ~/openttd-0.6.0 % CC=/usr/bin/cc 2:54
steve@zebedee 10 0 ~/openttd-0.6.0 % CXX=/usr/bin/g++ 2:54
steve@zebedee 18 1 ~/openttd-0.6.0 % export CC 2:54
gcc version 3.4.6 [FreeBSD] 20060305
steve@zebedee 12 1 ~/openttd-0.6.0 % export CXX 2:54
gcc version 3.4.6 [FreeBSD] 20060305
steve@zebedee 20 0 ~/openttd-0.6.0 % ./configure 2:54

So I wonder how you "know you are using 4.2"

gcc 4.2 knows -fstrict-overflow - http://hpux.cs.utah.edu/hppd/hpux/Gnu/gcc-4.2.3/man.html - gcc 4.2.3 man page, showing -fstrict-overflow

Anyway, it would be nice to find why "/usr/bin/cc" is rejected, and if it was used by 0.5.3. config.log may help
Comment by Peter Nelson (peter1138) - Monday, 14 April 2008, 09:21 GMT
The problem is 'gcc -dumpversion' on FreeBSD does not output anything...

Can you please test the following diff? http://fuzzle.org/o/dumpversion.diff

Errrr, or maybe it's 'gcc -dumpmachine' which outputs nothing, so that diff will not help.
Comment by sroome (sroome) - Monday, 14 April 2008, 23:36 GMT
Sorry, works fine with both /usr/bin/g++ and /usr/local/bin/g++42.

IFF $CC is not set.

If CC is set, it breaks and won't build as the -fno-foo option works with the g++ binary but not the gcc binary.

Maybe this is my fault for reading the output from configure to say set the CC/CXX environment variables.

I hadn't seen the "obvious" idea of setting CXX exporting that one and unsetting CC. :(

Comment by sroome (sroome) - Monday, 14 April 2008, 23:47 GMT
Sorry, nope, it's fine with BOTH set, but it appears that using just the gcc front end will get past the configure as gcc -dumpwhatever outputs enough to show that it's a capable c++ compiler too but fails to support the same flags as the g++ frontend.

(though both compile c++ code fine!)

The problem is that set "A/B environment variables" implied to me, set one or the other. (or possibly both).

Setting just the first (CC) gets halfway just as effectively, setting CXX instead gets all the way, much better.

Sorry for confusion, if gcc/g++ ought to handle arguments differently that's a different matter.


As to FreeBSD default gcc 3.4.6/g++ 3.4.6

Well, it really just doesn't work with them afaict:

steve@zebedee 93 0 ~/openttd-0.6.0 % ./configure
checking awk... awk
checking build system type... gcc not found
I couldn't detect any gcc binary on your system
please define the CC/CXX environment to where it is located

steve@zebedee 94 1 ~/openttd-0.6.0 % echo $CC
/usr/bin/cc

steve@zebedee 96 127 ~/openttd-0.6.0 % echo $CXX
/usr/bin/g++

steve@zebedee 97 0 ~/openttd-0.6.0 % echo $CC
/usr/bin/cc

steve@zebedee 98 0 ~/openttd-0.6.0 % export CC

steve@zebedee 99 0 ~/openttd-0.6.0 % export CXX

steve@zebedee 100 0 ~/openttd-0.6.0 % ./configure
checking awk... awk
checking build system type... /usr/bin/cc unusable
the CC environment variable is set, but it doesn't seem to be a gcc binary
please redefine the CC/CXX environment to a gcc binary

steve@zebedee 101 1 ~/openttd-0.6.0 % echo $CC
/usr/bin/cc

steve@zebedee 102 0 ~/openttd-0.6.0 % $CC -v
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.4.6 [FreeBSD] 20060305

steve@zebedee 103 0 ~/openttd-0.6.0 % echo $CXX
/usr/bin/g++

steve@zebedee 104 0 ~/openttd-0.6.0 % $CXX -v
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.4.6 [FreeBSD] 20060305

Comment by Remko Bijker (Rubidium) - Tuesday, 22 April 2008, 20:52 GMT
Does the attached diff fix the issue for FreeBSD?

Loading...