Errors compiling 0.4 on OpenBSD

For all the help you need with Armagetron!
User avatar
Z-Man
God & Project Admin
Posts: 11238
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne, Jabber: [email protected]
Contact:

Re: Errors compiling 0.4 on OpenBSD

Post by Z-Man »

Usually, if a program compiles fine against library headers and then linking fails, it means that the installation or include/link resolution is borked, like it's loading headers from a custom /usr/local/include installation, but trying to link to the outdated prebuilt libs in /usr/libs. Your locate output falsifies that possibility.
The next one down the line is: The library was built with a different compiler, and sadly, C++ does not reliably support linking between different compilers/compiler versions. You still have to use a version of gcc that's not canonically included with OpenBSD, right?
In that case, the solution would need to be to manually build protobuf with the same compiler.

Monkey
Match Winner
Posts: 725
Joined: Thu May 22, 2008 12:36 am
Location: England, UK

Re: Errors compiling 0.4 on OpenBSD

Post by Monkey »

Thanks Z-Man, I think you might be right on the money here. OpenBSD recently switched it's compiler for compiling the ports/packages (and the base system too FYI) from GCC/g++ to Clang/LLVM. I compile Arma using GCC/g++ (not the one in the base system but a newer one from the ports/packages repository). Protobuf is compiled using Clang/LLVM. Therein lies the problem.

I'm going to try to compile Arma using Clang/LLVM as the other way round (trying to compile everything with GCC/g++) has, believe it or not, far too many hurdles.
Playing since December 2006

Monkey
Match Winner
Posts: 725
Joined: Thu May 22, 2008 12:36 am
Location: England, UK

Re: Errors compiling 0.4 on OpenBSD

Post by Monkey »

Arma compiles fine with Clang/LLVM :P
Ok, so Arma now does crash every time I enter a server but it was doing that before...well, at least kinda doing that. I'll play around with Clang/LLVM some more and see what happens. My tests were with Clang/LLVM 4. Version 5 is in ports/packages...I'll have a play with that too.
Playing since December 2006

Monkey
Match Winner
Posts: 725
Joined: Thu May 22, 2008 12:36 am
Location: England, UK

Re: Errors compiling 0.4 on OpenBSD

Post by Monkey »

It's been almost 2 years since I last tried to build/play 0.4 and both LLVM/Clang and OpenBSD have moved on a lot. So, I'm trying to compile it again but I'm having some errors; details are as follows:

Configure output:

Code: Select all

