godotengine / godotengine/godot-cpp
Cannot build my GDExtension with Godot 4.4
- Dominant language
- C++
- Stars
- 2.7k
- Forks
- 809
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 8
Description
### Tested versions
Reproducible with Godot 4.4
Not reproducible with Godot 4.3
### System information
Godot v4.4.1.rc (afaa0cd4b) - Ubuntu 22.04.5 LTS 22.04 on X11 - X11 display driver, Multi-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1070 (nvidia; 535.183.01) - Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz (8 threads)
### Issue description
I encountered an unusual build error while porting my project from Godot 4.3 to 4.4. My project consists of several custom modules registering 94 classes to `ClassDB` and a small GDExtension written in C++.
Godot 4.4 itself builds without errors, and godot-cpp for 4.4 also compiles successfully. However, building my extension fails with the following error:
```
$ scons platform=linux dev_build=yes compiledb=true precision=double disable_exceptions=false verbose=true
scons: Reading SConscript files ...
Auto-detected 8 CPU cores available for build parallelism. Using 7 cores by default. You can override it with the -j argument.
Building for architecture x86_64 on platform linux
scons: done reading SConscript files.
scons: Building targets ...
ar rc /bin/libgodot-cpp.linux.template_debug.dev.double.x86_64.a
scons: *** [/bin/libgodot-cpp.linux.template_debug.dev.double.x86_64.a] sh: Argument list too long
scons: building terminated because of errors.
```
In the `ar rc` command, 1050 object files are listed, including the 94 from my project. The total length of the arguments is 131,107 characters. I believe the error occurs because the arguments are interpreted as a single entity, exceeding the system's limit of [MAX_ARG_STRLEN (131,072)](https://stackoverflow.com/questions/11475221/why-do-i-get-bin-sh-argument-list-too-long-when-passing-quoted-arguments).
To confirm this, I commented out some of my `GDREGISTER_CLASS` calls to reduce the total argument length below the threshold, and the build succeeded. Another potential workaround could be relocating my project to a directory with a shorter path (though I haven’t tested this; my current project path is only 47 characters long).
As Godot continues to grow, I suspect more users on similar Unix-like systems will encounter this limitation.
I'm unsure whether to report this issue to godot-cpp, or even scons directly, given its potential impact on Godot’s documentation. Please let me know if I should transfer this bug report elsewhere.
Notes:
- The issue occurs with both scons 4.0 and 4.9.
- Enabling the scons stack trace (`--debug=stacktrace`) produces the following error when the build fails:
```
scons: internal stack trace:
File "/home/mla/.local/lib/python3.10/site-packages/SCons/Taskmaster/Job.py", line 737, in _work
task.execute()
File "/home/mla/.local/lib/python3.10/site-packages/SCons/Script/Main.py", line 224, in execute
SCons.Taskmaster.OutOfDateTask.execute(self)
File "/home/mla/.local/lib/python3.10/site-packages/SCons/Taskmaster/__init__.py", line 263, in execute
raise buildError
```
### Steps to reproduce
Increase the number of classes registered to `ClassDB` then build the [GDextension C++ example](https://docs.godotengine.org/en/4.3/tutorials/scripting/gdextension/gdextension_cpp_example.html)
### Minimal reproduction project (MRP)
Let me know if you need one (it's not a trivial task)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.