2025-08-10 16:16 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0001097Spring engineGeneralpublic2008-10-16 17:39
ReporterAMDmi3 
Assigned ToAuswaschbar 
PrioritynormalSeveritytweakReproducibilityalways
StatusclosedResolutionfixed 
Product Version0.77b2+svn 
Target VersionFixed in Version0.77b4+svn 
Summary0001097: [PATCH] Bunch of compatibility tweaks
DescriptionHere's bunch of patches I've used to build spring 0.77b2 on FreeBSD. It would be good to merge them into the sourcetree, and I believe it will improve spring portability in general.

Summary of changes:
* TestCXXAcceptsVisibilityFlag.cmake has a test for whether gcc supports -fvisibility=hidden, but does not have test for -fvisibility=default. The latter is used as is in CMakeLists.txt, and this would fail on old gcc (in my case, legacy 6.x branch of FreeBSD which still uses gcc 3.4), so add support for VISIBILITY_DEFAULT to TestCXXAcceptsVisibilityFlag and fix CMakeLists.txt
* Add BEFORE keyword for spring internal include dirs in INCLUDE_DIRECTORIES here and there. Thus, build won't erroneously pick up some systemwide installed libraries (in by case that was luabind).
* Change malloc.h to stdlib.h, as the former is deprecated
* undef isnumber in rts/Lua/LuaUtils.h. Not sure why it is defined in my case though...
* Change library names to macros here and there. This way spring builds without need to specify additional library search paths (/usr/local/include in my case). cmake detects all libraries perfectly.
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files
  • patch file icon spring.patch (5,432 bytes) 2008-10-10 12:34 -
    --- CMakeLists.txt.orig	2008-10-09 23:25:29.000000000 +0400
    +++ CMakeLists.txt	2008-10-09 23:24:50.000000000 +0400
    @@ -55,6 +55,7 @@
     	INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
     
     	FIND_PACKAGE(Boost 1.34.0 COMPONENTS thread regex REQUIRED)
    +	INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
     endif (MINGW)
     
     ### Compiler flags and defines based on build type
    --- rts/CMakeLists.txt.orig	2008-10-09 23:13:40.000000000 +0400
    +++ rts/CMakeLists.txt	2008-10-09 23:16:17.000000000 +0400
    @@ -42,11 +42,11 @@
     
     	FIND_PACKAGE(Freetype REQUIRED)
     	INCLUDE_DIRECTORIES(${FREETYPE_INCLUDE_DIR})
    -	LIST(APPEND spring_libraries openal GL GLU ${DEVIL_LIBRARIES} X11 Xcursor ${GLEW_LIBRARIES} ${Boost_REGEX_LIBRARY} ${Boost_THREAD_LIBRARY})
    +	LIST(APPEND spring_libraries ${OPENAL_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${DEVIL_LIBRARIES} ${X11_X11_LIB} ${X11_Xcursor_LIB} ${GLEW_LIBRARIES} ${Boost_REGEX_LIBRARY} ${Boost_THREAD_LIBRARY})
     ENDIF (MINGW)
     
     ### libraries needed on all platforms
    -LIST(APPEND spring_libraries SDL vorbisfile vorbis ogg freetype)
    +LIST(APPEND spring_libraries ${SDL_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY} ${FREETYPE_LIBRARIES})
     
     ### build all libraries in lib (has its own CMakeLists.txt)
     ADD_SUBDIRECTORY(lib)
    @@ -56,7 +56,7 @@
     endif (USE_GML)
     
     ### include directories needed for compiling spring
    -INCLUDE_DIRECTORIES(lib/lua/include lib/luabind)
    +INCLUDE_DIRECTORIES(BEFORE lib/lua/include lib/luabind)
     
     ### all spring source directories
     ### each directorie which contains source has to be here
    --- rts/Game/GameServer.cpp.orig	2008-10-05 04:39:05.000000000 +0400
    +++ rts/Game/GameServer.cpp	2008-10-09 21:37:00.000000000 +0400
    @@ -15,7 +15,7 @@
     #if defined DEDICATED || defined DEBUG
     #include <iostream>
     #endif
    -#include <malloc.h>
    +#include <stdlib.h>
     
     #include "mmgr.h"
     
    --- rts/Lua/LuaUtils.h.orig	2008-07-16 02:42:48.000000000 +0400
    +++ rts/Lua/LuaUtils.h	2008-10-09 21:41:37.000000000 +0400
    @@ -14,6 +14,8 @@
     #include "LuaDefs.h"
     #include "Sim/Units/CommandAI/Command.h"
     
    +#undef isnumber
    +
     class LuaUtils {
     	public:
     		static int CopyData(lua_State* dst, lua_State* src, int count);
    --- rts/build/cmake/TestCXXAcceptsVisibilityFlag.cmake.orig	2008-09-18 23:31:26.000000000 +0400
    +++ rts/build/cmake/TestCXXAcceptsVisibilityFlag.cmake	2008-10-10 01:22:32.000000000 +0400
    @@ -19,6 +19,15 @@
     		SET(VISIBILITY_HIDDEN "")
     	ENDIF(HAS_VISIBILITY_HIDDEN AND NOT MINGW)
     ENDIF(NOT DEFINED VISIBILITY_HIDDEN)
    +
    +IF(NOT DEFINED VISIBILITY_DEFAULT)
    +	CHECK_CXX_ACCEPTS_FLAG(-fvisibility=default HAS_VISIBILITY_DEFAULT)
    +	IF(HAS_VISIBILITY_DEFAULT AND NOT MINGW)
    +		SET(VISIBILITY_DEFAULT "-fvisibility=default")
    +	ELSE(HAS_VISIBILITY_DEFAULT AND NOT MINGW)
    +		SET(VISIBILITY_DEFAULT "")
    +	ENDIF(HAS_VISIBILITY_DEFAULT AND NOT MINGW)
    +ENDIF(NOT DEFINED VISIBILITY_DEFAULT)
     	
     IF(NOT DEFINED VISIBILITY_INLINES_HIDDEN)
     	CHECK_CXX_ACCEPTS_FLAG(-fvisibility-inlines-hidden HAS_VISIBILITY_INLINES_HIDDEN)
    --- rts/lib/CMakeLists.txt.orig	2008-09-18 23:31:26.000000000 +0400
    +++ rts/lib/CMakeLists.txt	2008-10-09 21:31:06.000000000 +0400
    @@ -1,4 +1,4 @@
    -INCLUDE_DIRECTORIES(streflop lua/include luabind ${CMAKE_SOURCE_DIR}/rts/System)
    +INCLUDE_DIRECTORIES(BEFORE streflop lua/include luabind ${CMAKE_SOURCE_DIR}/rts/System)
     
     ADD_DEFINITIONS(${PIC_FLAG}) # all libraries need to be position independent (gives compiler warnings on 64bit-linux
     
    @@ -36,4 +36,4 @@
     ENDIF (UNIX)
     TARGET_LINK_LIBRARIES(minizip z)
     
    -ADD_SUBDIRECTORY(streflop)
    \ No newline at end of file
    +ADD_SUBDIRECTORY(streflop)
    --- tools/DedicatedServer/CMakeLists.txt.orig	2008-10-08 19:59:52.000000000 +0400
    +++ tools/DedicatedServer/CMakeLists.txt	2008-10-10 01:23:52.000000000 +0400
    @@ -50,12 +50,12 @@
     	../../rts/Lua/LuaUtils
     	../../rts/Map/MapParser
     	../../rts/Rendering/Textures/TAPalette)
    -TARGET_LINK_LIBRARIES(springserver SDL hpiutil2 7zip minizip lua)
    +TARGET_LINK_LIBRARIES(springserver ${SDL_LIBRARY} hpiutil2 7zip minizip lua)
     if (MINGW)
     	TARGET_LINK_LIBRARIES (springserver ws2_32 boost_thread-mt boost_regex-mt)
     else (MINGW)
     	TARGET_LINK_LIBRARIES (springserver ${Boost_REGEX_LIBRARY} ${Boost_THREAD_LIBRARY})
    -	ADD_DEFINITIONS (-fvisibility=default ) #overwrite hidden visibility
    +	ADD_DEFINITIONS (${VISIBILITY_DEFAULT}) #overwrite hidden visibility
     endif (MINGW)
     
     ADD_EXECUTABLE(spring-dedicated main)
    --- tools/unitsync/CMakeLists.txt.orig	2008-09-29 15:44:44.000000000 +0400
    +++ tools/unitsync/CMakeLists.txt	2008-10-09 23:53:57.000000000 +0400
    @@ -12,7 +12,7 @@
     	
     	FIND_PACKAGE(GLEW REQUIRED)
     	
    -	set (unitsync_libs ${GLEW_LIBRARIES} IL openal GL GLU)
    +	set (unitsync_libs ${GLEW_LIBRARIES} ${DEVIL_IL_LIBRARY} ${OPENAL_LIBRARY} ${GL_gl_LIBRARY} ${GL_glu_LIBRARY})
     	list (APPEND unitsync_libs util) # sometimes this is needed (and I have no clue why)
     	
     	FIND_PACKAGE(PythonLibs)
    @@ -73,7 +73,7 @@
     	list(APPEND unitsync_files javabind)
     endif (JAVA_FOUND)
     ADD_LIBRARY(unitsync SHARED ${platformfiles} ${unitsync_files} ${fsfiles} unitsync LuaParserAPI Syncer SyncServer stdafx)
    -TARGET_LINK_LIBRARIES(unitsync ${unitsync_libs} hpiutil2 7zip minizip lua boost_regex-mt ILU SDL)
    +TARGET_LINK_LIBRARIES(unitsync ${unitsync_libs} hpiutil2 7zip minizip lua ${BOOST_regex_LIBRARY} ${DEVIL_ILU_LIBRARY} ${SDL_LIBRARY})
     if (PYTHONLIBS_FOUND)
     	TARGET_LINK_LIBRARIES(unitsync ${PYTHON_LIBRARIES})
     endif (PYTHONLIBS_FOUND)
    
    patch file icon spring.patch (5,432 bytes) 2008-10-10 12:34 +
  • patch file icon spring.1.patch (1,540 bytes) 2008-10-12 15:58 -
    Index: tools/unitsync/CMakeLists.txt
    ===================================================================
    --- tools/unitsync/CMakeLists.txt	(revision 6681)
    +++ tools/unitsync/CMakeLists.txt	(working copy)
    @@ -70,7 +70,7 @@
     	list(APPEND unitsync_files javabind)
     endif (JAVA_FOUND)
     ADD_LIBRARY(unitsync SHARED ${platformfiles} ${unitsync_files} ${fsfiles} unitsync LuaParserAPI Syncer SyncServer stdafx)
    -TARGET_LINK_LIBRARIES(unitsync ${unitsync_libs} hpiutil2 7zip minizip lua boost_regex-mt ILU ${SDL_LIBRARY})
    +TARGET_LINK_LIBRARIES(unitsync ${unitsync_libs} hpiutil2 7zip minizip lua ${Boost_regex_LIBRARY} ${IL_ILU_LIBRARY} ${SDL_LIBRARY})
     if (PYTHONLIBS_FOUND)
     	TARGET_LINK_LIBRARIES(unitsync ${PYTHON_LIBRARIES})
     endif (PYTHONLIBS_FOUND)
    Index: rts/Lua/LuaUtils.h
    ===================================================================
    --- rts/Lua/LuaUtils.h	(revision 6681)
    +++ rts/Lua/LuaUtils.h	(working copy)
    @@ -14,6 +14,10 @@
     #include "LuaDefs.h"
     #include "Sim/Units/CommandAI/Command.h"
     
    +#ifdef isnumber
    +#undef isnumber
    +#endif
    +
     class LuaUtils {
     	public:
     		static int CopyData(lua_State* dst, lua_State* src, int count);
    Index: CMakeLists.txt
    ===================================================================
    --- CMakeLists.txt	(revision 6681)
    +++ CMakeLists.txt	(working copy)
    @@ -58,6 +58,7 @@
     	INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
     
     	FIND_PACKAGE(Boost 1.34.0 COMPONENTS thread regex REQUIRED)
    +	INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
     endif (MINGW)
     
     ### Compiler flags and defines based on build type
    
    patch file icon spring.1.patch (1,540 bytes) 2008-10-12 15:58 +
  • patch file icon spring.2.patch (2,302 bytes) 2008-10-15 17:16 -
    Index: tools/DedicatedServer/CMakeLists.txt
    ===================================================================
    --- tools/DedicatedServer/CMakeLists.txt	(revision 6752)
    +++ tools/DedicatedServer/CMakeLists.txt	(working copy)
    @@ -54,7 +54,7 @@
     if (MINGW)
     	TARGET_LINK_LIBRARIES (springserver ws2_32)
     else (MINGW)
    -	ADD_DEFINITIONS (-fvisibility=default ) #overwrite hidden visibility
    +	ADD_DEFINITIONS (${VISIBILITY_DEFAULT}) #overwrite hidden visibility
     endif (MINGW)
     
     ADD_EXECUTABLE(spring-dedicated main)
    Index: rts/Lua/LuaUtils.h
    ===================================================================
    --- rts/Lua/LuaUtils.h	(revision 6752)
    +++ rts/Lua/LuaUtils.h	(working copy)
    @@ -14,6 +14,10 @@
     #include "LuaDefs.h"
     #include "Sim/Units/CommandAI/Command.h"
     
    +#ifdef isnumber
    +#undef isnumber
    +#endif
    +
     class LuaUtils {
     	public:
     		static int CopyData(lua_State* dst, lua_State* src, int count);
    Index: rts/build/cmake/TestCXXAcceptsVisibilityFlag.cmake
    ===================================================================
    --- rts/build/cmake/TestCXXAcceptsVisibilityFlag.cmake	(revision 6752)
    +++ rts/build/cmake/TestCXXAcceptsVisibilityFlag.cmake	(working copy)
    @@ -19,6 +19,15 @@
     		SET(VISIBILITY_HIDDEN "")
     	ENDIF(HAS_VISIBILITY_HIDDEN AND NOT MINGW)
     ENDIF(NOT DEFINED VISIBILITY_HIDDEN)
    +
    +IF(NOT DEFINED VISIBILITY_DEFAULT)
    +	CHECK_CXX_ACCEPTS_FLAG(-fvisibility=default HAS_VISIBILITY_DEFAULT)
    +	IF(HAS_VISIBILITY_DEFAULT AND NOT MINGW)
    +		SET(VISIBILITY_DEFAULT "-fvisibility=default")
    +	ELSE(HAS_VISIBILITY_DEFAULT AND NOT MINGW)
    +		SET(VISIBILITY_DEFAULT "")
    +	ENDIF(HAS_VISIBILITY_DEFAULT AND NOT MINGW)
    +ENDIF(NOT DEFINED VISIBILITY_DEFAULT)
     	
     IF(NOT DEFINED VISIBILITY_INLINES_HIDDEN)
     	CHECK_CXX_ACCEPTS_FLAG(-fvisibility-inlines-hidden HAS_VISIBILITY_INLINES_HIDDEN)
    Index: rts/lib/CMakeLists.txt
    ===================================================================
    --- rts/lib/CMakeLists.txt	(revision 6752)
    +++ rts/lib/CMakeLists.txt	(working copy)
    @@ -1,4 +1,4 @@
    -INCLUDE_DIRECTORIES(streflop lua/include luabind ${CMAKE_SOURCE_DIR}/rts/System)
    +INCLUDE_DIRECTORIES(BEFORE streflop lua/include luabind ${CMAKE_SOURCE_DIR}/rts/System)
     
     ADD_DEFINITIONS(${PIC_FLAG}) # all libraries need to be position independent (gives compiler warnings on 64bit-linux
     
    
    patch file icon spring.2.patch (2,302 bytes) 2008-10-15 17:16 +

-Relationships
+Relationships

-Notes

~0002758

imbaczek (reporter)

patches really welcome, AFAIK no dev has FreeBSD to test spring on.

~0002760

AMDmi3 (reporter)

You can leave testing to me :)

~0002761

Kloot (developer)

beware regarding your first change though, Spring binaries compiled with gcc versions < 4.0 will not sync in multiplayer against the official builds so making compilation with it easier perhaps isn't a good idea (more potential ghost desync reports and such) :)

~0002762

AMDmi3 (reporter)

Then I think explicit check for gcc version or specific feature should be added to cmake and warning displayed.
In case of FreeBSD port, it can be made so Spring is always built with gcc42 (which is build from ports too if not present in base system), so FreeBSD-wise this is not a problem.

~0002799

Auswaschbar (reporter)

Applied most of the stuff, along with some modifications to not to break win32 build.

~0002814

AMDmi3 (reporter)

Some bits are still missing.

~0002815

AMDmi3 (reporter)

* tools/unitsync/CMakeLists.txt: libraries
* rts/Lua/LuaUtils.h: undef isnumber
* CMakeLists.txt: INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})

