Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenBSD error: conversion from 'const Variant' to 'unsigned long' is ambiguous #74669

Closed
omar-polo opened this issue Mar 9, 2023 · 12 comments · Fixed by #84017
Closed

OpenBSD error: conversion from 'const Variant' to 'unsigned long' is ambiguous #74669

omar-polo opened this issue Mar 9, 2023 · 12 comments · Fixed by #84017

Comments

@omar-polo
Copy link
Contributor

Godot version

4.0

System information

OpenBSD/amd64 7.2-CURRENT, amdgpu

Issue description

Trying to build on OpenBSD and I'm hitting this error message. Building with -DNEED_LONG_INT seems to go past this, but since it's only used for ios on aarch64 (guessing from grepping where it's defined) I'm not sure; this is happening on amd64 for me.

Here's the full error message; I apologize but my C++-fu is not strong enough to fully grasp this.

In file included from platform/linuxbsd/tts_linux.cpp:31:
In file included from platform/linuxbsd/tts_linux.h:40:
In file included from ./servers/display_server.h:34:
In file included from ./core/input/input.h:34:
In file included from ./core/input/input_event.h:35:
In file included from ./core/io/resource.h:34:
In file included from ./core/io/resource_uid.h:34:
In file included from ./core/object/ref_counted.h:34:
In file included from ./core/object/class_db.h:34:
In file included from ./core/object/method_bind.h:34:
./core/variant/binder_common.h:57:11: error: conversion from 'const Variant' to 'unsigned long' is ambiguous
                        return p_variant;
                               ^~~~~~~~~
./core/variant/binder_common.h:295:44: note: in instantiation of member function 'VariantCaster<unsigned long>::cast' requested here
        (p_instance->*p_method)(VariantCaster<P>::cast(*p_args[Is])...);
                                                  ^
./core/variant/binder_common.h:407:2: note: in instantiation of function template specialization 'call_with_variant_args_helper<TTS_Linux, unsigned long, unsigned long, int, const String &, 0UL, 1UL, 2UL, 3UL>' requested here
        call_with_variant_args_helper<T, P...>(p_instance, p_method, p_args, r_error, BuildIndexSequence<sizeof...(P)>{});
        ^
./core/object/callable_method_pointer.h:104:3: note: in instantiation of function template specialization 'call_with_variant_args<TTS_Linux, unsigned long, unsigned long, int, const String &>' requested here
                call_with_variant_args(data.instance, data.method, p_arguments, p_argcount, r_call_error);
                ^
./core/object/callable_method_pointer.h:107:2: note: in instantiation of member function 'CallableCustomMethodPointer<TTS_Linux, unsigned long, unsigned long, int, const String &>::call' requested here
        CallableCustomMethodPointer(T *p_instance, void (T::*p_method)(P...)) {
        ^
./core/object/callable_method_pointer.h:125:22: note: in instantiation of member function 'CallableCustomMethodPointer<TTS_Linux, unsigned long, unsigned long, int, const String &>::CallableCustomMethodPointer' requested here
        CCMP *ccmp = memnew(CCMP(p_instance, p_method));
                            ^
platform/linuxbsd/tts_linux.cpp:80:3: note: in instantiation of function template specialization 'create_custom_callable_function_pointer<TTS_Linux, unsigned long, unsigned long, int, const String &>' requested here
                callable_mp(tts, &TTS_Linux::_speech_index_mark).call_deferred(p_msg_id, p_client_id, (int)p_type, String::utf8(p_index_mark));
                ^
./core/object/callable_method_pointer.h:245:27: note: expanded from macro 'callable_mp'
#define callable_mp(I, M) create_custom_callable_function_pointer(I, M)
                          ^
./core/variant/variant.h:353:2: note: candidate function
        operator bool() const;
        ^
./core/variant/variant.h:354:2: note: candidate function
        operator signed int() const;
        ^
./core/variant/variant.h:355:2: note: candidate function
        operator unsigned int() const; // this is the real one
        ^
./core/variant/variant.h:356:2: note: candidate function
        operator signed short() const;
        ^
./core/variant/variant.h:357:2: note: candidate function
        operator unsigned short() const;
        ^
./core/variant/variant.h:358:2: note: candidate function
        operator signed char() const;
        ^
./core/variant/variant.h:359:2: note: candidate function
        operator unsigned char() const;
        ^
./core/variant/variant.h:361:2: note: candidate function
        operator int64_t() const;
        ^
./core/variant/variant.h:362:2: note: candidate function
        operator uint64_t() const;
        ^
./core/variant/variant.h:370:2: note: candidate function
        operator char32_t() const;
        ^
./core/variant/variant.h:371:2: note: candidate function
        operator float() const;
        ^
./core/variant/variant.h:372:2: note: candidate function
        operator double() const;
        ^
./core/variant/variant.h:420:2: note: candidate function
        operator Side() const;
        ^
./core/variant/variant.h:421:2: note: candidate function
        operator Orientation() const;
        ^
In file included from platform/linuxbsd/tts_linux.cpp:31:
In file included from platform/linuxbsd/tts_linux.h:40:
In file included from ./servers/display_server.h:34:
In file included from ./core/input/input.h:34:
In file included from ./core/input/input_event.h:35:
In file included from ./core/io/resource.h:34:
In file included from ./core/io/resource_uid.h:34:
In file included from ./core/object/ref_counted.h:34:
In file included from ./core/object/class_db.h:34:
In file included from ./core/object/method_bind.h:34:
In file included from ./core/variant/binder_common.h:35:
In file included from ./core/object/object.h:35:
In file included from ./core/object/message_queue.h:36:
In file included from ./core/variant/variant.h:60:
./core/variant/callable.h:78:43: error: conversion from 'unsigned long' to 'Variant' is ambiguous
                Variant args[sizeof...(p_args) + 1] = { p_args..., 0 }; // +1 makes sure zero sized arrays are also supported.
                                                        ^~~~~~
platform/linuxbsd/tts_linux.cpp:80:52: note: in instantiation of function template specialization 'Callable::call_deferred<unsigned long, unsigned long, int, String>' requested here
                callable_mp(tts, &TTS_Linux::_speech_index_mark).call_deferred(p_msg_id, p_client_id, (int)p_type, String::utf8(p_index_mark));
                                                                 ^
./core/variant/variant.h:428:2: note: candidate constructor
        Variant(bool p_bool);
        ^
./core/variant/variant.h:429:2: note: candidate constructor
        Variant(signed int p_int); // real one
        ^
./core/variant/variant.h:430:2: note: candidate constructor
        Variant(unsigned int p_int);
        ^
./core/variant/variant.h:435:2: note: candidate constructor
        Variant(signed short p_short); // real one
        ^
./core/variant/variant.h:436:2: note: candidate constructor
        Variant(unsigned short p_short);
        ^
./core/variant/variant.h:437:2: note: candidate constructor
        Variant(signed char p_char); // real one
        ^
./core/variant/variant.h:438:2: note: candidate constructor
        Variant(unsigned char p_char);
        ^
./core/variant/variant.h:439:2: note: candidate constructor
        Variant(int64_t p_int); // real one
        ^
./core/variant/variant.h:440:2: note: candidate constructor
        Variant(uint64_t p_int);
        ^
./core/variant/variant.h:441:2: note: candidate constructor
        Variant(float p_float);
        ^
./core/variant/variant.h:442:2: note: candidate constructor
        Variant(double p_double);
        ^
In file included from platform/linuxbsd/tts_linux.cpp:31:
In file included from platform/linuxbsd/tts_linux.h:40:
In file included from ./servers/display_server.h:34:
In file included from ./core/input/input.h:34:
In file included from ./core/input/input_event.h:35:
In file included from ./core/io/resource.h:34:
In file included from ./core/io/resource_uid.h:34:
In file included from ./core/object/ref_counted.h:34:
In file included from ./core/object/class_db.h:34:
In file included from ./core/object/method_bind.h:34:
In file included from ./core/variant/binder_common.h:35:
In file included from ./core/object/object.h:35:
In file included from ./core/object/message_queue.h:36:
In file included from ./core/variant/variant.h:60:
./core/variant/callable.h:78:43: error: conversion from 'unsigned long' to 'Variant' is ambiguous
                Variant args[sizeof...(p_args) + 1] = { p_args..., 0 }; // +1 makes sure zero sized arrays are also supported.
                                                        ^~~~~~
./core/variant/variant.h:428:2: note: candidate constructor
        Variant(bool p_bool);
        ^
./core/variant/variant.h:429:2: note: candidate constructor
        Variant(signed int p_int); // real one
        ^
./core/variant/variant.h:430:2: note: candidate constructor
        Variant(unsigned int p_int);
        ^
./core/variant/variant.h:435:2: note: candidate constructor
        Variant(signed short p_short); // real one
        ^
./core/variant/variant.h:436:2: note: candidate constructor
        Variant(unsigned short p_short);
        ^
./core/variant/variant.h:437:2: note: candidate constructor
        Variant(signed char p_char); // real one
        ^
./core/variant/variant.h:438:2: note: candidate constructor
        Variant(unsigned char p_char);
        ^
./core/variant/variant.h:439:2: note: candidate constructor
        Variant(int64_t p_int); // real one
        ^
./core/variant/variant.h:440:2: note: candidate constructor
        Variant(uint64_t p_int);
        ^
./core/variant/variant.h:441:2: note: candidate constructor
        Variant(float p_float);
        ^
./core/variant/variant.h:442:2: note: candidate constructor
        Variant(double p_double);
        ^
In file included from platform/linuxbsd/tts_linux.cpp:31:
In file included from platform/linuxbsd/tts_linux.h:40:
In file included from ./servers/display_server.h:34:
In file included from ./core/input/input.h:34:
In file included from ./core/input/input_event.h:35:
In file included from ./core/io/resource.h:34:
In file included from ./core/io/resource_uid.h:34:
In file included from ./core/object/ref_counted.h:34:
In file included from ./core/object/class_db.h:34:
In file included from ./core/object/method_bind.h:34:
In file included from ./core/variant/binder_common.h:35:
In file included from ./core/object/object.h:35:
In file included from ./core/object/message_queue.h:36:
In file included from ./core/variant/variant.h:60:
./core/variant/callable.h:78:43: error: conversion from 'unsigned long' to 'Variant' is ambiguous
                Variant args[sizeof...(p_args) + 1] = { p_args..., 0 }; // +1 makes sure zero sized arrays are also supported.
                                                        ^~~~~~
platform/linuxbsd/tts_linux.cpp:95:47: note: in instantiation of function template specialization 'Callable::call_deferred<unsigned long, unsigned long, int>' requested here
                callable_mp(tts, &TTS_Linux::_speech_event).call_deferred(p_msg_id, p_client_id, (int)p_type);
                                                            ^
./core/variant/variant.h:428:2: note: candidate constructor
        Variant(bool p_bool);
        ^
./core/variant/variant.h:429:2: note: candidate constructor
        Variant(signed int p_int); // real one
        ^
./core/variant/variant.h:430:2: note: candidate constructor
        Variant(unsigned int p_int);
        ^
./core/variant/variant.h:435:2: note: candidate constructor
        Variant(signed short p_short); // real one
        ^
./core/variant/variant.h:436:2: note: candidate constructor
        Variant(unsigned short p_short);
        ^
./core/variant/variant.h:437:2: note: candidate constructor
        Variant(signed char p_char); // real one
        ^
./core/variant/variant.h:438:2: note: candidate constructor
        Variant(unsigned char p_char);
        ^
./core/variant/variant.h:439:2: note: candidate constructor
        Variant(int64_t p_int); // real one
        ^
./core/variant/variant.h:440:2: note: candidate constructor
        Variant(uint64_t p_int);
        ^
./core/variant/variant.h:441:2: note: candidate constructor
        Variant(float p_float);
        ^
./core/variant/variant.h:442:2: note: candidate constructor
        Variant(double p_double);
        ^
In file included from platform/linuxbsd/tts_linux.cpp:31:
In file included from platform/linuxbsd/tts_linux.h:40:
In file included from ./servers/display_server.h:34:
In file included from ./core/input/input.h:34:
In file included from ./core/input/input_event.h:35:
In file included from ./core/io/resource.h:34:
In file included from ./core/io/resource_uid.h:34:
In file included from ./core/object/ref_counted.h:34:
In file included from ./core/object/class_db.h:34:
In file included from ./core/object/method_bind.h:34:
In file included from ./core/variant/binder_common.h:35:
In file included from ./core/object/object.h:35:
In file included from ./core/object/message_queue.h:36:
In file included from ./core/variant/variant.h:60:
./core/variant/callable.h:78:43: error: conversion from 'unsigned long' to 'Variant' is ambiguous
                Variant args[sizeof...(p_args) + 1] = { p_args..., 0 }; // +1 makes sure zero sized arrays are also supported.
                                                        ^~~~~~
./core/variant/variant.h:428:2: note: candidate constructor
        Variant(bool p_bool);
        ^
./core/variant/variant.h:429:2: note: candidate constructor
        Variant(signed int p_int); // real one
        ^
./core/variant/variant.h:430:2: note: candidate constructor
        Variant(unsigned int p_int);
        ^
./core/variant/variant.h:435:2: note: candidate constructor
        Variant(signed short p_short); // real one
        ^
./core/variant/variant.h:436:2: note: candidate constructor
        Variant(unsigned short p_short);
        ^
./core/variant/variant.h:437:2: note: candidate constructor
        Variant(signed char p_char); // real one
        ^
./core/variant/variant.h:438:2: note: candidate constructor
        Variant(unsigned char p_char);
        ^
./core/variant/variant.h:439:2: note: candidate constructor
        Variant(int64_t p_int); // real one
        ^
./core/variant/variant.h:440:2: note: candidate constructor
        Variant(uint64_t p_int);
        ^
./core/variant/variant.h:441:2: note: candidate constructor
        Variant(float p_float);
        ^
./core/variant/variant.h:442:2: note: candidate constructor
        Variant(double p_double);
        ^
5 errors generated.

Steps to reproduce

building from the 4.0 release tarball on OpenBSD

Minimal reproduction project

N/A

@akien-mga
Copy link
Member

CC @bruvzg as you might know more about when NEED_LONG_INT is required. Currently it's indeed defined only for iOS arm64:

$ rg NEED_LONG_INT
core/variant/variant.cpp
1496:#ifdef NEED_LONG_INT
2431:#ifdef NEED_LONG_INT

core/variant/variant.h
363:#ifdef NEED_LONG_INT
431:#ifdef NEED_LONG_INT

platform/ios/detect.py
134:        env.Append(CPPDEFINES=["NEED_LONG_INT"])

@bruvzg
Copy link
Member

bruvzg commented Mar 9, 2023

might know more about when NEED_LONG_INT is required

No idea, iOS ARM64 is building without it. It't probably was needed is neither int not int64_t is the same as long (but it's the case only on 16-bit Windows), I guess it was added when int64_t was not supported.

@omar-polo
Copy link
Contributor Author

Could it be since size_t/ssize_t are long typedef'd on OpenBSD/amd64?

% grep -R typedef /usr/include | grep size_t
[...]
amd64/_types.h:typedef  unsigned long           __size_t;
amd64/_types.h:typedef  long                    __ssize_t;

if so, unifdef'ing NEED_LONG_INT could be acceptable? It makes the long/unsigned long version of those functions available, shouldn't cause any issue but can't test on anything non-OpenBSD atm.

Don't know if it's related, but I also have to patch the embedded embree copy (see RenderKit/embree#379)

@nbonfils
Copy link

nbonfils commented Apr 2, 2023

I am also on OpenBSD -current and trying to build godot master leads to the exact same error for me, but I also get another error about quick_exit() being undeclared.

Here is the full trace along with the command I ran:
trace.txt

I am ok with C, but also not used to C++ at all.

@omar-polo
Copy link
Contributor Author

@nbonfils our libc doesn't seem to have quick_exit, I've locally replaced it with _exit instead (seems safe seeing how it is used.) (btw, I should be able to send a tarball for godot 4.0 to ports@ soon, which includes these patches as well as the ones needed for thirdparty)

omar-polo added a commit to omar-polo/godot that referenced this issue Apr 2, 2023
At least on OpenBSD the long/unsigned long version of the Variant
constructor and accessors are needed.  See godotengine#74669
@akien-mga akien-mga changed the title error: conversion from 'const Variant' to 'unsigned long' is ambiguous OpenBSD error: conversion from 'const Variant' to 'unsigned long' is ambiguous Jun 16, 2023
@akien-mga
Copy link
Member

I guess to solve this we can do something like this (untested, I don't know if platform.system() actually returns this):

diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py
index dadc03685b..adf0f76a7b 100644
--- a/platform/linuxbsd/detect.py
+++ b/platform/linuxbsd/detect.py
@@ -388,6 +388,9 @@ def configure(env: "Environment"):
         ]
     )
 
+    if platform.system() == "OpenBSD":
+        env.Append(CPPDEFINES=["NEED_LONG_INT"])
+
     if env["x11"]:
         if not env["use_sowrap"]:
             if os.system("pkg-config --exists x11"):

@YuriSizov YuriSizov modified the milestones: 4.1, 4.2 Jun 26, 2023
omar-polo added a commit to omar-polo/godot that referenced this issue Jun 28, 2023
At least on OpenBSD the long/unsigned long version of the Variant
constructor and accessors are needed.  See godotengine#74669
@omar-polo
Copy link
Contributor Author

sorry for the delay.

unfortunately -DNEED_LONG_INT doesn't seem to fix the build on OpenBSD :(

I'm not sure what I did months ago, but now it fails with:

./core/variant/callable.h:78:43: error: conversion from 'unsigned long' to 'Variant' is ambiguous
                Variant args[sizeof...(p_args) + 1] = { p_args..., 0 }; // +1 makes sure zero sized arrays are also supported.
                                                        ^~~~~~
./core/variant/variant.h:425:2: note: candidate constructor
        Variant(bool p_bool);
        ^
./core/variant/variant.h:426:2: note: candidate constructor
        Variant(signed int p_int); // real one
        ^
./core/variant/variant.h:427:2: note: candidate constructor
        Variant(unsigned int p_int);
        ^
./core/variant/variant.h:432:2: note: candidate constructor
        Variant(signed short p_short); // real one
        ^
./core/variant/variant.h:433:2: note: candidate constructor
        Variant(unsigned short p_short);
        ^
./core/variant/variant.h:434:2: note: candidate constructor
        Variant(signed char p_char); // real one
        ^
./core/variant/variant.h:435:2: note: candidate constructor
        Variant(unsigned char p_char);
        ^
./core/variant/variant.h:436:2: note: candidate constructor
        Variant(int64_t p_int); // real one
        ^
./core/variant/variant.h:437:2: note: candidate constructor
        Variant(uint64_t p_int);
        ^
./core/variant/variant.h:438:2: note: candidate constructor
        Variant(float p_float);
        ^
./core/variant/variant.h:439:2: note: candidate constructor
        Variant(double p_double);
        ^

which is a bit over my C++ ability, apologize!

@ceverettkoop
Copy link

I got a similar error on Godot 4.1 compiling on mingw on Windows (same code works fine on Linux).

As a workaround I was able to change long to int32_t and it compiles this way.

@omar-polo
Copy link
Contributor Author

#84017 fixes this for me.

@nbonfils
Copy link

nbonfils commented Oct 27, 2023

@omar-polo Awesome! Does this mean we'll have Godot 4 in the ports in the future?
If by any chance you already have ports file somewhere, I'd be glad if you could share them as well. :)

Edit:
I see I can find it here as well: https://github.com/jasperla/openbsd-wip/tree/master
Am I mistaken?

@omar-polo
Copy link
Contributor Author

@nbonfils yes, that's what @rfht and I have been working in the past days.

Note that the package name is temporarily "godot4", when it'll reach ports@ it will be named just "godot" (and a new package "godot3" will be added as well.)

@nbonfils
Copy link

Awesome, thank you and thanks everybody for their work on this, I was looking forward to this for a bit now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants