Compiled in Std Lib with MinGW


#1

Is it currently possible to build chaiscript with the std lib compiled in, with MinGW, at all?

I’m cross-compiling from linux, using GCC 4.9.2 in Ubuntu 15.04. But, from what I can tell, the exact same thing would happen on windows.

Basically, when I try to compile this file:

#include <chaiscript/chaiscript_stdlib.hpp>
#include "sqee/scripts/chaiscript.hpp"

using namespace sq;

chai::ChaiScript* sq::make_ChaiScript() {
    return new chai::ChaiScript(chai::Std_Lib::library());
}

I get this error:

[ 21%] Building CXX object CMakeFiles/sqee.dir/src/sqee/scripts/chaiscript.cpp.obj
/usr/bin/x86_64-w64-mingw32-as: CMakeFiles/sqee.dir/src/sqee/scripts/chaiscript.cpp.obj: too many sections (114827)
/tmp/ccmzPqfU.s: Assembler messages:
/tmp/ccmzPqfU.s: Fatal error: can't write CMakeFiles/sqee.dir/src/sqee/scripts/chaiscript.cpp.obj: File too big
/usr/bin/x86_64-w64-mingw32-as: CMakeFiles/sqee.dir/src/sqee/scripts/chaiscript.cpp.obj: too many sections (114827)
/tmp/ccmzPqfU.s: Fatal error: can't close CMakeFiles/sqee.dir/src/sqee/scripts/chaiscript.cpp.obj: File too big
CMakeFiles/sqee.dir/build.make:319: recipe for target 'CMakeFiles/sqee.dir/src/sqee/scripts/chaiscript.cpp.obj' failed
make[2]: *** [CMakeFiles/sqee.dir/src/sqee/scripts/chaiscript.cpp.obj] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/sqee.dir/all' failed
make[1]: *** [CMakeFiles/sqee.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2

If I add -Wa,-mbig-obj to CMAKE_CXX_FLAGS, then I get this error:

/usr/bin/x86_64-w64-mingw32-as: CMakeFiles/sqee.dir/src/sqee/scripts/chaiscript.cpp.obj: section .text$_ZNKSt8functionIFSsaEEclEa: string table overflow at offset 10000001
/tmp/ccwiEZuc.s: Assembler messages:
/tmp/ccwiEZuc.s: Fatal error: can't close CMakeFiles/sqee.dir/src/sqee/scripts/chaiscript.cpp.obj: File too big
CMakeFiles/sqee.dir/build.make:319: recipe for target 'CMakeFiles/sqee.dir/src/sqee/scripts/chaiscript.cpp.obj' failed
make[2]: *** [CMakeFiles/sqee.dir/src/sqee/scripts/chaiscript.cpp.obj] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/sqee.dir/all' failed
make[1]: *** [CMakeFiles/sqee.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2

Has anyone tried doing this (compiling in std lib) with MinGW?


#2

There is one other user who got that setup working: Cross-compiling for windows from Linux

I believe the piece you are missing is that you have to compile with “-O3” if you want it to finish linking.

Also, if you try using the current ‘develop’ branch instead of the last release you might have more luck. I did some changes that reduce the number of templates being instantiated.


#3

Sweet. Compiling with -O3 (or -O2) works.

Also, that “other user” was me :smile:. And the threading works well now using MinGW-w64 with GCC 4.9.2.


#4

Oh sorry about that! Right, yes, you have to enable optimizations. It seems to be a bug in mingw.

I need to set up a mingw target on my CI system.