Page MenuHomeWildfire Games

Patches required to work with latest clang on FreeBSD
ClosedPublic

Authored by madpilot on Jul 5 2018, 4:48 PM.

Details

Summary

FreeBSD 12 includes clang version 6.0.1 (imported a few days ago, I tested with 6.0.0).

This compiler is really picky about standards and a few lines required changing:

in AtlasObjectImpl.ccp clang was erroring out due to the calls to add and set being considered ambiguous.

I took a brutal approach and duplicated the code inside the functions calling them directly. This can be made better, but I'm not a C++ expert, so I did not spend too much time thinking about it.

In MapDialog.cpp and ScenarioEditor.cpp the calls to wxString::wc_str() return wchar_t*, but the constructor they are passed into expects std::wstring so I changed the call to wxString::ToStdWstring(), returning the expected type.

Test Plan

The patches compile and work fine in FreeBSD, at least for a short playtest.

If a specific test is requested I can perform that.

Patches already committed to the FreeBSD ports tree.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

madpilot created this revision.Jul 5 2018, 4:48 PM
Owners added a subscriber: Restricted Owners Package.Jul 5 2018, 4:49 PM
Vulcan added a subscriber: Vulcan.Jul 5 2018, 4:53 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/differential/673/display/redirect

Could you attach your errors?

Here is the error for the add call (the one for set is the same):

c++ -O2 -pipe -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing  -DLIBICONV_PLUG -DU_USING_ICU_NAMESPACE=1 -DLIBICONV_PLUG -MMD -MP -DNDEBUG -DCONFIG_FINAL=1 -DLIB_STATIC_LINK -DINSTALLED_BINDIR=/usr/local/bin -DINSTALLED_DATADIR=/usr/local/share/0ad -DINSTALLED_LIBDIR=/usr/local/lib/0ad -I../../../source/tools/atlas/AtlasObject -I../../../source/third_party/jsonspirit -isystem /usr/local/include/libxml2 -isystem /usr/local/lib/wx/include/gtk2-unicode-3.0 -isystem /usr/local/include/wx-3.0 -isystem /usr/X11R6/include/X11 -isystem /usr/X11R6/include -isystem /usr/local/include/X11 -isystem /usr/local/include -isystem /usr/include/X11 -O3 -g -Wall -Wextra -Wno-switch -Wno-reorder -Wno-invalid-offsetof -Wextra -Wno-missing-field-initializers -Wunused-parameter -Wredundant-decls -Wnon-virtual-dtor -Wundef -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstrict-aliasing -fno-omit-frame-pointer -fpch-preprocess -std=c++0x -fvisibility=hidden -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -D_THREAD_SAFE -rdynamic -fPIC -Wno-unused-local-typedefs  -o "obj/AtlasObject_Release/AtlasObjectImpl.o" -MF "obj/AtlasObject_Release/AtlasObjectImpl.d" -c "../../../source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp"
../../../source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp:167:2: error: call to member function 'add' is ambiguous
        add(key, value.wc_str());
        ^~~
../../../source/tools/atlas/AtlasObject/AtlasObject.h:160:7: note: candidate function
        void add(const char* key, const wchar_t* value);
             ^
../../../source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp:165:13: note: candidate function
void AtObj::add(const char* key, const wxString& value)
            ^
../../../source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp:157:13: note: candidate function not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'AtObj &' for 2nd argument
void AtObj::add(const char* key, AtObj& data)
            ^
../../../source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp:190:2: error: call to member function 'set' is ambiguous
        set(key, value.wc_str());
        ^~~
../../../source/tools/atlas/AtlasObject/AtlasObject.h:163:7: note: candidate function
        void set(const char* key, const wchar_t* value);
             ^
../../../source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp:188:13: note: candidate function
void AtObj::set(const char* key, const wxString& value)
            ^
../../../source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp:180:13: note: candidate function not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'AtObj &' for 2nd argument
void AtObj::set(const char* key, AtObj& data)
            ^
2 errors generated.

Here is the one for the wxString::wc_str() :