checking build system type... x86_64-unknown-openbsd6.5
checking host system type... x86_64-unknown-openbsd6.5
checking target system type... x86_64-unknown-openbsd6.5
checking for ranlib... ranlib
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether UID '0' is supported by ustar format... yes
checking whether GID '0' is supported by ustar format... yes
checking how to create a ustar tar archive... plaintar
checking whether ln -s works... yes
checking for bison... bison -y
checking bison version... bison (GNU Bison) 3.3.2
checking for m4... true
checking whether make supports the include directive... yes (GNU style)
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether /usr/bin/clang++ accepts -g... yes
checking dependency style of /usr/bin/clang++... gcc3
checking CXXFLAGS for gcc -std=c++11... -std=c++11
checking for gcc... /usr/bin/clang
checking whether we are using the GNU C compiler... yes
checking whether /usr/bin/clang accepts -g... yes
checking for /usr/bin/clang option to accept ISO C89... none needed
checking whether /usr/bin/clang understands -c and -o together... yes
checking dependency style of /usr/bin/clang... gcc3
checking how to run the C preprocessor... /usr/bin/clang-cpp
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether /usr/bin/clang++ accepts -g... (cached) yes
checking dependency style of /usr/bin/clang++... (cached) gcc3
checking how to run the C++ preprocessor... /usr/bin/clang-cpp
checking for gmake... yes
checking for bash... yes
checking for boostlib >= 1.33.1... yes
checking whether make understands sinclude... yes
checking for socklen_t... yes
checking for X... libraries /usr/X11R6/lib, headers /usr/X11R6/include
checking whether -R must be followed by a space... neither works
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... yes
checking for xmlParseMemory in -lxml2... yes
checking for xmlParserInputBufferCreateFilenameDefault... yes
checking for _ZN5boost6system15system_categoryEv in -lboost_system... yes
checking for _ZN5boost11this_thread5yieldEv in -lboost_thread... no
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for sys/stat.h... (cached) yes
checking for protoc... /usr/local/bin/protoc
checking for _ZN6google8protobuf7MessageD2Ev in -lprotobuf... no
checking for _ZN6google8protobuf7ClosureD2Ev in -lprotobuf... yes
configure: WARNING: The library protobuf (Google Protobuf Buffers) has a broken dependency on library pthread on your system.
checking google/protobuf/message.h usability... yes
checking google/protobuf/message.h presence... yes
checking for google/protobuf/message.h... yes
checking time.h usability... yes
checking time.h presence... yes
checking for time.h... yes
checking for clock_gettime in -lrt... no
checking for exp in -lm... yes
checking whether SDL2 is installed... yes
checking for SDL_GL_SetAttribute... yes
checking for Mix_OpenAudio in -lSDL2_mixer... yes
checking for XOpenDisplay in -lX11... yes
checking for glVertex3f in -lGL... yes
checking for gluBuild3DMipmaps in -lGLU... yes
checking for glewInit in -lGLEW... yes
checking GL/glew.h usability... yes
checking GL/glew.h presence... yes
checking for GL/glew.h... yes
checking whether libpng is installed... yes
checking for png_sig_cmp... yes
checking for ftglRenderGlyph in -lftgl... yes
checking for FT_Init_FreeType in -lfreetype... yes
checking whether FTGLPixmapFont.h is deprecated... yes
checking FTGL/ftgl.h usability... yes
checking FTGL/ftgl.h presence... yes
checking for FTGL/ftgl.h... yes
checking for IMG_Load in -lSDL2_image... yes
checking SDL_image.h usability... yes
checking SDL_image.h presence... yes
checking for SDL_image.h... yes
checking for ANSI C header files... (cached) yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking for select... yes
checking for atan2f... yes
checking for sinf... yes
checking for cosf... yes
checking for tanf... yes
checking for sqrtf... yes
checking for logf... yes
checking for expf... yes
checking for fabsf... yes
checking for floorf... yes
checking for pow10... no
checking for pow10f... no
checking for wmemset... yes
checking whether binary relocation support should be enabled... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating src/Makefile
config.status: creating src/protobuf/Makefile
config.status: creating src/first/Makefile
config.status: creating Makefile
config.status: creating batch/Makefile
config.status: creating language/languages.txt
config.status: creating config/rc.config
config.status: creating config/aiplayers.cfg
config.status: creating src/doc/Makefile
config.status: creating src/doc/net/Makefile
config.status: creating src/doc/Doxyfile
config.status: creating src/doc/html.m4
config.status: creating src/thirdparty/Makefile
config.status: creating src/thirdparty/particles/Makefile
config.status: creating src/thirdparty/mathexpr/Makefile
config.status: creating src/thirdparty/scrap/Makefile
config.status: creating src/swig/Makefile
config.status: creating resource/Makefile
config.status: creating config/Makefile
config.status: creating desktop/Makefile
config.status: creating www-root/Makefile
config.status: creating desktop/armagetronad-armagetronad.desktop
config.status: creating desktop/armagetronad-armagetronad-handler.desktop
config.status: creating desktop/armagetronad-link.xml
config.status: creating desktop/armagetronad.protocol
config.status: creating desktop/os-x/Info.plist
config.status: creating aa_config.h
config.status: aa_config.h is unchanged
config.status: executing depfiles commands
config.status: executing universal_variables commands
config.status: executing pathsubstitution commands
Configuration complete!

Options selected are:
     Build Regular Game Client: true
     Build Dedicated Server: false
     Build Master Server: false

