godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.22k stars 21.04k forks source link

Cannot compile Android templates with Mono in the 3.2 branch on Windows (conflict with MonoGCHandle typedef) #44068

Open Enoti722 opened 3 years ago

Enoti722 commented 3 years ago

Godot version: 3.2 branch 9df3d06

OS/device including version: Windows 10 64-bit VS 2019 Native tools Command Prompt x64

Issue description: Firstly I compiled the stable branch of 3.2 with mono enabled (following the instructions) Also compiled mono for android (https://github.com/godotengine/godot-mono-builds) Then in VS 2019 Tools I'm compiling templates: set env variables, running command scons p=android target=release module_mono_enabled=yes android_arch=armv7 mono_prefix="Path-To-Compiled-Monos\android-armeabi-v7a-release" And on file Godot-Source-Path\modules\mono\csharp_script.cpp I have this issue:

[ 17%] Compiling ==> modules\mono\csharp_script.cpp
=====
"In file included from modules\\mono\\csharp_script.cpp:31:
In file included from modules\\mono/csharp_script.h:39:
modules\\mono/mono_gc_handle.h:38:7: error: definition of type 'MonoGCHandle' conflicts with typedef of the same name
class MonoGCHandle : public Reference {
C:\\Program Files\\Mono\\Mono-installs\\android-armeabi-v7a-release\\include\\mono-2.0\\mono/utils/mono-forward.h:13:16: note: 'MonoGCHandle' declared here
typedef void * MonoGCHandle;
               ^
In file included from modules\\mono\\csharp_script.cpp:58:
modules\\mono/signal_awaiter_utils.h:42:36: error: base specifier must name a class
class SignalAwaiterHandle : public MonoGCHandle {
                            ~~~~~~~^~~~~~~~~~~~
modules\\mono/signal_awaiter_utils.h:44:31: error: 'MonoGCHandle' (aka 'void *') is not a class, namespace, or enumeration
GDCLASS(SignalAwaiterHandle, MonoGCHandle);
                                     ^
modules\\mono/signal_awaiter_utils.h:44:31: error: 'MonoGCHandle' (aka 'void *') is not a class, namespace, or enumeration
modules\\mono/signal_awaiter_utils.h:44:31: error: 'MonoGCHandle' (aka 'void *') is not a class, namespace, or enumeration
modules\\mono/signal_awaiter_utils.h:44:2: error: use of undeclared identifier '_get_category'
        GDCLASS(SignalAwaiterHandle, MonoGCHandle);
        ^
.\\core/object.h:295:7: note: expanded from macro 'GDCLASS'
                if (_get_category != m_inherits::_get_category) {                                                                               \\
                    ^
In file included from modules\\mono\\csharp_script.cpp:58:
modules\\mono/signal_awaiter_utils.h:44:31: error: 'MonoGCHandle' (aka 'void *') is not a class, namespace, or enumeration
        GDCLASS(SignalAwaiterHandle, MonoGCHandle);
                                     ^
modules\\mono/signal_awaiter_utils.h:44:2: error: use of undeclared identifier '_get_category'
        GDCLASS(SignalAwaiterHandle, MonoGCHandle);
        ^
.\\core/object.h:298:16: note: expanded from macro 'GDCLASS'
                        category += _get_category();                                                                                                \\
                                    ^
In file included from modules\\mono\\csharp_script.cpp:58:
modules\\mono/signal_awaiter_utils.h:44:31: error: 'MonoGCHandle' (aka 'void *') is not a class, namespace, or enumeration
        GDCLASS(SignalAwaiterHandle, MonoGCHandle);
                                     ^
modules\\mono/signal_awaiter_utils.h:44:31: error: 'MonoGCHandle' (aka 'void *') is not a class, namespace, or enumeration
modules\\mono/signal_awaiter_utils.h:44:31: error: 'MonoGCHandle' (aka 'void *') is not a class, namespace, or enumeration
modules\\mono/signal_awaiter_utils.h:44:2: error: no member named '_get_valid_parents_static' in 'SignalAwaiterHandle'; did you mean 'get_valid_parents_static'?
        GDCLASS(SignalAwaiterHandle, MonoGCHandle);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\\core/object.h:310:16: note: expanded from macro 'GDCLASS'
                if (m_class::_get_valid_parents_static != m_inherits::_get_valid_parents_static) {                                              \\
                    ~~~~~~~~~^
modules\\mono/signal_awaiter_utils.h:44:2: note: 'get_valid_parents_static' declared here
.\\core/object.h:308:14: note: expanded from macro 'GDCLASS'
        static void get_valid_parents_static(List<String> *p_parents) {                                                                     \\
                    ^
In file included from modules\\mono\\csharp_script.cpp:58:
modules\\mono/signal_awaiter_utils.h:44:2: error: no type named '_get_valid_parents_static' in 'SignalAwaiterHandle'
        GDCLASS(SignalAwaiterHandle, MonoGCHandle)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\\core/object.h:311:13: note: expanded from macro 'GDCLASS'
                        m_class::_get_valid_parents_static(p_parents);                                                                              \\
                        ~~~~~~~~~^
In file included from modules\\mono\\csharp_script.cpp:58:
modules\\mono/signal_awaiter_utils.h:44:31: error: 'MonoGCHandle' (aka 'void *') is not a class, namespace, or enumeration
        GDCLASS(SignalAwaiterHandle, MonoGCHandle);
                                     ^
modules\\mono/signal_awaiter_utils.h:44:31: error: 'MonoGCHandle' (aka 'void *') is not a class, namespace, or enumeration
modules\\mono/signal_awaiter_utils.h:44:31: error: 'MonoGCHandle' (aka 'void *') is not a class, namespace, or enumeration
modules\\mono/signal_awaiter_utils.h:44:10: error: no member named '_get' in 'SignalAwaiterHandle'; did you mean '::SignalAwaiterHandle::_getv'?
        GDCLASS(SignalAwaiterHandle, MonoGCHandle);        ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\\core/object.h:339:68: note: expanded from macro 'GDCLASS'
                return (bool (Object::*)(const StringName &, Variant &) const) & m_class::_get;                                                 \\
                                                                                 ^~~~~~~~~
modules\\mono/signal_awaiter_utils.h:44:2: note: '::SignalAwaiterHandle::_getv' declared here
        GDCLASS(SignalAwaiterHandle, MonoGCHandle);
        ^
.\\core/object.h:341:15: note: expanded from macro 'GDCLASS'
        virtual bool _getv(const StringName &p_name, Variant &r_ret) const {                                                                \\
                     ^
In file included from modules\\mono\\csharp_script.cpp:58:
modules\\mono/signal_awaiter_utils.h:44:31: error: 'MonoGCHandle' (aka 'void *') is not a class, namespace, or enumeration
        GDCLASS(SignalAwaiterHandle, MonoGCHandle);
                                     ^
modules\\mono/signal_awaiter_utils.h:44:2: error: use of undeclared identifier '_get'; did you mean '_getv'?
        GDCLASS(SignalAwaiterHandle, MonoGCHandle);
        ^
.\\core/object.h:343:8: note: expanded from macro 'GDCLASS'
                        if (_get(p_name, r_ret))                                                                                                    \\
                            ^
modules\\mono/signal_awaiter_utils.h:44:2: note: '_getv' declared here
.\\core/object.h:341:15: note: expanded from macro 'GDCLASS'
        virtual bool _getv(const StringName &p_name, Variant &r_ret) const {                                                                \\
                     ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]\r\n20 errors generated.
"
=====
scons: *** [modules\mono\csharp_script.android.opt.armv7.neon.o] Error 1
scons: building terminated because of errors.

Hope I wrote enough and you will help with it. Thanks in advance :)

Steps to reproduce:

Compile 9df3d06 Godot 3.2 Compile Mono for Android from https://github.com/mono/mono (master branch) Compile Android Templates with scons p=android target=release module_mono_enabled=yes android_arch=armv7 mono_prefix="Path-To-Compiled-Monos\android-armeabi-v7a-release"

akien-mga commented 3 years ago

The problem is here:

modules\\mono/mono_gc_handle.h:38:7: error: definition of type 'MonoGCHandle' conflicts with typedef of the same name
class MonoGCHandle : public Reference {
C:\\Program Files\\Mono\\Mono-installs\\android-armeabi-v7a-release\\include\\mono-2.0\\mono/utils/mono-forward.h:13:16: note: 'MonoGCHandle' declared here
typedef void * MonoGCHandle;
               ^

I can't reproduce it locally on Linux with a local build of Mono 6.8.0.

It also seems to work fine on the official buildsystem (also Linux-based) with Mono 6.12.0.111.

Here's the content of android-armeabi-v7a-release/include/mono-2.0/mono/utils/mono-forward.h here:

/**
 * \file
 *
 * (C) 2018 Microsoft, Inc.
 *
 */
#ifndef _MONO_UTILS_FORWARD_
#define _MONO_UTILS_FORWARD_

typedef struct _MonoDomain MonoDomain;
typedef struct _MonoJitInfo MonoJitInfo;

#endif

No typedef for MonoGCHandle.

neikeq commented 3 years ago

I took the opportunity to fix this on master together this change: https://github.com/godotengine/godot/commit/0b814ea78d6b065e8e0785155207bd80b3d845c8 Since this doesn't look too urgent (as Mono added the MonoGCHandle typedef after version 6.12 which is what we use) maybe I should backport that entire commit rather than just doing the rename.

AlekEagle commented 3 years ago

I'm getting the same error, however, I'm building Godot with SteamGodot, the Linux build worked perfectly, however, when compiling to windows I get the same error.

MinGW Mono version:

Mono JIT compiler version 6.13.0 (master/981b5837513)
Copyright (C) Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS:
SIGSEGV:       normal
Notification:  Thread + polling
Architecture:  amd64
Disabled:      none
Misc:          softdebug
Interpreter:   yes
Suspend:       hybrid
GC:            sgen (concurrent by default)

Godot version 3.2 commit a18df71789a36b318c40d691efdb4da1e574bbfd

Operating System: Ubuntu 20.04.1 LTS Kernel: Linux 5.4.0-59-generic Architecture: x86-64

akien-mga commented 3 years ago

@AlekEagle I would advise using Mono 6.12 which is what we use for official Godot builds.

Mono 6.13 is not released, and likely won't ever be, as Mono development now happens and is versioned along dotnet-runtime.

AlekEagle commented 3 years ago

that works, thanks!