c++ -O2 -pipe -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing  -DLIBICONV_PLUG -DU_USING_ICU_NAMESPACE=1 -DLIBICONV_PLUG -MMD -MP -DNDEBUG -DCONFIG_FINAL=1 -DLIB_STATIC_LINK -DINSTALLED_BINDIR=/usr/local/bin -DINSTALLED_DATADIR=/usr/local/share/0ad -DINSTALLED_LIBDIR=/usr/local/lib/0ad -DUSING_PCH -I../../../source/tools/atlas/AtlasUI -I../../../source/tools/atlas -I../../../source/tools/atlas/AtlasUI/CustomControls -I../../../source/tools/atlas/AtlasUI/Misc -isystem /usr/local/include/libxml2 -isystem /usr/local/include/SDL2 -isystem /usr/local/lib/wx/include/gtk2-unicode-3.0 -isystem /usr/local/include/wx-3.0 -isystem /usr/X11R6/include/X11 -isystem /usr/X11R6/include -isystem /usr/local/include/X11 -isystem /usr/local/include -isystem /usr/include/X11 -O3 -fPIC -g -Wall -Wextra -Wno-switch -Wno-reorder -Wno-invalid-offsetof -Wextra -Wno-missing-field-initializers -Wunused-parameter -Wredundant-decls -Wnon-virtual-dtor -Wundef -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstrict-aliasing -fno-omit-frame-pointer -fpch-preprocess -std=c++0x -fvisibility=hidden -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -D_THREAD_SAFE -rdynamic -fPIC -Wno-unused-local-typedefs -include obj/AtlasUI_Release/precompiled.h -o "obj/AtlasUI_Release/MapDialog.o" -MF "obj/AtlasUI_Release/MapDialog.d" -c "../../../source/tools/atlas/AtlasUI/CustomControls/MapDialog/MapDialog.cpp"
../../../source/tools/atlas/AtlasUI/CustomControls/MapDialog/MapDialog.cpp:169:32: error: no matching constructor for initialization of 'AtlasMessage::qVFSFileExists'
                AtlasMessage::qVFSFileExists qry(filePath.wc_str());
                                             ^   ~~~~~~~~~~~~~~~~~
../../../source/tools/atlas/GameInterface/Messages.h:207:1: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'const AtlasMessage::qVFSFileExists' for 1st argument
QUERY(VFSFileExists,
^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:188:3: note: expanded from macro 'QUERY'
                QUERY_WITH_INPUTS) \
                ^
/usr/local/include/boost/preprocessor/control/iif.hpp:18:60: note: expanded from macro 'BOOST_PP_IIF'
#    define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
                                                           ^
/usr/local/include/boost/preprocessor/control/iif.hpp:25:63: note: expanded from macro 'BOOST_PP_IIF_I'
#    define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f)
                                                              ^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
../../../source/tools/atlas/GameInterface/MessagesSetup.h:176:2: note: expanded from macro 'QUERY_WITH_INPUTS'
        QUERYSTRUCT(name) \
        ^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:81:9: note: expanded from macro 'QUERYSTRUCT'
        struct q##t : public QueryMessage { \
               ^
<scratch space>:164:1: note: expanded from here
qVFSFileExists
^
../../../source/tools/atlas/GameInterface/Messages.h:207:1: note: candidate constructor not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'std::wstring' (aka 'basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >') for 1st argument
../../../source/tools/atlas/GameInterface/MessagesSetup.h:188:3: note: expanded from macro 'QUERY'
                QUERY_WITH_INPUTS) \
                ^
/usr/local/include/boost/preprocessor/control/iif.hpp:18:60: note: expanded from macro 'BOOST_PP_IIF'
#    define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
                                                           ^
/usr/local/include/boost/preprocessor/control/iif.hpp:25:63: note: expanded from macro 'BOOST_PP_IIF_I'
#    define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f)
                                                              ^
/usr/local/include/boost/preprocessor/control/iif.hpp:31:31: note: expanded from macro 'BOOST_PP_IIF_0'
# define BOOST_PP_IIF_0(t, f) f
                              ^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:177:3: note: expanded from macro 'QUERY_WITH_INPUTS'
                q##name( BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORARGS, ~, in_vals) ) \
                ^
<scratch space>:167:1: note: expanded from here
qVFSFileExists
^
../../../source/tools/atlas/AtlasUI/CustomControls/MapDialog/MapDialog.cpp:173:35: error: no matching constructor for initialization of 'AtlasMessage::qVFSFileRealPath'
                        AtlasMessage::qVFSFileRealPath qry(filePath.wc_str());
                                                       ^   ~~~~~~~~~~~~~~~~~
../../../source/tools/atlas/GameInterface/Messages.h:213:1: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'const AtlasMessage::qVFSFileRealPath' for 1st argument
QUERY(VFSFileRealPath,
^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:188:3: note: expanded from macro 'QUERY'
                QUERY_WITH_INPUTS) \
                ^
