Compiling chaiscript using MSYS2/MINGW Windows


#1

Hello, I tried to include the chaiscript headers and compile my project but I’m getting “file too big” error.

Then I built the chaiscript stl with compiler warnings that I want to share with you:

C:\Users\Dani\dev\wspace\ChaiScript-5.7.1\build>mingw32-make
Scanning dependencies of target chaiscript_stdlib-5.7.1
[ 33%] Building CXX object CMakeFiles/chaiscript_stdlib-5.7.1.dir/src/chaiscript_stdlib.cpp.obj
In function ‘typename chaiscript::detail::Cast_Helper::Result_Type chaiscript::boxed_cast(const chaiscript::Boxed_Value&, const chaiscrip
t::Type_Conversions*) [with Type = const chaiscript::Boxed_Value&; typename chaiscript::detail::Cast_Helper::Result_Type = const chaiscri
pt::Boxed_Value&]’:
cc1plus.exe: warning: function may return address of local variable [-Wreturn-local-addr]
In file included from C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/dispatchkit/dispatchkit.hpp:26:0,
from C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/chaiscript_stdlib.hpp:17,
from C:\Users\Dani\dev\wspace\ChaiScript-5.7.1\src\chaiscript_stdlib.cpp:2:
C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/dispatchkit/boxed_cast.hpp:88:47: note: declared here
return detail::Cast_Helper::cast(t_conversions->boxed_type_conversion(bv), t_conversions);
^
cc1plus.exe: warning: function may return address of local variable [-Wreturn-local-addr]
C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/dispatchkit/boxed_cast.hpp:93:49: note: declared here
return detail::Cast_Helper::cast(t_conversions->boxed_type_down_conversion(bv), t_conversions);
^
In function ‘typename chaiscript::detail::Cast_Helper::Result_Type chaiscript::boxed_cast(const chaiscript::Boxed_Value&, const chaiscrip
t::Type_Conversions*) [with Type = chaiscript::Boxed_Value; typename chaiscript::detail::Cast_Helper::Result_Type = const chaiscript::Box
ed_Value&]’:
cc1plus.exe: warning: function may return address of local variable [-Wreturn-local-addr]
C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/dispatchkit/boxed_cast.hpp:88:47: note: declared here
return detail::Cast_Helper::cast(t_conversions->boxed_type_conversion(bv), t_conversions);
^
cc1plus.exe: warning: function may return address of local variable [-Wreturn-local-addr]
C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/dispatchkit/boxed_cast.hpp:93:49: note: declared here
return detail::Cast_Helper::cast(t_conversions->boxed_type_down_conversion(bv), t_conversions);
^
In function ‘typename chaiscript::detail::Cast_Helper::Result_Type chaiscript::boxed_cast(const chaiscript::Boxed_Value&, const chaiscrip
t::Type_Conversions*) [with Type = chaiscript::Boxed_Value&; typename chaiscript::detail::Cast_Helper::Result_Type = chaiscript::Boxed_Va
lue&]’:
cc1plus.exe: warning: function may return address of local variable [-Wreturn-local-addr]
C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/dispatchkit/boxed_cast.hpp:88:47: note: declared here
return detail::Cast_Helper::cast(t_conversions->boxed_type_conversion(bv), t_conversions);
^
cc1plus.exe: warning: function may return address of local variable [-Wreturn-local-addr]
C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/dispatchkit/boxed_cast.hpp:93:49: note: declared here
return detail::Cast_Helper::cast(t_conversions->boxed_type_down_conversion(bv), t_conversions);
^
Linking CXX shared module libchaiscript_stdlib-5.7.1.dll
[ 33%] Built target chaiscript_stdlib-5.7.1
Scanning dependencies of target chai
[ 66%] Building CXX object CMakeFiles/chai.dir/src/main.cpp.obj
In function ‘typename chaiscript::detail::Cast_Helper::Result_Type chaiscript::boxed_cast(const chaiscript::Boxed_Value&, const chaiscrip
t::Type_Conversions*) [with Type = const chaiscript::Boxed_Value&; typename chaiscript::detail::Cast_Helper::Result_Type = const chaiscri
pt::Boxed_Value&]’:
cc1plus.exe: warning: function may return address of local variable [-Wreturn-local-addr]
In file included from C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/dispatchkit/dispatchkit.hpp:26:0,
from C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/chaiscript.hpp:822,
from C:\Users\Dani\dev\wspace\ChaiScript-5.7.1\src\main.cpp:15:
C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/dispatchkit/boxed_cast.hpp:88:47: note: declared here
return detail::Cast_Helper::cast(t_conversions->boxed_type_conversion(bv), t_conversions);
^
cc1plus.exe: warning: function may return address of local variable [-Wreturn-local-addr]
C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/dispatchkit/boxed_cast.hpp:93:49: note: declared here
return detail::Cast_Helper::cast(t_conversions->boxed_type_down_conversion(bv), t_conversions);
^
In function ‘typename chaiscript::detail::Cast_Helper::Result_Type chaiscript::boxed_cast(const chaiscript::Boxed_Value&, const chaiscrip
t::Type_Conversions*) [with Type = chaiscript::Boxed_Value; typename chaiscript::detail::Cast_Helper::Result_Type = const chaiscript::Box
ed_Value&]’:
cc1plus.exe: warning: function may return address of local variable [-Wreturn-local-addr]
C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/dispatchkit/boxed_cast.hpp:88:47: note: declared here
return detail::Cast_Helper::cast(t_conversions->boxed_type_conversion(bv), t_conversions);
^
cc1plus.exe: warning: function may return address of local variable [-Wreturn-local-addr]
C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/dispatchkit/boxed_cast.hpp:93:49: note: declared here
return detail::Cast_Helper::cast(t_conversions->boxed_type_down_conversion(bv), t_conversions);
^
Linking CXX executable chai.exe
[ 66%] Built target chai
Scanning dependencies of target stl_extra
[100%] Building CXX object CMakeFiles/stl_extra.dir/src/stl_extra.cpp.obj
In function ‘typename chaiscript::detail::Cast_Helper::Result_Type chaiscript::boxed_cast(const chaiscript::Boxed_Value&, const chaiscrip
t::Type_Conversions*) [with Type = const chaiscript::Boxed_Value&; typename chaiscript::detail::Cast_Helper::Result_Type = const chaiscri
pt::Boxed_Value&]’:
cc1plus.exe: warning: function may return address of local variable [-Wreturn-local-addr]
In file included from C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/dispatchkit/dispatchkit.hpp:26:0,
from C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/chaiscript.hpp:822,
from C:\Users\Dani\dev\wspace\ChaiScript-5.7.1\src\stl_extra.cpp:7:
C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/dispatchkit/boxed_cast.hpp:88:47: note: declared here
return detail::Cast_Helper::cast(t_conversions->boxed_type_conversion(bv), t_conversions);
^
cc1plus.exe: warning: function may return address of local variable [-Wreturn-local-addr]
C:/Users/Dani/dev/wspace/ChaiScript-5.7.1/include/chaiscript/dispatchkit/boxed_cast.hpp:93:49: note: declared here
return detail::Cast_Helper::cast(t_conversions->boxed_type_down_conversion(bv), t_conversions);
^
Linking CXX shared module libstl_extra.dll
[100%] Built target stl_extra