If the first issue breaks win32 build, I think IF(MINGW) should be used like in other places.

The second one is questionable, but on FreeBSD, isnumber is defined as a macro for some (I guess compatibility) reason, so it's safer to undef it.

The third one should be clear.

~0002925

AMDmi3 (reporter)

Those are the last bits, main thing is rts/lib/CMakeLists.txt.
Now used SVN to be sure not to miss anything.

~0002958

Auswaschbar (reporter)

Applied everything but the fvisibility=default, because of the reasons kloot gave.

~0002960

AMDmi3 (reporter)

Thanks a lot!

Though it seems illogical to me that there are checks for -fvisibility=hidden and -fvisibility-inlines-hidden (which seem to help building with gcc34), and still there's hardcoded -fvisibility=default just to break build on that very gcc34.
+Notes

-Issue History
Date Modified Username Field Change
2008-10-10 12:34 AMDmi3 New Issue
2008-10-10 12:34 AMDmi3 File Added: spring.patch
2008-10-10 14:18 imbaczek Note Added: 0002758
2008-10-10 14:26 AMDmi3 Note Added: 0002760
2008-10-10 14:30 Kloot Note Added: 0002761
2008-10-10 14:50 AMDmi3 Note Added: 0002762
2008-10-10 15:37 tvo Product Version => 0.77b2+svn
2008-10-10 15:37 tvo Summary Bunch of compatibility tweaks => [PATCH] Bunch of compatibility tweaks
2008-10-12 00:54 Auswaschbar Status new => resolved
2008-10-12 00:54 Auswaschbar Resolution open => fixed
2008-10-12 00:54 Auswaschbar Assigned To => Auswaschbar
2008-10-12 00:54 Auswaschbar Note Added: 0002799
2008-10-12 15:53 AMDmi3 Status resolved => feedback
2008-10-12 15:53 AMDmi3 Resolution fixed => reopened
2008-10-12 15:53 AMDmi3 Note Added: 0002814
2008-10-12 15:57 AMDmi3 Note Added: 0002815
2008-10-12 15:58 AMDmi3 File Added: spring.1.patch
2008-10-15 17:16 AMDmi3 Note Added: 0002925
2008-10-15 17:16 AMDmi3 File Added: spring.2.patch
2008-10-16 16:21 Auswaschbar Status feedback => resolved
2008-10-16 16:21 Auswaschbar Fixed in Version => 0.77b4+svn
2008-10-16 16:21 Auswaschbar Resolution reopened => fixed
2008-10-16 16:21 Auswaschbar Note Added: 0002958
2008-10-16 17:39 AMDmi3 Status resolved => closed
2008-10-16 17:39 AMDmi3 Note Added: 0002960
+Issue History