/usr/local/include/boost/preprocessor/control/iif.hpp:18:60: note: expanded from macro 'BOOST_PP_IIF'
#    define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
                                                           ^
/usr/local/include/boost/preprocessor/control/iif.hpp:25:63: note: expanded from macro 'BOOST_PP_IIF_I'
#    define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f)
                                                              ^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
../../../source/tools/atlas/GameInterface/MessagesSetup.h:176:2: note: expanded from macro 'QUERY_WITH_INPUTS'
        QUERYSTRUCT(name) \
        ^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:81:9: note: expanded from macro 'QUERYSTRUCT'
        struct q##t : public QueryMessage { \
               ^
<scratch space>:81:1: note: expanded from here
qVFSFileRealPath
^
../../../source/tools/atlas/GameInterface/Messages.h:213:1: note: candidate constructor not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'std::wstring' (aka 'basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >') for 1st argument
../../../source/tools/atlas/GameInterface/MessagesSetup.h:188:3: note: expanded from macro 'QUERY'
                QUERY_WITH_INPUTS) \
                ^
/usr/local/include/boost/preprocessor/control/iif.hpp:18:60: note: expanded from macro 'BOOST_PP_IIF'
#    define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
                                                           ^
/usr/local/include/boost/preprocessor/control/iif.hpp:25:63: note: expanded from macro 'BOOST_PP_IIF_I'
#    define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f)
                                                              ^
/usr/local/include/boost/preprocessor/control/iif.hpp:31:31: note: expanded from macro 'BOOST_PP_IIF_0'
# define BOOST_PP_IIF_0(t, f) f
                              ^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:177:3: note: expanded from macro 'QUERY_WITH_INPUTS'
                q##name( BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORARGS, ~, in_vals) ) \
                ^
<scratch space>:84:1: note: expanded from here
qVFSFileRealPath
^
../../../source/tools/atlas/AtlasUI/CustomControls/MapDialog/MapDialog.cpp:224:31: error: no matching constructor for initialization of 'AtlasMessage::qVFSFileExists'
        AtlasMessage::qVFSFileExists qry(filePath.wc_str());
                                     ^   ~~~~~~~~~~~~~~~~~
../../../source/tools/atlas/GameInterface/Messages.h:207:1: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'const AtlasMessage::qVFSFileExists' for 1st argument
QUERY(VFSFileExists,
^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:188:3: note: expanded from macro 'QUERY'
                QUERY_WITH_INPUTS) \
                ^
/usr/local/include/boost/preprocessor/control/iif.hpp:18:60: note: expanded from macro 'BOOST_PP_IIF'
#    define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
                                                           ^
/usr/local/include/boost/preprocessor/control/iif.hpp:25:63: note: expanded from macro 'BOOST_PP_IIF_I'
#    define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f)
                                                              ^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
../../../source/tools/atlas/GameInterface/MessagesSetup.h:176:2: note: expanded from macro 'QUERY_WITH_INPUTS'
        QUERYSTRUCT(name) \
        ^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:81:9: note: expanded from macro 'QUERYSTRUCT'
        struct q##t : public QueryMessage { \
               ^
<scratch space>:164:1: note: expanded from here
qVFSFileExists
^
../../../source/tools/atlas/GameInterface/Messages.h:207:1: note: candidate constructor not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'std::wstring' (aka 'basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >') for 1st argument
../../../source/tools/atlas/GameInterface/MessagesSetup.h:188:3: note: expanded from macro 'QUERY'
                QUERY_WITH_INPUTS) \
                ^
/usr/local/include/boost/preprocessor/control/iif.hpp:18:60: note: expanded from macro 'BOOST_PP_IIF'
#    define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
                                                           ^
/usr/local/include/boost/preprocessor/control/iif.hpp:25:63: note: expanded from macro 'BOOST_PP_IIF_I'
#    define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f)
                                                              ^
/usr/local/include/boost/preprocessor/control/iif.hpp:31:31: note: expanded from macro 'BOOST_PP_IIF_0'
# define BOOST_PP_IIF_0(t, f) f
                              ^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:177:3: note: expanded from macro 'QUERY_WITH_INPUTS'
                q##name( BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORARGS, ~, in_vals) ) \
                ^
<scratch space>:167:1: note: expanded from here
qVFSFileExists
^
../../../source/tools/atlas/AtlasUI/CustomControls/MapDialog/MapDialog.cpp:239:31: error: no matching constructor for initialization of 'AtlasMessage::qVFSFileExists'
        AtlasMessage::qVFSFileExists qry(filePath.wc_str());
                                     ^   ~~~~~~~~~~~~~~~~~