Tomorrow I will try to link it with my game to see if the “too big file” error is gone.


#2

There’s a bug in mingw that requires you to build with optimizations enabled. -O2 should get it working.

Which version of MinGW are you using that’s generating those warnings?

-Jason


#3

I’m using MSYS2 :

C:\Users\Dani>mingw32-make.exe --version
GNU Make 4.1.90
Built for Windows32
Copyright © 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

C:\Users\Dani>g++ --version
g++ (Rev3, Built by MSYS2 project) 5.2.0
Copyright © 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


#4

Is this this MINGW bug reported? Because debugging with -O2 … :confused:


#5

I don’t know if it’s reported anywhere. It’s been a problem for me since at least MingGW 4.8, but it’s a platform I only very rarely test against. It’s possible there’s some other workaround. I think -O1 works also maybe?

Let me know if you find out anything else.


#6

Yes, with -O1 is compiling too, but surprisingly WITHOUT those warnings.

  • Without optimizations, gives a “File too big” and “too many sections” error.
  • With O1 compiles without warnings
  • With O2 compiles with warnings
  • With O3 compiles with warnings (the same from O2)

For your projects, in Windows, are you using only MSVC?


#7

Yes, my preference is to use the “native” compiler on all platforms (ie MSVC on Windows). But officially ChaiScript supports “all” compilers (within reason, such that they have the language features I require).

There are a surprising amount of tiny workarounds for things like broken standard library implementations and weird linker issues. For the most part they do not get in the way, though.

I’ll put in something to ignore those warnings. The warning is not technically correct for this code.