godotengine / godot

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

Building with LLVM 6 fails #41852

Closed BloodyMess closed 4 years ago

BloodyMess commented 4 years ago

Godot version: Build the latest zip snapshot of master.

OS/device including version: Hardware:

Software:

Issue description: (This issue was encountered while trying build option variations to see if they affected the LLVM LTO problem in #40279)

Building with LLVM fails with the following compile errors in modules/gdscript/gdscript_cache.cpp:

modules/gdscript/gdscript_cache.cpp:111:36: error: expected ')'
        MutexLock(GDScriptCache::singleton->lock);
                                          ^
modules/gdscript/gdscript_cache.cpp:111:11: note: to match this '('
        MutexLock(GDScriptCache::singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:111:27: error: definition or redeclaration of 'singleton' not allowed inside a function
        MutexLock(GDScriptCache::singleton->lock);
                  ~~~~~~~~~~~~~~~^
modules/gdscript/gdscript_cache.cpp:118:21: error: expected ')'
        MutexLock(singleton->lock);
                           ^
modules/gdscript/gdscript_cache.cpp:118:11: note: to match this '('
        MutexLock(singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:118:11: error: cannot use parentheses when declaring variable with deduced class template specialization type
        MutexLock(singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:118:12: error: declaration of variable 'singleton' with deduced type 'MutexLock' requires an initializer
        MutexLock(singleton->lock);
                  ^
modules/gdscript/gdscript_cache.cpp:124:21: error: expected ')'
        MutexLock(singleton->lock);
                           ^
modules/gdscript/gdscript_cache.cpp:124:11: note: to match this '('
        MutexLock(singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:124:11: error: cannot use parentheses when declaring variable with deduced class template specialization type
        MutexLock(singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:124:12: error: declaration of variable 'singleton' with deduced type 'MutexLock' requires an initializer
        MutexLock(singleton->lock);
                  ^
modules/gdscript/gdscript_cache.cpp:171:21: error: expected ')'
        MutexLock(singleton->lock);
                           ^
modules/gdscript/gdscript_cache.cpp:171:11: note: to match this '('
        MutexLock(singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:171:11: error: cannot use parentheses when declaring variable with deduced class template specialization type
        MutexLock(singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:171:12: error: declaration of variable 'singleton' with deduced type 'MutexLock' requires an initializer
        MutexLock(singleton->lock);
                  ^
modules/gdscript/gdscript_cache.cpp:193:21: error: expected ')'
        MutexLock(singleton->lock);
                           ^
modules/gdscript/gdscript_cache.cpp:193:11: note: to match this '('
        MutexLock(singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:193:11: error: cannot use parentheses when declaring variable with deduced class template specialization type
        MutexLock(singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:193:12: error: declaration of variable 'singleton' with deduced type 'MutexLock' requires an initializer
        MutexLock(singleton->lock);
                  ^

Steps to reproduce:

  1. Download a snapshot of the Godot source and extract it.
  2. Go into the project folder and build, making sure that the LLVM build option is enabled (other LLVM related options do not affect the result. Nor do the values given for the -j or optimize options). Example Build Command: scons -j24 platform=x11 target=debug optimize=size use_llvm=yes use_lld=yes
  3. The build fails when compiling modules/gdscript/gdscript_cache.cpp.

Minimal reproduction project: (not applicable)

akien-mga commented 4 years ago

Aren't there more errors further up the log? The first error doesn't make much sense but would usually happen as fallout of a previous syntax error.

BloodyMess commented 4 years ago

No. Those are the only error messages, copied directly from the terminal window.

Here's the entire output of the latest build attempt:

$ > scons -j24 platform=x11 target=debug use_llvm=yes
scons: Reading SConscript files ...
Platform "x11" has been renamed to "linuxbsd" in Godot 4.0. Building for platform "linuxbsd".
Enabling ALSA
Enabling PulseAudio
Checking for C header file mntent.h... (cached) yes
scons: done reading SConscript files.
scons: Building targets ...
[ 31%] Compiling ==> modules/gdscript/gdscript_cache.cpp
[ 33%] Linking Static Library ==> modules/libmodule_gdnavigation.linuxbsd.tools.64.llvm.a
[ 33%] Ranlib Library         ==> modules/libmodule_gdnavigation.linuxbsd.tools.64.llvm.a
[ 33%] Compiling ==> modules/gdnative/android/android_gdn.cpp
[ 33%] Compiling ==> modules/gdnative/gdnative/aabb.cpp
[ 33%] Compiling ==> modules/gdnative/gdnative/array.cpp
[ 33%] Compiling ==> modules/gdnative/gdnative/basis.cpp
[ 33%] Compiling ==> modules/gdnative/gdnative/callable.cpp
[ 33%] Compiling ==> modules/gdnative/gdnative/color.cpp
[ 33%] Compiling ==> modules/gdnative/gdnative/dictionary.cpp
[ 33%] Compiling ==> modules/gdnative/gdnative/gdnative.cpp
[ 33%] Compiling ==> modules/gdnative/gdnative/node_path.cpp
[ 33%] Compiling ==> modules/gdnative/gdnative/packed_arrays.cpp
[ 33%] Compiling ==> modules/gdnative/gdnative/plane.cpp
[ 33%] Compiling ==> modules/gdnative/gdnative/quat.cpp
[ 33%] Compiling ==> modules/gdnative/gdnative/rect2.cpp
[ 33%] Compiling ==> modules/gdnative/gdnative/rid.cpp
[ 33%] Compiling ==> modules/gdnative/gdnative/string.cpp
[ 34%] Compiling ==> modules/gdnative/gdnative/string_name.cpp
[ 34%] Compiling ==> modules/gdnative/gdnative/transform.cpp
[ 34%] Compiling ==> modules/gdnative/gdnative/transform2d.cpp
[ 34%] Compiling ==> modules/gdnative/gdnative/variant.cpp
[ 34%] Compiling ==> modules/gdnative/gdnative/vector2.cpp
[ 34%] Compiling ==> modules/gdnative/gdnative/vector3.cpp
[ 34%] Compiling ==> modules/gdnative/nativescript/api_generator.cpp
[ 34%] Compiling ==> modules/gdnative/nativescript/godot_nativescript.cpp
[ 34%] Compiling ==> modules/gdnative/nativescript/nativescript.cpp
[ 34%] Compiling ==> modules/gdnative/nativescript/register_types.cpp
modules/gdscript/gdscript_cache.cpp:111:36: error: expected ')'
        MutexLock(GDScriptCache::singleton->lock);
                                          ^
modules/gdscript/gdscript_cache.cpp:111:11: note: to match this '('
        MutexLock(GDScriptCache::singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:111:27: error: definition or redeclaration of 'singleton' not allowed inside a function
        MutexLock(GDScriptCache::singleton->lock);
                  ~~~~~~~~~~~~~~~^
modules/gdscript/gdscript_cache.cpp:118:21: error: expected ')'
        MutexLock(singleton->lock);
                           ^
modules/gdscript/gdscript_cache.cpp:118:11: note: to match this '('
        MutexLock(singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:118:11: error: cannot use parentheses when declaring variable with deduced class template specialization type
        MutexLock(singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:118:12: error: declaration of variable 'singleton' with deduced type 'MutexLock' requires an initializer
        MutexLock(singleton->lock);
                  ^
modules/gdscript/gdscript_cache.cpp:124:21: error: expected ')'
        MutexLock(singleton->lock);
                           ^
modules/gdscript/gdscript_cache.cpp:124:11: note: to match this '('
        MutexLock(singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:124:11: error: cannot use parentheses when declaring variable with deduced class template specialization type
        MutexLock(singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:124:12: error: declaration of variable 'singleton' with deduced type 'MutexLock' requires an initializer
        MutexLock(singleton->lock);
                  ^
modules/gdscript/gdscript_cache.cpp:171:21: error: expected ')'
        MutexLock(singleton->lock);
                           ^
modules/gdscript/gdscript_cache.cpp:171:11: note: to match this '('
        MutexLock(singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:171:11: error: cannot use parentheses when declaring variable with deduced class template specialization type
        MutexLock(singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:171:12: error: declaration of variable 'singleton' with deduced type 'MutexLock' requires an initializer
        MutexLock(singleton->lock);
                  ^
modules/gdscript/gdscript_cache.cpp:193:21: error: expected ')'
        MutexLock(singleton->lock);
                           ^
modules/gdscript/gdscript_cache.cpp:193:11: note: to match this '('
        MutexLock(singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:193:11: error: cannot use parentheses when declaring variable with deduced class template specialization type
        MutexLock(singleton->lock);
                 ^
modules/gdscript/gdscript_cache.cpp:193:12: error: declaration of variable 'singleton' with deduced type 'MutexLock' requires an initializer
        MutexLock(singleton->lock);
                  ^
[ 34%] Compiling ==> modules/gdnative/gdnative_library_singleton_editor.cpp
[ 34%] Compiling ==> modules/gdnative/gdnative_library_editor_plugin.cpp
[ 34%] Compiling ==> modules/gdnative/net/multiplayer_peer_gdnative.cpp
[ 34%] Compiling ==> modules/gdnative/net/packet_peer_gdnative.cpp
[ 34%] Compiling ==> modules/gdnative/net/register_types.cpp
[ 34%] Compiling ==> modules/gdnative/net/stream_peer_gdnative.cpp
[ 34%] Compiling ==> modules/gdnative/net/webrtc_gdnative.cpp
[ 34%] Compiling ==> modules/gdnative/xr/register_types.cpp
[ 34%] 14 errors generated.
Compiling ==> modules/gdnative/xr/xr_interface_gdnative.cpp
scons: *** [modules/gdscript/gdscript_cache.linuxbsd.tools.64.llvm.o] Error 1
modules/gdnative/xr/xr_interface_gdnative.cpp:273:2: warning: this needs to be redone [-W#warnings]
#warning this needs to be redone
 ^
modules/gdnative/xr/xr_interface_gdnative.cpp:290:2: warning: need to obtain this ID again [-W#warnings]
#warning need to obtain this ID again
 ^
2 warnings generated.
modules/gdnative/nativescript/nativescript.cpp:116:2: warning: inheritance needs to be implemented in NativeScript [-W#warnings]
#warning inheritance needs to be implemented in NativeScript
 ^
1 warning generated.
scons: building terminated because of errors.
Anutrix commented 4 years ago

Try without -j24. It should give better results in terms of clarity.

akien-mga commented 4 years ago

It builds fine for me with scons p=linuxbsd use_llvm=yes -j6 with clang 10.0.0.

bruvzg commented 4 years ago

Building fine with clang-10 on Linux and MinGW, and Apple clang-1200 on macOS.

Are you sure clang-10 is selected as default compiler on your system (CC environment variable, etc)? Try adding AS=llvm-ar-10 CC=clang-10 CXX=clang++-10 AR=llvm-ar-10 RANLIB=llvm-ranlib-10 LINK=clang++-10 to the end of build command.

BloodyMess commented 4 years ago

Are you sure clang-10 is selected as default compiler on your system (CC environment variable, etc)? Try adding AS=llvm-ar-10 CC=clang-10 CXX=clang++-10 AR=llvm-ar-10 RANLIB=llvm-ranlib-10 LINK=clang++-10 to the end of build command.

That got it building again!

Now that this build problem is out of the way, I can get back to trying to build Godot with LLVM's LTO (which is still failing, but with different and fewer error messages.).

Is there an existing way to configure Scons, or the build scripts, to use a specific version of a compiler/toolchain? Or is that something that has to be done in the environment variables, etc?

I'm sorry I'm such a noob with command line. I know the C++ language quite well, I just never realized how spoiled I was by the sheltered environment of IDE's.

What's a good resource for learning to configure/maintain the defaults/environment for building on the command line? This distro comes with both gcc and llvm/clang-6 installed, and I'm very hesitant to nuke or mess with something that's more or less stable.

Also: Would it be better to move these questions to someplace like godotforums.org?

akien-mga commented 4 years ago

If clang 6 fails building the current source, we should probably up the min requirement in SConstruct (currently clang 6+ for proper support of C++17 guaranteed copy elision).

muzzician commented 4 years ago

I've got exact the same 14 errors, and no above additions to the command line helps... Please help. I am on XCode Version 10.1 (10B61). My default C compiler is clang. What Do I do wrong? Is that clang version, is that a C++17 I am missing?

BloodyMess commented 4 years ago

@muzzician : Those additions to the command line can only help if you have llvm/clang 10 installed. It looks like Apple's custom build of Clang that is included with XCode 10 is based on llvm/clang-6.x. XCode doesn't include llvm/clang-10 until XCode 12.

It sounds like you might need to install an up to date version of llvm/clang. I haven't used XCode in years, so I have no idea of whether that's feasible on MacOS these days.

@akien-mga : Since MacOS development relies on XCode with its custom clang, and XCode versions are basically tied to versions of MacOS... What would upping the minimum clang version do to Godot's compatibility with earlier versions of MacOS?

muzzician commented 4 years ago

It sounds like you might need to install an up to date version of llvm/clang. I haven't used XCode in years, so I have no idea of whether that's feasible on MacOS these days.

Thanks BloodyMess! Great pointer! To my (humble) knowledge it requires update chain: Catalina->XCode->Clang... I have to avoid Catalina for now. Is there a way to compile using gcc/g++ or other compiler? Godot says xcode on mac is required. I am a bit lost. Even thinking compiling in VBox emulating Windows. I was able to compile godotengine in Windows in the past with no problems.

bruvzg commented 4 years ago

It looks like Apple's custom build of Clang that is included with XCode 10 is based on llvm/clang-6.x

Xcode 10.2+ is based on LLVM 7.0.0, current version (Xcode 11.7) clang is based on LLVM 9.0 and beta (Xcode 12) on LLVM 10.0.

It is possible to use both GCC on upstream versions of LLVM on macOS (by building one or installing pre-build via homebrew or macports) but you still need Xcode for macOS SDK.

akien-mga commented 4 years ago

41904 should fix compatibility with LLVM 6.

muzzician commented 4 years ago

41904 should fix compatibility with LLVM 6.

Great to have this version-sensitive issue addressed! Thanks.