../../../source/tools/atlas/GameInterface/Messages.h:207:1: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'const AtlasMessage::qVFSFileExists' for 1st argument
QUERY(VFSFileExists,
^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:188:3: note: expanded from macro 'QUERY'
                QUERY_WITH_INPUTS) \
                ^
/usr/local/include/boost/preprocessor/control/iif.hpp:18:60: note: expanded from macro 'BOOST_PP_IIF'
#    define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
                                                           ^
/usr/local/include/boost/preprocessor/control/iif.hpp:25:63: note: expanded from macro 'BOOST_PP_IIF_I'
#    define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f)
                                                              ^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
../../../source/tools/atlas/GameInterface/MessagesSetup.h:176:2: note: expanded from macro 'QUERY_WITH_INPUTS'
        QUERYSTRUCT(name) \
        ^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:81:9: note: expanded from macro 'QUERYSTRUCT'
        struct q##t : public QueryMessage { \
               ^
<scratch space>:164:1: note: expanded from here
qVFSFileExists
^
../../../source/tools/atlas/GameInterface/Messages.h:207:1: note: candidate constructor not viable: no known conversion from 'const wxScopedWCharBuffer' (aka 'const wxScopedCharTypeBuffer<wchar_t>') to 'std::wstring' (aka 'basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >') for 1st argument
../../../source/tools/atlas/GameInterface/MessagesSetup.h:188:3: note: expanded from macro 'QUERY'
                QUERY_WITH_INPUTS) \
                ^
/usr/local/include/boost/preprocessor/control/iif.hpp:18:60: note: expanded from macro 'BOOST_PP_IIF'
#    define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f)
                                                           ^
/usr/local/include/boost/preprocessor/control/iif.hpp:25:63: note: expanded from macro 'BOOST_PP_IIF_I'
#    define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f)
                                                              ^
/usr/local/include/boost/preprocessor/control/iif.hpp:31:31: note: expanded from macro 'BOOST_PP_IIF_0'
# define BOOST_PP_IIF_0(t, f) f
                              ^
../../../source/tools/atlas/GameInterface/MessagesSetup.h:177:3: note: expanded from macro 'QUERY_WITH_INPUTS'
                q##name( BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORARGS, ~, in_vals) ) \
                ^
<scratch space>:167:1: note: expanded from here
qVFSFileExists
^
nwtour added a subscriber: nwtour.Feb 8 2021, 12:38 AM

IMHO its not clang/freebsd problem. I found this problem on Linux/gcc https://code.wildfiregames.com/D1202. Actual on latest revision.

String polymorphism described in official documentation https://docs.wxwidgets.org/3.1/classwx_string.html (Section "Conversion to C string")

I`m rebuild wxwidget package in my system (remove -DUNICODE=1 -DwxUSE_UNICODE=1 --enable-utf8=yes --enable-unicode) and Atlas successfully build.

Stan added a comment.Feb 8 2021, 12:52 AM

I'm not sure I understand do you mean the fix here is incorrect?

s0600204 requested changes to this revision.Feb 27 2021, 12:42 AM
s0600204 added a subscriber: s0600204.

Requires an update and rebase.

@madpilot, an updated patch has been suggested by @nwtour in the comments of D1202. (If you would prefer them or someone else to take over instead, please make this known.)

This revision now requires changes to proceed.Feb 27 2021, 12:42 AM
madpilot planned changes to this revision.Feb 27 2021, 2:09 PM

I'll update the patch with the code I'm using at present in the FreeBSD port, which I'm now testing for the update to the latest version.

The patch has not changed much though.

madpilot updated this revision to Diff 16101.Feb 27 2021, 2:19 PM

Updated patch working with latest FreeBSD clang 10.x and 11.x (release 13.0 coming in a month has 11.0.1)

Stan added a comment.Feb 27 2021, 5:11 PM

@nwtour can you confirm it works for you?

nwtour added a comment.Mar 1 2021, 9:48 PM

Yes. Patch succesfully applied and Atlas successfuly build with wxWidget 3.0.5.1 @Stan

Stan accepted this revision.Mar 1 2021, 9:50 PM

Sweet. Will fix headers and commit now that I know its use.

This revision was not accepted when it landed; it landed in state Needs Review.Mar 2 2021, 12:32 AM
This revision was automatically updated to reflect the committed changes.