Installation options:
     Prefix: /usr/local

     Sound support: yes
     Particle System support: no
     Joystick support: yes
     Zones support: Basic, Fortress

     Binaries will be installed in      : ${prefix}/bin
     Static data will be installed in   : ${prefix}/share/armagetronad
     Configuration will be installed in : ${prefix}/etc/armagetronad
     Build with Krawall authentication support: no
     Ruby support: no
     Call sysinstall: no
     Generate uninstall: no
     Allow multiple versions: no
     Use custom memory manager: no
     Debug level : 0
     Code level  : 0
     CPPFLAGS    :  -I/usr/local/include/libxml2 -I/usr/local/include -I/usr/local/include -I/usr/local/include/SDL2 -I/usr/X11R6/include -D_REENTRANT -I/usr/X11R6/include -I/usr/local/include/libpng16 -I/usr/local/include -I/usr/local/include/FTGL -I/usr/X11R6/include/freetype2 -I/usr/X11R6/include/freetype2
     CXXFLAGS    : -O2 -std=c++11  -I/usr/X11R6/include 
     LIBS        : -lSDL2_image -lGLEW -lGLU -lGL -lX11 -L/usr/X11R6/lib -lSDL2_mixer -L/usr/local/lib -lSDL2 -L/usr/X11R6/lib -lm -lprotobuf -lpthread  -lboost_system -L/usr/local/lib -lxml2 -lz -L/usr/local/lib -llzma -lpthread -L/usr/local/lib -liconv -lm  -L/usr/X11R6/lib  -lpng -L/usr/local/lib -lftgl -L/usr/X11R6/lib -lfreetype -lz
Gmake output:

Code: Select all

(CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /root/armagetronad/0.4/missing autoheader)
rm -f stamp-h1
touch aa_config.h.in
cd . && /bin/sh ./config.status aa_config.h
config.status: creating aa_config.h
config.status: aa_config.h is unchanged
gmake  all-recursive
gmake[1]: Entering directory '/root/armagetronad/0.4'
Making all in src
gmake[2]: Entering directory '/root/armagetronad/0.4/src'
Making all in first
gmake[3]: Entering directory '/root/armagetronad/0.4/src/first'
gmake[3]: Nothing to be done for 'all'.
gmake[3]: Leaving directory '/root/armagetronad/0.4/src/first'
Making all in protobuf
gmake[3]: Entering directory '/root/armagetronad/0.4/src/protobuf'
/usr/bin/clang++ -DHAVE_CONFIG_H -I. -I../..   -I/usr/local/include/libxml2 -I/usr/local/include -I/usr/local/include -I/usr/local/include/SDL2 -I/usr/X11R6/include -D_REENTRANT -I/usr/X11R6/include -I/usr/local/include/libpng16 -I/usr/local/include -I/usr/local/include/FTGL -I/usr/X11R6/include/freetype2 -I/usr/X11R6/include/freetype2  -I. -I./ -O2 -std=c++11  -I/usr/X11R6/include  -MT libprotobuf_a-tColor.pb.o -MD -MP -MF .deps/libprotobuf_a-tColor.pb.Tpo -c -o libprotobuf_a-tColor.pb.o `test -f 'tColor.pb.cc' || echo './'`tColor.pb.cc
In file included from tColor.pb.cc:4:
In file included from ./tColor.pb.h:7:
In file included from /usr/include/c++/v1/string:505:
In file included from /usr/include/c++/v1/string_view:176:
In file included from /usr/include/c++/v1/__string:57:
In file included from /usr/include/c++/v1/algorithm:640:
In file included from /usr/include/c++/v1/initializer_list:47:
In file included from /usr/include/c++/v1/cstddef:38:
../../version:1:1: error: C++ requires a type specifier for all declarations
m4_define(AUTOMATIC_VERSION,[0.4_alpha_z4111])
^
../../version:1:11: error: use of undeclared identifier 'AUTOMATIC_VERSION'
m4_define(AUTOMATIC_VERSION,[0.4_alpha_z4111])
          ^
../../version:1:30: error: expected variable name or 'this' in lambda capture list
m4_define(AUTOMATIC_VERSION,[0.4_alpha_z4111])
                             ^
tColor.pb.cc:895:2: error: expected ';' after top level declarator
}  // namespace google
 ^
 ;
4 errors generated.
gmake[3]: *** [Makefile:538: libprotobuf_a-tColor.pb.o] Error 1
gmake[3]: Leaving directory '/root/armagetronad/0.4/src/protobuf'
gmake[2]: *** [Makefile:4317: all-recursive] Error 1
gmake[2]: Leaving directory '/root/armagetronad/0.4/src'
gmake[1]: *** [Makefile:768: all-recursive] Error 1
gmake[1]: Leaving directory '/root/armagetronad/0.4'
gmake: *** [Makefile:560: all] Error 2
Contents of the file "Version":

Code: Select all

m4_define(AUTOMATIC_VERSION,[0.4_alpha_z4111])
Any help is appreciated, as per usual :)
Playing since December 2006

User avatar
Z-Man
God & Project Admin
Posts: 11238
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne, Jabber: [email protected]
Contact:

Re: Errors compiling 0.4 on OpenBSD

Post by Z-Man »

THAT version file isn't supposed to be included! Can you look for a line containing '#include' and 'version' in /usr/include/c++/v1/cstddef and post its surroundings? I'd like to know how this happens.

To work around the problem, you could try moving the version file out of the way after running configure, though I have not tested how the rest of the build system would react.

Monkey
Match Winner
Posts: 725
Joined: Thu May 22, 2008 12:36 am
Location: England, UK

Re: Errors compiling 0.4 on OpenBSD

Post by Monkey »

It's only a small file, here's all of it:

Code: Select all

// -*- C++ -*-
//===--------------------------- cstddef ----------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP_CSTDDEF
#define _LIBCPP_CSTDDEF

/*
    cstddef synopsis

Macros:

    offsetof(type,member-designator)
    NULL

namespace std
{

Types:

    ptrdiff_t
    size_t
    max_align_t
    nullptr_t
    byte // C++17

}  // std

*/

#include <__config>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif

// Don't include our own <stddef.h>; we don't want to declare ::nullptr_t.
#include_next <stddef.h>
#include <__nullptr>

_LIBCPP_BEGIN_NAMESPACE_STD

using ::ptrdiff_t;
using ::size_t;

#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
    defined(__DEFINED_max_align_t) || defined(__NetBSD__)
// Re-use the compiler's <stddef.h> max_align_t where possible.
using ::max_align_t;
#else
typedef long double max_align_t;
#endif

_LIBCPP_END_NAMESPACE_STD

#if _LIBCPP_STD_VER > 14
namespace std  // purposefully not versioned
{
enum class byte : unsigned char {};

constexpr byte  operator| (byte  __lhs, byte __rhs) noexcept
{
    return static_cast<byte>(
      static_cast<unsigned char>(
         static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs)
    ));
}

constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
{ return __lhs = __lhs | __rhs; }

constexpr byte  operator& (byte  __lhs, byte __rhs) noexcept
{
    return static_cast<byte>(
      static_cast<unsigned char>(
         static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs)
    ));
}

constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept
{ return __lhs = __lhs & __rhs; }

constexpr byte  operator^ (byte  __lhs, byte __rhs) noexcept
{
    return static_cast<byte>(
      static_cast<unsigned char>(
         static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs)
    ));
}

constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept
{ return __lhs = __lhs ^ __rhs; }

constexpr byte  operator~ (byte __b) noexcept
{
    return static_cast<byte>(
      static_cast<unsigned char>(
        ~static_cast<unsigned int>(__b)
    ));
}

}

#include <type_traits>  // rest of byte
#endif

#endif  // _LIBCPP_CSTDDEF
Moving/removing the "version" file makes configure automatically get re-run.
By the way, LLVM/Clang is supposed to be a drop in replacement for GCC.
Playing since December 2006

User avatar
Z-Man
God & Project Admin
Posts: 11238
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne, Jabber: [email protected]
Contact:

Re: Errors compiling 0.4 on OpenBSD

Post by Z-Man »

"Supposed to", yeah :)
The problem here is the "-I../../" command line argument to the compiler. In the olden days, you'd say
gcc -IA -I- -IB
and if there is a #include "bla" in the source, it would look both in A and B, but a #include <bla> would only look in B. We don't have a -I- in there at all, so it #include <version> should not look in ../../ and not find our version source. Obviously, your clang thinks otherwise.
Those arguments that change meaning depending on which side of another argument they are were obviously terrible and are now deprecated in favor of -iquote and -isystem, so replacing the -I../../ here with -iquote../../ would be the right solution.

TROULBE IS, i don't know how to change it. It's something added by automake, DEFAULT_INCLUDES is the name of the variable it puts them in in Makefile.in.
That's as far as I'm going to get today, and I don't know how much computer time I'll have in the coming four weeks, so if anyone else is in the mood for some automake hacking, be my guest.

Monkey
Match Winner
Posts: 725
Joined: Thu May 22, 2008 12:36 am
Location: England, UK

Re: Errors compiling 0.4 on OpenBSD

Post by Monkey »

Thanks for looking into it Z-Man, I'll be away for three weeks as of Sunday anyway. :)

Here is some interesting information though:

0.2.8 does the same thing when I try to build it from source, however the OpenBSD ports system (which builds from source too) builds 0.2.8 perfectly fine. OK, the program crashes as it did several years ago for me but still it builds. This ports system seems to use the same tools and Armagetronad source code to build it too *and* it uses Clang for all of the compilation! I'll try to have a look at what they've done to get this to work.
Playing since December 2006

User avatar
Z-Man
God & Project Admin
Posts: 11238
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne, Jabber: [email protected]
Contact:

Re: Errors compiling 0.4 on OpenBSD

Post by Z-Man »

Nah, it's working as intended after all. Without -I-, all includes are supposed to be system includes.

There's a solution suggestion here, just add -I- in a place where the automake additions get added before it:
https://github.com/nickg/nvc/issues/5
Sadly, it completely breaks C++ compilation on Ubuntu 2016; the reason is unclear. Seems that #include "..." normally also looks into the directory the current source file resides in, but the mere presence of -I- turns that off. At least with our combinations of other flags.

So now I just renamed 'version' to 'version.m4'. Considering it contains m4 code, that's the better name anyway. For me, clang compilation now works.

Monkey
Match Winner
Posts: 725
Joined: Thu May 22, 2008 12:36 am
Location: England, UK

Re: Errors compiling 0.4 on OpenBSD

Post by Monkey »

So, it's been 8 months and Stereo says that there has been some changes to 0.4 since then. I'm getting the following error now when compiling:

Code: Select all

mathexpr.cpp:1043:6: error: use of undeclared identifier 'exp10'
        *p*=exp10(*(p+1));}
            ^
1 error generated.
gmake[4]: *** [Makefile:449: libmathexpr_a-mathexpr.o] Error 1
gmake[3]: *** [Makefile:415: all-recursive] Error 1
gmake[2]: *** [Makefile:4333: all-recursive] Error 1
gmake[1]: *** [Makefile:769: all-recursive] Error 1
gmake: *** [Makefile:561: all] Error 2
I've noticed something about this in the bzr log so I'm hoping it's a simple fix.
Any help appreciated as always :)

By the way, I have contacted the OpenBSD maintainer for Arma about the crashing and possible threading issues that I've been having.
They happen on 0.2.8 as well as 0.4.
Playing since December 2006

User avatar
Z-Man
God & Project Admin
Posts: 11238
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne, Jabber: [email protected]
Contact:

Re: Errors compiling 0.4 on OpenBSD

Post by Z-Man »

This one?
I suppose we can generalize it with a configure check instead of just disabling it on windows, or just use pow(10,...) all of the time, or maybe just test for _GNU_SOURCE right there, as that seems to be the macro making exp10 available on Linux.

Monkey
Match Winner
Posts: 725
Joined: Thu May 22, 2008 12:36 am
Location: England, UK

Re: Errors compiling 0.4 on OpenBSD

Post by Monkey »

So, it is a simple fix for now. There is only one case of exp10 in the Arma 0.4 source code. I replaced it with pow(10,*) and Arma 0.4 now compiles and runs, despite, of course, crashing every time I start game play. I'm sure, as you concluded too, it's a threading issue. The errors I get (found using GDB) are all thread-related.
Playing since December 2006

Post Reply