ddnet icon indicating copy to clipboard operation
ddnet copied to clipboard

WIP Rust PoC

Open heinrich5991 opened this issue 3 years ago • 35 comments

heinrich5991 avatar Jul 09 '22 14:07 heinrich5991

The stuff in src/rust-bridge is autogenerated using

cxxbridge src/engine/shared/rust_version.rs --output src/rust-bridge/engine/shared/rust_version.cpp --output src/rust-bridge/engine/shared/rust_version.h
cxxbridge src/engine/console.rs --output src/rust-bridge/cpp/console.cpp --output src/rust-bridge/cpp/console.h

Binary sizes do get a lot larger, probably not by an acceptable amount:

$ ls -lh */DDNet{,-Server} # before
 28M build/DDNet*
8.3M build/DDNet-Server*
3.9M ipo/DDNet*
1.9M ipo/DDNet-Server*
$ ls -lh */DDNet{,-Server} # after
 33M build/DDNet*
 13M build/DDNet-Server*
8.6M ipo/DDNet*
6.6M ipo/DDNet-Server*

I.e. DDNet-Server goes from 1.9 MiB to 6.6 MiB, and DDNet goes from 3.9 MiB to 8.6 MiB.

There are some problems with the bindings, cxx doesn't seem to support nested classes, so I had to typedef them. Not nice, maybe we could somehow pull request this into cxx.

Linux-only currently.

It adds a console command that prints the rustc version that was used to compile DDNet.

heinrich5991 avatar Jul 09 '22 14:07 heinrich5991

Haters gonna hate, but IMO we should not let it die bcs of a few MBytes. That's our smallest problem

Jupeyy avatar Jul 09 '22 15:07 Jupeyy

I guess compile time is more interesting.

C0D3D3V avatar Jul 09 '22 15:07 C0D3D3V

Also missing support for debug builds. No thoughts have been spent on cross-compilation so far.

I enabled LTO and build-std for the Rust part, this brought it down to:

$ ls -lh */DDNet{,-Server}
 29M build/DDNet*
8.9M build/DDNet-Server*
4.4M ipo/DDNet*
2.4M ipo/DDNet-Server*

So DDNet goes from 8.3 MiB to 8.9 MiB; DDNet-Server goes from 1.9 MiB to 2.4 MiB, both a ~600 KiB increase, which I would consider acceptable.

I guess compile time is more interesting.

I haven't measured compile times.

heinrich5991 avatar Jul 09 '22 15:07 heinrich5991

@def- This is becoming somewhat ready. Can I help you try build it on your machine?

heinrich5991 avatar Jul 17 '22 13:07 heinrich5991

What do I need? Rust installed or anything else?

def- avatar Jul 17 '22 14:07 def-

Theoretically only Rust installed. I have only tested win64 cross-compilation.

heinrich5991 avatar Jul 17 '22 14:07 heinrich5991

Linux build failed:

+build_linux:2> PLATFORM=x86_64 
+build_linux:3> DIR=/home/deen/isos/ddnet/debian10 
+build_linux:5> cd /home/deen/isos/ddnet/debian10
+build_linux:6> mkdir -p proc sys dev
+build_linux:7> umount proc sys dev
+build_linux:7> true
+build_linux:8> mount -t proc proc proc/
+build_linux:9> mount -t sysfs sys sys/
+build_linux:10> mount -o bind /dev dev/
+build_linux:12> rm -rf ddnet-source ddnet-source-steam ddnet-libs-source ddnet-ddnet_rust ddnet-libs-master
+build_linux:13> unzip -q /home/deen/isos/ddnet/main.zip
+build_linux:14> unzip -q /home/deen/isos/ddnet/libs.zip
+build_linux:15> mv ddnet-ddnet_rust ddnet-source
+build_linux:16> rm -rf ddnet-source/ddnet-libs
+build_linux:17> mv ddnet-libs-master ddnet-source/ddnet-libs
+build_linux:18> cp -r ddnet-source ddnet-source-steam
+build_linux:21> [ x86_64 '=' x86_64 ']'
+build_linux:22> DISCORD=ON 
+build_linux:27> echo '-DAUTOUPDATE=ON'
+build_linux:27> chroot . sh -c 'cd ddnet-source &&     export CXXFLAGS="'\''-DDDNET_CHECKSUM_SALT={{0xf9,0xb4,0x3c,0x8e,0xe2,0x1e,0x34,0x14,0x94,0x83,0x5b,0xe1,0x11,0xf3,0x94,0xf2}}'\'' -no-pie" &&     export LDFLAGS="-no-pie" &&     cmake -DVERSION=rust -DCMAKE_BUILD_TYPE=Release -DDISCORD=ON -DDISCORD_DYNAMIC=ON -DWEBSOCKETS=OFF -DIPO=ON -DAUTOUPDATE=ON -DPREFER_BUNDLED_LIBS=ON &&     make -j1 package_default'
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test HAVE_ATOMICS_WITHOUT_LIB
-- Performing Test HAVE_ATOMICS_WITHOUT_LIB - Success
-- Looking for __i386
-- Looking for __i386 - not found
-- IPO is enabled
-- Performing Test FLAG_SUPPORTED_fstack_protector_all
-- Performing Test FLAG_SUPPORTED_fstack_protector_all - Success
-- Performing Test FLAG_SUPPORTED_fno_exceptions
-- Performing Test FLAG_SUPPORTED_fno_exceptions - Success
-- Performing Test FLAG_SUPPORTED_Wall
-- Performing Test FLAG_SUPPORTED_Wall - Success
-- Performing Test FLAG_SUPPORTED_Wdeclaration_after_statement
-- Performing Test FLAG_SUPPORTED_Wdeclaration_after_statement - Failed
-- Performing Test FLAG_SUPPORTED_Wextra
-- Performing Test FLAG_SUPPORTED_Wextra - Success
-- Performing Test FLAG_SUPPORTED_Wno_unused_parameter
-- Performing Test FLAG_SUPPORTED_Wno_unused_parameter - Success
-- Performing Test FLAG_SUPPORTED_Wno_missing_field_initializers
-- Performing Test FLAG_SUPPORTED_Wno_missing_field_initializers - Success
-- Performing Test FLAG_SUPPORTED_Wformat_2
-- Performing Test FLAG_SUPPORTED_Wformat_2 - Success
-- Performing Test FLAG_SUPPORTED_Wno_implicit_function_declaration
-- Performing Test FLAG_SUPPORTED_Wno_implicit_function_declaration - Success
-- Performing Test FLAG_SUPPORTED_Wno_nullability_completeness
-- Performing Test FLAG_SUPPORTED_Wno_nullability_completeness - Success
-- Performing Test FLAG_SUPPORTED_Wduplicated_cond
-- Performing Test FLAG_SUPPORTED_Wduplicated_cond - Success
-- Performing Test FLAG_SUPPORTED_Wduplicated_branches
-- Performing Test FLAG_SUPPORTED_Wduplicated_branches - Success
-- Performing Test FLAG_SUPPORTED_Wlogical_op
-- Performing Test FLAG_SUPPORTED_Wlogical_op - Success
-- Performing Test FLAG_SUPPORTED_Wrestrict
-- Performing Test FLAG_SUPPORTED_Wrestrict - Success
-- Performing Test FLAG_SUPPORTED_Wshadow_all
-- Performing Test FLAG_SUPPORTED_Wshadow_all - Failed
-- Performing Test FLAG_SUPPORTED_Wshadow_global
-- Performing Test FLAG_SUPPORTED_Wshadow_global - Success
-- Performing Test FLAG_SUPPORTED_Wthread_safety
-- Performing Test FLAG_SUPPORTED_Wthread_safety - Failed
-- Performing Test FLAG_SUPPORTED_Wthread_safety_negative
-- Performing Test FLAG_SUPPORTED_Wthread_safety_negative - Failed
-- Performing Test FLAG_SUPPORTED_Wsuggest_override
-- Performing Test FLAG_SUPPORTED_Wsuggest_override - Success
-- Performing Test DEFINE_FORTIFY_SOURCE
-- Performing Test DEFINE_FORTIFY_SOURCE - Success
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29") 
-- Found ZLIB: src/engine/external/zlib (found version "rust") 
-- Could NOT find Crypto (missing: CRYPTO_LIBRARY CRYPTO_INCLUDEDIR) (found version "rust")
-- Checking for module 'libcurl'
--   Found libcurl, version 7.64.0
-- Found Curl: /ddnet-source/ddnet-libs/curl/linux/lib64/libcurl.so (found version "rust") 
-- Checking for module 'libavcodec'
--   No package 'libavcodec' found
-- Checking for module 'libavformat'
--   No package 'libavformat' found
-- Checking for module 'libavutil'
--   No package 'libavutil' found
-- Checking for module 'libswscale'
--   No package 'libswscale' found
-- Checking for module 'libswresample'
--   No package 'libswresample' found
-- Checking for one of the modules 'libx264;x264'
-- Found FFMPEG: /ddnet-source/ddnet-libs/ffmpeg/linux/lib64/libavcodec.a (found version "rust") 
-- Checking for module 'freetype2'
--   Found freetype2, version 22.1.16
-- Found Freetype: /usr/lib/x86_64-linux-gnu/libfreetype.so (found version "rust") 
-- Found GLEW: src/engine/external/glew (found version "rust") 
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY) (found version "rust")
-- Checking for module 'ogg'
--   No package 'ogg' found
-- Found Ogg: /ddnet-source/ddnet-libs/opus/include (found version "rust") 
-- Checking for module 'opus'
--   No package 'opus' found
-- Found Opus: /ddnet-source/ddnet-libs/opus/include/opus (found version "rust") 
-- Checking for module 'opusfile'
--   No package 'opusfile' found
-- Found Opusfile: /ddnet-source/ddnet-libs/opus/linux/lib64/libopusfile.a (found version "rust") 
-- Found PNG: /ddnet-source/ddnet-libs/png/linux/lib64/libpng16.a (found version "rust") 
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.7.3", minimum required is "3") 
-- Could NOT find Rust (missing: RUST_RUSTC RUST_CARGO) (found version "rust")
-- Checking for module 'sdl2'
--   Found sdl2, version 2.0.6
-- Found SDL2: /usr/local/lib/libSDL2.so (found version "rust") 
-- Checking for module 'sqlite3'
--   Found sqlite3, version 3.32.3
-- Found SQLite3: /ddnet-source/ddnet-libs/sqlite3/include (found version "rust") 
-- Found DiscordSdk: /ddnet-source/ddnet-libs/discord/linux/lib64/discord_game_sdk.so (found version "rust") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE (found version "rust") 
-- Found Wavpack: src/engine/external/wavpack (found version "rust") 
-- Checking for module 'vulkan'
--   Found vulkan, version 1.1.97
-- Building vulkan shaders
/ddnet-source/data/shader/vulkan/quad.vert
-- Finished building vulkan shaders
-- ******** DDNet ********
-- Target OS: linux x86_64
-- Compiler: /usr/bin/c++
-- Rust version: 
-- Build type: Release
-- Dependencies:
--  * Curl not found (using bundled version)
--  * FFmpeg not found (using bundled version)
--  * Freetype found
--  * Glew not found (using bundled version)
--  * GTest not found
--  * Ogg found
--  * OpenSSL Crypto not found
--  * Opus found
--  * Opusfile not found (using bundled version)
--  * PNG not found (using bundled version)
--  * PythonInterp found
--  * SDL2 found
--  * SQLite3 not found (using bundled version)
--  * Wavpack not found (using bundled version)
--  * Zlib not found (using bundled version)
--  * DiscordSdk found
--  * Vulkan found
-- To run the tests, you have to install GTest
-- Found Notify: notify;gdk_pixbuf-2.0;gio-2.0;gobject-2.0;glib-2.0 (found version "rust") 
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libGL.so (found version "rust") 
-- Looking for WavpackOpenFileInputEx
-- Looking for WavpackOpenFileInputEx - not found
-- Looking for WavpackCloseFile
-- Looking for WavpackCloseFile - not found
-- Configuring done
-- Generating done
-- Build files have been written to: /ddnet-source
[  0%] Generating src/game/generated/protocolglue.h
[  0%] Generating src/game/generated/git_revision.cpp
[  0%] Generating src/game/generated/protocol.h
[  1%] Generating src/game/generated/protocol7.h
Scanning dependencies of target game-shared
[  1%] Building CXX object CMakeFiles/game-shared.dir/src/game/bezier.cpp.o
[  2%] Building CXX object CMakeFiles/game-shared.dir/src/game/collision.cpp.o
[  2%] Building CXX object CMakeFiles/game-shared.dir/src/game/gamecore.cpp.o
[  2%] Building CXX object CMakeFiles/game-shared.dir/src/game/layers.cpp.o
[  3%] Building CXX object CMakeFiles/game-shared.dir/src/game/localization.cpp.o
[  3%] Building CXX object CMakeFiles/game-shared.dir/src/game/mapbugs.cpp.o
[  3%] Building CXX object CMakeFiles/game-shared.dir/src/game/mapitems.cpp.o
[  4%] Building CXX object CMakeFiles/game-shared.dir/src/game/prng.cpp.o
[  4%] Building CXX object CMakeFiles/game-shared.dir/src/game/teamscore.cpp.o
[  5%] Building CXX object CMakeFiles/game-shared.dir/src/game/generated/git_revision.cpp.o
[  5%] Built target game-shared
Scanning dependencies of target json
[  5%] Building C object CMakeFiles/json.dir/src/engine/external/json-parser/json.c.o
[  5%] Built target json
Scanning dependencies of target zlib
[  6%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/adler32.c.o
[  6%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/compress.c.o
[  6%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/crc32.c.o
[  7%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/deflate.c.o
[  7%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/gzclose.c.o
[  7%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/gzlib.c.o
[  8%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/gzread.c.o
[  8%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/gzwrite.c.o
[  8%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/infback.c.o
[ 10%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/inffast.c.o
[ 10%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/inflate.c.o
[ 10%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/inftrees.c.o
[ 11%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/trees.c.o
[ 11%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/uncompr.c.o
[ 12%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/zutil.c.o
[ 12%] Built target zlib
Scanning dependencies of target rust-bridge-shared
[ 13%] Building CXX object CMakeFiles/rust-bridge-shared.dir/src/rust-bridge/cpp/console.cpp.o
[ 13%] Building CXX object CMakeFiles/rust-bridge-shared.dir/src/rust-bridge/engine/shared/rust_version.cpp.o
[ 13%] Built target rust-bridge-shared
Scanning dependencies of target md5
[ 13%] Building C object CMakeFiles/md5.dir/src/engine/external/md5/md5.c.o
[ 13%] Built target md5
Scanning dependencies of target rust_engine_shared_target
[ 13%] Generating release/libddnet_engine_shared.a
No such file or directory
make[3]: *** [CMakeFiles/rust_engine_shared_target.dir/build.make:74: release/libddnet_engine_shared.a] Error 1
make[2]: *** [CMakeFiles/Makefile2:1139: CMakeFiles/rust_engine_shared_target.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:692: CMakeFiles/package_default.dir/rule] Error 2
make: *** [Makefile:394: package_default] Error 2

This is with Rust 1.62.0 installed in the Debian 10 chroot.

Windows build fails differently, also with Rust 1.62.0 installed on the Arch system:

+./build.sh:232> TARGET_FAMILY=windows TARGET_PLATFORM=win32 TARGET_ARCH=ia32 PREFIX=i686-w64-mingw32- PATH=/usr/i686-w64-mingw32/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin::/opt/android-ndk:/opt/android-sdk/tools:/opt/android-sdk/tools/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/local/bin:/opt/android-sdk/build-tools/23.0.3:/opt/android-sdk/tools:/opt/android-ndk:/opt/android-sdk/platform-tools +./build.sh:232> build_windows_website 32 '-DIPO=OFF'
+build_windows_website:2> PLATFORM=32 
+build_windows_website:3> BUILDOPTS='-DIPO=OFF' 
+build_windows_website:4> echo '-DIPO=OFF'
+build_windows_website:4> CXXFLAGS=\''-DDDNET_CHECKSUM_SALT={{0xf9,0xb4,0x3c,0x8e,0xe2,0x1e,0x34,0x14,0x94,0x83,0x5b,0xe1,0x11,0xf3,0x94,0xf2}}'\'' -pie' +build_windows_website:4> build_windows 32 '-DAUTOUPDATE=ON -DIPO=OFF'
+build_windows:2> PLATFORM=32 
+build_windows:3> BUILDOPTS='-DAUTOUPDATE=ON -DIPO=OFF' 
+build_windows:4> SUFFIX='' 
+build_windows:5> DIR=win32 
+build_windows:7> rm -rf win32
+build_windows:8> mkdir win32
+build_windows:9> cd win32
+build_windows:10> echo '-DAUTOUPDATE=ON -DIPO=OFF'
+build_windows:10> cmake '-DVERSION=rust' '-DCMAKE_BUILD_TYPE=RelWithDebInfo' '-DDISCORD=ON' '-DWEBSOCKETS=OFF' '-DPREFER_BUNDLED_LIBS=ON' '-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/mingw32.toolchain' '-DCMAKE_DISABLE_FIND_PACKAGE_GTest=ON' '-DEXCEPTION_HANDLING=ON' '-DAUTOUPDATE=ON' '-DIPO=OFF' ../ddnet-source
-- The C compiler identification is GNU 12.1.0
-- The CXX compiler identification is GNU 12.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/sbin/i686-w64-mingw32-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/sbin/i686-w64-mingw32-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test HAVE_ATOMICS_WITHOUT_LIB
-- Performing Test HAVE_ATOMICS_WITHOUT_LIB - Success
-- Looking for __i386
-- Looking for __i386 - found
-- Performing Test FLAG_SUPPORTED_fuse_ld_mold
-- Performing Test FLAG_SUPPORTED_fuse_ld_mold - Failed
-- Performing Test FLAG_SUPPORTED_fuse_ld_lld
-- Performing Test FLAG_SUPPORTED_fuse_ld_lld - Failed
-- Performing Test FLAG_SUPPORTED_fuse_ld_gold
-- Performing Test FLAG_SUPPORTED_fuse_ld_gold - Failed
-- Performing Test FLAG_SUPPORTED_fstack_protector_all
-- Performing Test FLAG_SUPPORTED_fstack_protector_all - Failed
-- Performing Test FLAG_SUPPORTED_fno_exceptions
-- Performing Test FLAG_SUPPORTED_fno_exceptions - Success
-- Performing Test FLAG_SUPPORTED_ffloat_store
-- Performing Test FLAG_SUPPORTED_ffloat_store - Success
-- Performing Test FLAG_SUPPORTED_Wl___no_insert_timestamp
-- Performing Test FLAG_SUPPORTED_Wl___no_insert_timestamp - Success
-- Performing Test FLAG_SUPPORTED_DCONF_EXCEPTION_HANDLING
-- Performing Test FLAG_SUPPORTED_DCONF_EXCEPTION_HANDLING - Success
-- Performing Test FLAG_SUPPORTED_fno_omit_frame_pointer
-- Performing Test FLAG_SUPPORTED_fno_omit_frame_pointer - Success
-- Performing Test FLAG_SUPPORTED_Wall
-- Performing Test FLAG_SUPPORTED_Wall - Success
-- Performing Test FLAG_SUPPORTED_Wdeclaration_after_statement
-- Performing Test FLAG_SUPPORTED_Wdeclaration_after_statement - Failed
-- Performing Test FLAG_SUPPORTED_Wextra
-- Performing Test FLAG_SUPPORTED_Wextra - Success
-- Performing Test FLAG_SUPPORTED_Wno_unused_parameter
-- Performing Test FLAG_SUPPORTED_Wno_unused_parameter - Success
-- Performing Test FLAG_SUPPORTED_Wno_missing_field_initializers
-- Performing Test FLAG_SUPPORTED_Wno_missing_field_initializers - Success
-- Performing Test FLAG_SUPPORTED_Wformat_2
-- Performing Test FLAG_SUPPORTED_Wformat_2 - Success
-- Performing Test FLAG_SUPPORTED_Wno_implicit_function_declaration
-- Performing Test FLAG_SUPPORTED_Wno_implicit_function_declaration - Success
-- Performing Test FLAG_SUPPORTED_Wno_nullability_completeness
-- Performing Test FLAG_SUPPORTED_Wno_nullability_completeness - Success
-- Performing Test FLAG_SUPPORTED_Wduplicated_cond
-- Performing Test FLAG_SUPPORTED_Wduplicated_cond - Success
-- Performing Test FLAG_SUPPORTED_Wduplicated_branches
-- Performing Test FLAG_SUPPORTED_Wduplicated_branches - Success
-- Performing Test FLAG_SUPPORTED_Wlogical_op
-- Performing Test FLAG_SUPPORTED_Wlogical_op - Success
-- Performing Test FLAG_SUPPORTED_Wrestrict
-- Performing Test FLAG_SUPPORTED_Wrestrict - Success
-- Performing Test FLAG_SUPPORTED_Wshadow_all
-- Performing Test FLAG_SUPPORTED_Wshadow_all - Failed
-- Performing Test FLAG_SUPPORTED_Wshadow_global
-- Performing Test FLAG_SUPPORTED_Wshadow_global - Success
-- Performing Test FLAG_SUPPORTED_Wthread_safety
-- Performing Test FLAG_SUPPORTED_Wthread_safety - Failed
-- Performing Test FLAG_SUPPORTED_Wthread_safety_negative
-- Performing Test FLAG_SUPPORTED_Wthread_safety_negative - Failed
-- Performing Test FLAG_SUPPORTED_Wsuggest_override
-- Performing Test FLAG_SUPPORTED_Wsuggest_override - Success
-- Performing Test FLAG_SUPPORTED_Wno_alloc_size_larger_than
-- Performing Test FLAG_SUPPORTED_Wno_alloc_size_larger_than - Success
-- Performing Test DEFINE_FORTIFY_SOURCE
-- Performing Test DEFINE_FORTIFY_SOURCE - Success
-- Found ZLIB: src/engine/external/zlib  
-- Could NOT find Crypto (missing: CRYPTO_LIBRARY CRYPTO_INCLUDEDIR) 
-- Found Curl: /home/deen/isos/ddnet/ddnet-source/ddnet-libs/curl/windows/lib32/curl.lib  
-- Found FFMPEG: /home/deen/isos/ddnet/ddnet-source/ddnet-libs/ffmpeg/windows/lib32/avcodec.lib  
-- Found Freetype: /home/deen/isos/ddnet/ddnet-source/ddnet-libs/freetype/windows/lib32/freetype.lib  
-- Found Git: /usr/sbin/git (found version "2.37.1") 
-- Found GLEW: src/engine/external/glew  
-- Found Ogg: /home/deen/isos/ddnet/ddnet-source/ddnet-libs/opus/include  
-- Found Opus: /home/deen/isos/ddnet/ddnet-source/ddnet-libs/opus/include/opus  
-- Found Opusfile: /home/deen/isos/ddnet/ddnet-source/ddnet-libs/opus/windows/lib32/opusfile.lib  
-- Found PNG: /home/deen/isos/ddnet/ddnet-source/ddnet-libs/png/windows/lib32/libpng16-16.lib  
-- Found PythonInterp: /usr/sbin/python3 (found suitable version "3.10.5", minimum required is "3") 
-- Found Rust: /usr/sbin/rustc  
-- Found SDL2: /home/deen/isos/ddnet/ddnet-source/ddnet-libs/sdl/windows/lib32/SDL2.lib  
-- Found SQLite3: /home/deen/isos/ddnet/ddnet-source/ddnet-libs/sqlite3/include  
-- Found DiscordSdk: /home/deen/isos/ddnet/ddnet-source/ddnet-libs/discord/windows/lib32/discord_game_sdk.dll.lib  
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found Wavpack: src/engine/external/wavpack  
-- ******** DDNet ********
-- Target OS: windows 
-- Compiler: /usr/sbin/i686-w64-mingw32-g++
-- Rust version: rustc 1.62.0 (Arch Linux rust 1:1.62.0-1)
-- Build type: RelWithDebInfo
-- Dependencies:
--  * Curl not found (using bundled version)
--  * FFmpeg not found (using bundled version)
--  * Freetype not found (using bundled version)
--  * Git found
--  * Glew not found (using bundled version)
--  * GTest not found
--  * Ogg found
--  * OpenSSL Crypto not found
--  * Opus found
--  * Opusfile not found (using bundled version)
--  * PNG not found (using bundled version)
--  * PythonInterp found
--  * SDL2 not found (using bundled version)
--  * SQLite3 not found (using bundled version)
--  * Wavpack not found (using bundled version)
--  * Zlib not found (using bundled version)
--  * DiscordSdk found
-- Automatically downloading GTest to be able to run tests
-- Configuring done
-- Generating done
-- Build files have been written to: /home/deen/isos/ddnet/win32/googletest-download
[ 11%] Creating directories for 'googletest'
[ 22%] Performing download step (git clone) for 'googletest'
Cloning into 'googletest-src'...
HEAD is now at 5c8ca58e Googletest export
[ 33%] Performing update step for 'googletest'
[ 44%] No patch step for 'googletest'
[ 55%] No configure step for 'googletest'
[ 66%] No build step for 'googletest'
[ 77%] No install step for 'googletest'
[ 88%] No test step for 'googletest'
[100%] Completed 'googletest'
[100%] Built target googletest
-- Found Python: /usr/sbin/python3.10 (found version "3.10.5") found components: Interpreter 
-- Looking for WavpackOpenFileInputEx
-- Looking for WavpackOpenFileInputEx - not found
-- Looking for WavpackCloseFile
-- Looking for WavpackCloseFile - not found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/deen/isos/ddnet/win32
+build_windows:11> make -j1
[  0%] Building CXX object CMakeFiles/steam_api.dir/src/steam/steam_api_stub.cpp.obj
[  0%] Linking CXX shared library steam_api.dll
[  0%] Built target steam_api
[  0%] Generating src/game/generated/protocolglue.h
[  0%] Generating src/game/generated/protocol.cpp
[  0%] Generating src/game/generated/protocol.h
[  0%] Generating src/game/generated/protocol7.cpp
[  1%] Generating src/game/generated/protocol7.h
[  1%] Generating src/game/generated/protocolglue.cpp
[  2%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/assertion_logger.cpp.obj
[  2%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/compression.cpp.obj
[  2%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/config.cpp.obj
[  3%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/console.cpp.obj
[  3%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/csv.cpp.obj
[  3%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/datafile.cpp.obj
[  3%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/demo.cpp.obj
[  4%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/econ.cpp.obj
[  4%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/engine.cpp.obj
[  4%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/fifo.cpp.obj
[  6%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/filecollection.cpp.obj
[  6%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/global_uuid_manager.cpp.obj
[  6%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/http.cpp.obj
[  6%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/huffman.cpp.obj
[  7%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/jobs.cpp.obj
[  7%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/json.cpp.obj
[  7%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/kernel.cpp.obj
[  8%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/linereader.cpp.obj
[  8%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/map.cpp.obj
[  8%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/masterserver.cpp.obj
[  8%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/memheap.cpp.obj
[  9%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/netban.cpp.obj
[  9%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/network.cpp.obj
[  9%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/network_client.cpp.obj
[ 10%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/network_conn.cpp.obj
[ 10%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/network_console.cpp.obj
[ 10%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/network_console_conn.cpp.obj
[ 10%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/network_server.cpp.obj
[ 12%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/network_stun.cpp.obj
[ 12%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/packer.cpp.obj
[ 12%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/protocol_ex.cpp.obj
[ 13%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/ringbuffer.cpp.obj
[ 13%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/serverinfo.cpp.obj
[ 13%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/snapshot.cpp.obj
[ 13%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/storage.cpp.obj
[ 14%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/stun.cpp.obj
[ 14%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/teehistorian_ex.cpp.obj
[ 14%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/uuid_manager.cpp.obj
[ 15%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/video.cpp.obj
[ 15%] Building CXX object CMakeFiles/engine-shared.dir/src/engine/shared/websockets.cpp.obj
[ 15%] Building CXX object CMakeFiles/engine-shared.dir/src/game/generated/protocolglue.cpp.obj
[ 15%] Building CXX object CMakeFiles/engine-shared.dir/src/game/generated/protocol7.cpp.obj
[ 16%] Building CXX object CMakeFiles/engine-shared.dir/src/game/generated/protocol.cpp.obj
[ 16%] Building CXX object CMakeFiles/engine-shared.dir/src/game/mapitems_ex.cpp.obj
[ 16%] Building CXX object CMakeFiles/engine-shared.dir/src/base/hash.cpp.obj
[ 18%] Building CXX object CMakeFiles/engine-shared.dir/src/base/hash_bundled.cpp.obj
[ 18%] Building CXX object CMakeFiles/engine-shared.dir/src/base/hash_libtomcrypt.cpp.obj
[ 18%] Building CXX object CMakeFiles/engine-shared.dir/src/base/hash_openssl.cpp.obj
[ 19%] Building CXX object CMakeFiles/engine-shared.dir/src/base/log.cpp.obj
[ 19%] Building CXX object CMakeFiles/engine-shared.dir/src/base/system.cpp.obj
In function ‘void str_copy(char*, const char*, int)’,
    inlined from ‘void fs_listdir(const char*, FS_LISTDIR_CALLBACK, int, void*)’ at /home/deen/isos/ddnet/ddnet-source/src/base/system.cpp:2076:11:
/home/deen/isos/ddnet/ddnet-source/src/base/system.cpp:2549:16: warning: ‘char* strncat(char*, const char*, size_t)’ output may be truncated copying between 0 and 511 bytes from a string of length 511 [-Wstringop-truncation]
 2549 |         strncat(dst, src, dst_size - 1);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In function ‘void str_copy(char*, const char*, int)’,
    inlined from ‘void fs_listdir_fileinfo(const char*, FS_LISTDIR_CALLBACK_FILEINFO, int, void*)’ at /home/deen/isos/ddnet/ddnet-source/src/base/system.cpp:2130:11:
/home/deen/isos/ddnet/ddnet-source/src/base/system.cpp:2549:16: warning: ‘char* strncat(char*, const char*, size_t)’ output may be truncated copying between 0 and 511 bytes from a string of length 511 [-Wstringop-truncation]
 2549 |         strncat(dst, src, dst_size - 1);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
At global scope:
cc1plus: note: unrecognized command-line option ‘-Wno-nullability-completeness’ may have been intended to silence earlier diagnostics
[ 19%] Building CXX object CMakeFiles/engine-shared.dir/src/base/unicode/confusables.cpp.obj
[ 19%] Building CXX object CMakeFiles/engine-shared.dir/src/base/unicode/tolower.cpp.obj
[ 19%] Built target engine-shared
[ 19%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/adler32.c.obj
[ 20%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/compress.c.obj
[ 20%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/crc32.c.obj
[ 20%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/deflate.c.obj
[ 21%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/gzclose.c.obj
[ 21%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/gzlib.c.obj
[ 21%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/gzread.c.obj
[ 21%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/gzwrite.c.obj
[ 22%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/infback.c.obj
[ 22%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/inffast.c.obj
[ 22%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/inflate.c.obj
[ 24%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/inftrees.c.obj
[ 24%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/trees.c.obj
[ 24%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/uncompr.c.obj
[ 25%] Building C object CMakeFiles/zlib.dir/src/engine/external/zlib/zutil.c.obj
[ 25%] Built target zlib
[ 26%] Building C object CMakeFiles/glew.dir/src/engine/external/glew/glew.c.obj
[ 26%] Built target glew
[ 27%] Building C object CMakeFiles/wavpack.dir/src/engine/external/wavpack/bits.c.obj
[ 27%] Building C object CMakeFiles/wavpack.dir/src/engine/external/wavpack/float.c.obj
[ 27%] Building C object CMakeFiles/wavpack.dir/src/engine/external/wavpack/metadata.c.obj
[ 28%] Building C object CMakeFiles/wavpack.dir/src/engine/external/wavpack/unpack.c.obj
[ 28%] Building C object CMakeFiles/wavpack.dir/src/engine/external/wavpack/words.c.obj
[ 28%] Building C object CMakeFiles/wavpack.dir/src/engine/external/wavpack/wputils.c.obj
[ 28%] Built target wavpack
[ 28%] Building C object CMakeFiles/json.dir/src/engine/external/json-parser/json.c.obj
[ 28%] Built target json
[ 30%] Building C object CMakeFiles/md5.dir/src/engine/external/md5/md5.c.obj
[ 30%] Built target md5
[ 31%] Generating src/game/generated/git_revision.cpp
[ 31%] Building CXX object CMakeFiles/game-shared.dir/src/game/bezier.cpp.obj
[ 31%] Building CXX object CMakeFiles/game-shared.dir/src/game/collision.cpp.obj
[ 31%] Building CXX object CMakeFiles/game-shared.dir/src/game/gamecore.cpp.obj
[ 32%] Building CXX object CMakeFiles/game-shared.dir/src/game/layers.cpp.obj
[ 32%] Building CXX object CMakeFiles/game-shared.dir/src/game/localization.cpp.obj
[ 32%] Building CXX object CMakeFiles/game-shared.dir/src/game/mapbugs.cpp.obj
[ 33%] Building CXX object CMakeFiles/game-shared.dir/src/game/mapitems.cpp.obj
[ 33%] Building CXX object CMakeFiles/game-shared.dir/src/game/prng.cpp.obj
[ 33%] Building CXX object CMakeFiles/game-shared.dir/src/game/teamscore.cpp.obj
[ 33%] Building CXX object CMakeFiles/game-shared.dir/src/game/generated/git_revision.cpp.obj
[ 34%] Built target game-shared
[ 34%] Building CXX object CMakeFiles/rust-bridge-shared.dir/src/rust-bridge/cpp/console.cpp.obj
[ 34%] Building CXX object CMakeFiles/rust-bridge-shared.dir/src/rust-bridge/engine/shared/rust_version.cpp.obj
[ 34%] Built target rust-bridge-shared
[ 36%] Generating i686-pc-windows-gnu/release/libddnet_engine_shared.a
error: could not find `Cargo.toml` in `/home/deen/isos/ddnet/win32` or any parent directory
make[2]: *** [CMakeFiles/rust_engine_shared_target.dir/build.make:86: i686-pc-windows-gnu/release/libddnet_engine_shared.a] Error 101
make[1]: *** [CMakeFiles/Makefile2:351: CMakeFiles/rust_engine_shared_target.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

def- avatar Jul 17 '22 16:07 def-

At least one error should be fixed now, I now set the working directory correctly. Could you try again?

heinrich5991 avatar Jul 17 '22 21:07 heinrich5991

Linux x86-64:

[ 30%] Linking CXX executable config_retrieve
/usr/bin/ld: warning: ddnet-libs/curl/linux/lib64/libcurl.so: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001
/usr/bin/ld: warning: ddnet-libs/curl/linux/lib64/libcurl.so: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010002
[ 30%] Built target config_retrieve
Scanning dependencies of target rust_engine_shared_target
[ 30%] Generating release/libddnet_engine_shared.a
No such file or directory
make[3]: *** [CMakeFiles/rust_engine_shared_target.dir/build.make:74: release/libddnet_engine_shared.a] Error 1

Linux x86:

[  6%] Generating release/libddnet_engine_shared.a
No such file or directory
make[3]: *** [CMakeFiles/rust_engine_shared_target.dir/build.make:74: release/libddnet_engine_shared.a] Error 1

Windows 32bit:

  = note: /usr/i686-w64-mingw32/bin/ld: unrecognised emulation mode: elf_x86_64
          Supported emulations: i386pe
          collect2: error: ld returned 1 exit status


error: could not compile `syn` due to previous error
make[2]: *** [CMakeFiles/rust_engine_shared_target.dir/build.make:86: i686-pc-windows-gnu/release/libddnet_engine_shared.a] Error 101

Windows 64bit:

  = note: /usr/x86_64-w64-mingw32/bin/ld: unrecognised emulation mode: elf_x86_64
          Supported emulations: i386pep i386pe
          collect2: error: ld returned 1 exit status


error: could not compile `syn` due to previous error
make[2]: *** [CMakeFiles/rust_engine_shared_target.dir/build.make:86: x86_64-pc-windows-gnu/release/libddnet_engine_shared.a] Error 101

def- avatar Jul 17 '22 21:07 def-

The Linux stuff looks like it should be fixed by removing the build directory and trying again? It seems cargo is not found, it happened to me when it was first found in /usr/bin/cargo and I then uninstalled that and used rustup.

heinrich5991 avatar Jul 19 '22 12:07 heinrich5991

Can you try setting -DCMAKE_RUST_COMPILER_TARGET=x86_64-pc-windows-gnu for 64-bit Windows and -DCMAKE_RUST_COMPILER_TARGET=i686-pc-windows-gnu for 32-bit Windows?

heinrich5991 avatar Jul 19 '22 12:07 heinrich5991

The Linux stuff looks like it should be fixed by removing the build directory and trying again?

Build directory is always removed first. Do I have to remove the cargo from /usr/bin/cargo? I think it's part of the rust package since I installed nothing else.

def- avatar Jul 26 '22 18:07 def-

Still the same errors on Windows with your flags

def- avatar Jul 26 '22 18:07 def-

How can I reproduce these errors? Using some ddnet-scripts?

heinrich5991 avatar Aug 01 '22 08:08 heinrich5991

Yes, it's arch linux with the mingw packages installed. I think some paths are hardcoded and no one tried to run ddnet-scripts/release/build.sh yet except me.

def- avatar Aug 01 '22 11:08 def-

Okay, that script seems to be difficult to execute. I'll try to catch you in the next couple of days.

heinrich5991 avatar Aug 01 '22 21:08 heinrich5991

For Linux with make with VERBOSE=1 I'm not seeing much more info:

+build_linux:2> PLATFORM=x86_64 
+build_linux:3> DIR=/home/deen/isos/ddnet/debian10 
+build_linux:5> cd /home/deen/isos/ddnet/debian10
+build_linux:6> mkdir -p proc sys dev
+build_linux:7> umount /home/deen/isos/ddnet/debian10/proc /home/deen/isos/ddnet/debian10/sys /home/deen/isos/ddnet/debian10/dev
+build_linux:7> true
+build_linux:8> mount -t proc proc proc/
+build_linux:9> mount -t sysfs sys sys/
+build_linux:10> mount -o bind /dev dev/
+build_linux:12> rm -rf ddnet-source ddnet-source-steam ddnet-libs-source ddnet-ddnet_rust ddnet-libs-master
+build_linux:13> unzip -q /home/deen/isos/ddnet/main.zip
+build_linux:14> unzip -q /home/deen/isos/ddnet/libs.zip
+build_linux:15> mv ddnet-ddnet_rust ddnet-source
+build_linux:16> rm -rf ddnet-source/ddnet-libs
+build_linux:17> mv ddnet-libs-master ddnet-source/ddnet-libs
+build_linux:18> cp -r ddnet-source ddnet-source-steam
+build_linux:21> [ x86_64 '=' x86_64 ']'
+build_linux:22> DISCORD=ON 
+build_linux:27> echo '-DAUTOUPDATE=ON'
+build_linux:27> chroot . sh -c 'cd ddnet-source &&     export CXXFLAGS="'\''-DDDNET_CHECKSUM_SALT={{0xf9,0xb4,0x3c,0x8e,0xe2,0x1e,0x34,0x14,0x94,0x83,0x5b,0xe1,0x11,0xf3,0x94,0xf2}}'\'' -no-pie" &&     export LDFLAGS="-no-pie" &&     cmake -DVERSION=rust -DCMAKE_BUILD_TYPE=Release -DDISCORD=ON -DDISCORD_DYNAMIC=ON -DWEBSOCKETS=OFF -DIPO=ON -DAUTOUPDATE=ON -DPREFER_BUNDLED_LIBS=ON &&     make -j1 package_default VERBOSE=1'
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test HAVE_ATOMICS_WITHOUT_LIB
-- Performing Test HAVE_ATOMICS_WITHOUT_LIB - Success
-- Looking for __i386
-- Looking for __i386 - not found
-- IPO is enabled
-- Performing Test FLAG_SUPPORTED_fstack_protector_all
-- Performing Test FLAG_SUPPORTED_fstack_protector_all - Success
-- Performing Test FLAG_SUPPORTED_fno_exceptions
-- Performing Test FLAG_SUPPORTED_fno_exceptions - Success
-- Performing Test FLAG_SUPPORTED_Wall
-- Performing Test FLAG_SUPPORTED_Wall - Success
-- Performing Test FLAG_SUPPORTED_Wdeclaration_after_statement
-- Performing Test FLAG_SUPPORTED_Wdeclaration_after_statement - Failed
-- Performing Test FLAG_SUPPORTED_Wextra
-- Performing Test FLAG_SUPPORTED_Wextra - Success
-- Performing Test FLAG_SUPPORTED_Wno_unused_parameter
-- Performing Test FLAG_SUPPORTED_Wno_unused_parameter - Success
-- Performing Test FLAG_SUPPORTED_Wno_missing_field_initializers
-- Performing Test FLAG_SUPPORTED_Wno_missing_field_initializers - Success
-- Performing Test FLAG_SUPPORTED_Wformat_2
-- Performing Test FLAG_SUPPORTED_Wformat_2 - Success
-- Performing Test FLAG_SUPPORTED_Wno_implicit_function_declaration
-- Performing Test FLAG_SUPPORTED_Wno_implicit_function_declaration - Success
-- Performing Test FLAG_SUPPORTED_Wno_nullability_completeness
-- Performing Test FLAG_SUPPORTED_Wno_nullability_completeness - Success
-- Performing Test FLAG_SUPPORTED_Wduplicated_cond
-- Performing Test FLAG_SUPPORTED_Wduplicated_cond - Success
-- Performing Test FLAG_SUPPORTED_Wduplicated_branches
-- Performing Test FLAG_SUPPORTED_Wduplicated_branches - Success
-- Performing Test FLAG_SUPPORTED_Wlogical_op
-- Performing Test FLAG_SUPPORTED_Wlogical_op - Success
-- Performing Test FLAG_SUPPORTED_Wrestrict
-- Performing Test FLAG_SUPPORTED_Wrestrict - Success
-- Performing Test FLAG_SUPPORTED_Wshadow_all
-- Performing Test FLAG_SUPPORTED_Wshadow_all - Failed
-- Performing Test FLAG_SUPPORTED_Wshadow_global
-- Performing Test FLAG_SUPPORTED_Wshadow_global - Success
-- Performing Test FLAG_SUPPORTED_Wthread_safety
-- Performing Test FLAG_SUPPORTED_Wthread_safety - Failed
-- Performing Test FLAG_SUPPORTED_Wthread_safety_negative
-- Performing Test FLAG_SUPPORTED_Wthread_safety_negative - Failed
-- Performing Test FLAG_SUPPORTED_Wsuggest_override
-- Performing Test FLAG_SUPPORTED_Wsuggest_override - Success
-- Performing Test DEFINE_FORTIFY_SOURCE
-- Performing Test DEFINE_FORTIFY_SOURCE - Success
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29") 
-- Found ZLIB: src/engine/external/zlib (found version "rust") 
-- Could NOT find Crypto (missing: CRYPTO_LIBRARY CRYPTO_INCLUDEDIR) (found version "rust")
-- Checking for module 'libcurl'
--   Found libcurl, version 7.64.0
-- Found Curl: /ddnet-source/ddnet-libs/curl/linux/lib64/libcurl.so (found version "rust") 
-- Checking for module 'libavcodec'
--   No package 'libavcodec' found
-- Checking for module 'libavformat'
--   No package 'libavformat' found
-- Checking for module 'libavutil'
--   No package 'libavutil' found
-- Checking for module 'libswscale'
--   No package 'libswscale' found
-- Checking for module 'libswresample'
--   No package 'libswresample' found
-- Checking for one of the modules 'libx264;x264'
-- Found FFMPEG: /ddnet-source/ddnet-libs/ffmpeg/linux/lib64/libavcodec.a (found version "rust") 
-- Checking for module 'freetype2'
--   Found freetype2, version 22.1.16
-- Found Freetype: /usr/lib/x86_64-linux-gnu/libfreetype.so (found version "rust") 
-- Found GLEW: src/engine/external/glew (found version "rust") 
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY) (found version "rust")
-- Checking for module 'ogg'
--   No package 'ogg' found
-- Found Ogg: /ddnet-source/ddnet-libs/opus/include (found version "rust") 
-- Checking for module 'opus'
--   No package 'opus' found
-- Found Opus: /ddnet-source/ddnet-libs/opus/include/opus (found version "rust") 
-- Checking for module 'opusfile'
--   No package 'opusfile' found
-- Found Opusfile: /ddnet-source/ddnet-libs/opus/linux/lib64/libopusfile.a (found version "rust") 
-- Found PNG: /ddnet-source/ddnet-libs/png/linux/lib64/libpng16.a (found version "rust") 
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.7.3", minimum required is "3") 
-- Could NOT find Rust (missing: RUST_RUSTC RUST_CARGO) (found version "rust")
-- Checking for module 'sdl2'
--   Found sdl2, version 2.0.6
-- Found SDL2: /usr/local/lib/libSDL2.so (found version "rust") 
-- Checking for module 'sqlite3'
--   Found sqlite3, version 3.32.3
-- Found SQLite3: /ddnet-source/ddnet-libs/sqlite3/include (found version "rust") 
-- Found DiscordSdk: /ddnet-source/ddnet-libs/discord/linux/lib64/discord_game_sdk.so (found version "rust") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE (found version "rust") 
-- Found Wavpack: src/engine/external/wavpack (found version "rust") 
-- Checking for module 'vulkan'
--   Found vulkan, version 1.1.97
-- Building vulkan shaders
/ddnet-source/data/shader/vulkan/quad.vert
-- Finished building vulkan shaders
-- ******** DDNet ********
-- Target OS: linux x86_64
-- Compiler: /usr/bin/c++
-- Rust version: 
-- Build type: Release
-- Dependencies:
--  * Curl not found (using bundled version)
--  * FFmpeg not found (using bundled version)
--  * Freetype found
--  * Glew not found (using bundled version)
--  * GTest not found
--  * Ogg found
--  * OpenSSL Crypto not found
--  * Opus found
--  * Opusfile not found (using bundled version)
--  * PNG not found (using bundled version)
--  * PythonInterp found
--  * SDL2 found
--  * SQLite3 not found (using bundled version)
--  * Wavpack not found (using bundled version)
--  * Zlib not found (using bundled version)
--  * DiscordSdk found
--  * Vulkan found
-- To run the tests, you have to install GTest
-- Found Notify: notify;gdk_pixbuf-2.0;gio-2.0;gobject-2.0;glib-2.0 (found version "rust") 
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libGL.so (found version "rust") 
-- Looking for WavpackOpenFileInputEx
-- Looking for WavpackOpenFileInputEx - not found
-- Looking for WavpackCloseFile
-- Looking for WavpackCloseFile - not found
-- Configuring done
-- Generating done
-- Build files have been written to: /ddnet-source
/usr/local/bin/cmake -H/ddnet-source -B/ddnet-source --check-build-system CMakeFiles/Makefile.cmake 0
make -f CMakeFiles/Makefile2 package_default
make[1]: Entering directory '/ddnet-source'
/usr/local/bin/cmake -H/ddnet-source -B/ddnet-source --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start /ddnet-source/CMakeFiles 90
make -f CMakeFiles/Makefile2 CMakeFiles/package_default.dir/all
make[2]: Entering directory '/ddnet-source'
make -f CMakeFiles/rust_engine_shared_target.dir/build.make CMakeFiles/rust_engine_shared_target.dir/depend
make[3]: Entering directory '/ddnet-source'
cd /ddnet-source && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /ddnet-source /ddnet-source /ddnet-source /ddnet-source /ddnet-source/CMakeFiles/rust_engine_shared_target.dir/DependInfo.cmake --color=
Dependee "/ddnet-source/CMakeFiles/rust_engine_shared_target.dir/DependInfo.cmake" is newer than depender "/ddnet-source/CMakeFiles/rust_engine_shared_target.dir/depend.internal".
Dependee "/ddnet-source/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/ddnet-source/CMakeFiles/rust_engine_shared_target.dir/depend.internal".
Scanning dependencies of target rust_engine_shared_target
make[3]: Leaving directory '/ddnet-source'
make -f CMakeFiles/rust_engine_shared_target.dir/build.make CMakeFiles/rust_engine_shared_target.dir/build
make[3]: Entering directory '/ddnet-source'
[  0%] Generating release/libddnet_engine_shared.a
/usr/local/bin/cmake -E env CARGO_TARGET_DIR=/ddnet-source DDNET_TEST_NO_LINK=1 RUST_CARGO-NOTFOUND build --release
No such file or directory
make[3]: *** [CMakeFiles/rust_engine_shared_target.dir/build.make:74: release/libddnet_engine_shared.a] Error 1
make[3]: Leaving directory '/ddnet-source'
make[2]: *** [CMakeFiles/Makefile2:1139: CMakeFiles/rust_engine_shared_target.dir/all] Error 2
make[2]: Leaving directory '/ddnet-source'
make[1]: *** [CMakeFiles/Makefile2:692: CMakeFiles/package_default.dir/rule] Error 2
make[1]: Leaving directory '/ddnet-source'
make: *** [Makefile:394: package_default] Error 2

def- avatar Aug 01 '22 23:08 def-

I see that it didn't find a Rust compiler/Cargo. Is it in $PATH?

(RUST_CARGO-NOTFOUND, -- Rust version: ).

heinrich5991 avatar Aug 01 '22 23:08 heinrich5991

root@li:/# which rustc
/root/.cargo/bin/rustc
root@li:/# which cargo
/root/.cargo/bin/cargo
root@li:/# rustc --version
rustc 1.62.0 (a8314ef7d 2022-06-27)
root@li:/# cargo --version
cargo 1.62.0 (a748cf5a3 2022-06-08)

Let me try adding . "$HOME/.cargo/env" to the start.

def- avatar Aug 01 '22 23:08 def-

Looks like Linux x86-64 is now getting there. I guess there is no rust version for x86 when using rustup? Failing for me:

/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

def- avatar Aug 01 '22 23:08 def-

Can you execute rustup target add i686-unknown-linux-gnu for the rustup of the build?

heinrich5991 avatar Aug 02 '22 16:08 heinrich5991

linux x86-64 still failed in the end, same failure for macOS and linux x86:

[ 30%] Generating release/libddnet_engine_shared.a
/usr/local/bin/cmake -E env CARGO_TARGET_DIR=/ddnet-source DDNET_TEST_NO_LINK=1 /root/.cargo/bin/cargo build --release
    Updating crates.io index
 Downloading crates ...
  Downloaded proc-macro2 v1.0.40
  Downloaded quote v1.0.20
  Downloaded unicode-ident v1.0.1
  Downloaded syn v1.0.98
  Downloaded cxxbridge-macro v1.0.71
  Downloaded cc v1.0.73
  Downloaded cxxbridge-flags v1.0.71
  Downloaded cxx v1.0.71
  Downloaded link-cplusplus v1.0.6
   Compiling cc v1.0.73
   Compiling proc-macro2 v1.0.40
   Compiling unicode-ident v1.0.1
   Compiling quote v1.0.20
   Compiling cxxbridge-flags v1.0.71
   Compiling syn v1.0.98
   Compiling ddnet-test v0.0.1 (/ddnet-source/src/rust-bridge/test)
   Compiling ddnet-engine-shared v0.0.1 (/ddnet-source/src/engine/shared)
   Compiling link-cplusplus v1.0.6
   Compiling cxx v1.0.71
The following warnings were emitted during compilation:

warning: c++: error: '-DDDNET_CHECKSUM_SALT={{...}}': No such file or directory

error: failed to run custom build command for `link-cplusplus v1.0.6`

Caused by:
  process didn't exit successfully: `/ddnet-source/release/build/link-cplusplus-be09495aba4776d0/build-script-build` (exit status: 1)
  --- stdout
  TARGET = Some("x86_64-unknown-linux-gnu")
  OPT_LEVEL = Some("3")
  HOST = Some("x86_64-unknown-linux-gnu")
  CXX_x86_64-unknown-linux-gnu = None
  CXX_x86_64_unknown_linux_gnu = None
  HOST_CXX = None
  CXX = None
  CXXFLAGS_x86_64-unknown-linux-gnu = None
  CXXFLAGS_x86_64_unknown_linux_gnu = None
  HOST_CXXFLAGS = None
  CXXFLAGS = Some("'-DDDNET_CHECKSUM_SALT={{...}}' -no-pie")
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "\'-DDDNET_CHECKSUM_SALT={{...}}\'" "-no-pie" "-o" "/ddnet-source/release/build/link-cplusplus-fdef6d6aa711649f/out/dummy.o" "-c" "/ddnet-source/release/build/link-cplusplus-fdef6d6aa711649f/out/dummy.cc"
  cargo:warning=c++: error: '-DDDNET_CHECKSUM_SALT={{...}}': No such file or directory
  exit status: 1

  --- stderr


  error occurred: Command "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "\'-DDDNET_CHECKSUM_SALT={{...}}\'" "-no-pie" "-o" "/ddnet-source/release/build/link-cplusplus-fdef6d6aa711649f/out/dummy.o" "-c" "/ddnet-source/release/build/link-cplusplus-fdef6d6aa711649f/out/dummy.cc" with args "c++" did not execute successfully (status code exit status: 1).

I think this is a problem with passing the arguments, they might have one too many '' surrounding them.

def- avatar Aug 02 '22 17:08 def-

Just curious- What will be the benefits of this Rust PoC?

VoxelDoesCode avatar Sep 05 '22 04:09 VoxelDoesCode

The idea is to be able to write future components of DDNet in Rust, a memory-safe high-performance language. The disadvantage is that everyone building DDNet will require Rust then.

def- avatar Sep 05 '22 07:09 def-

@def-

Could you try unsetting CXXFLAGS and LDFLAGS for the build step with make, and only passing them to the initial CMake command line? Either by unsetting them after the CMake or by only mentioning them in front of the CMake, like ENVVAR=abc cmake ..?

Just curious- What will be the benefits of this Rust PoC?

See also #5292.

heinrich5991 avatar Sep 08 '22 08:09 heinrich5991

I created a bug report for the different handling of CXXFLAGS between CMake and the Rust crate cc: https://github.com/rust-lang/cc-rs/issues/719.

heinrich5991 avatar Sep 08 '22 08:09 heinrich5991

Done, mac failed in the end:

ld: warning: ignoring file release/libddnet_engine_shared.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
undef: _cxxbridge1$RustVersionRegister
Undefined symbols for architecture x86_64:
  "_cxxbridge1$RustVersionRegister", referenced from:
      _main in lto.o
      RustVersionRegister(IConsole&) in lto.o
ld: symbol(s) not found for architecture x86_64

win32 fails with:

  = note: "cc" "-m64" "/tmp/rustcB9kS4E/symbols.o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3.build_script_build.0a79426b-cgu.0.rcgu.o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3.build_script_build.0a79426b-cgu.1.rcgu.o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3.build_script_build.0a79426b-cgu.10.rcgu.o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3.build_script_build.0a79426b-cgu.11.rcgu.o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3.build_script_build.0a79426b-cgu.12.rcgu.o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3.build_script_build.0a79426b-cgu.13.rcgu.o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3.build_script_build.0a79426b-cgu.14.rcgu.o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3.build_script_build.0a79426b-cgu.15.rcgu.o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3.build_script_build.0a79426b-cgu.2.rcgu.o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3.build_script_build.0a79426b-cgu.3.rcgu.o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3.build_script_build.0a79426b-cgu.4.rcgu.o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3.build_script_build.0a79426b-cgu.5.rcgu.o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3.build_script_build.0a79426b-cgu.6.rcgu.o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3.build_script_build.0a79426b-cgu.7.rcgu.o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3.build_script_build.0a79426b-cgu.8.rcgu.o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3.build_script_build.0a79426b-cgu.9.rcgu.o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3.4ve7xkljh1yvha5p.rcgu.o" "-Wl,--as-needed" "-L" "/home/deen/isos/ddnet/win32/release/deps" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-7ecaa1d3b2e25b4b.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-0f67a1d26c33cb27.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-848ecc50fbf9be7a.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-d8be1e3fa630d0a3.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-0300982f3263d3ef.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-07e656a21b51fb4e.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-960d25cdb9098add.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-f1542393afc8e8e8.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-fb965fcb645cea50.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-bedda6d9604a983a.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-8c24c5b6ccf7b96d.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-46e16a5c91bae5bc.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-7ef854b0801fa758.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-7c80e59b624b1c13.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-1a144f1de7612a3d.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-3df53debb2d200b3.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-f740d9f9cc788c97.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-cf57ef87b5b088f3.rlib" "-Wl,--end-group" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-f58bddf3085a3d5e.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/deen/isos/ddnet/win32/release/build/syn-f8b1c574487539f3/build_script_build-f8b1c574487539f3" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs"
  = note: /usr/i686-w64-mingw32/bin/ld: unrecognised emulation mode: elf_x86_64
          Supported emulations: i386pe
          collect2: error: ld returned 1 exit status


error: could not compile `syn` due to previous error

win64 same:

  = note: /usr/x86_64-w64-mingw32/bin/ld: unrecognised emulation mode: elf_x86_64
          Supported emulations: i386pep i386pe
          collect2: error: ld returned 1 exit status


error: could not compile `syn` due to previous error

linux x86 failure looks like it could be unrelated or because your code state is quite old:

/ddnet-source/src/engine/client/video.cpp: In member function 'bool CVideo::AddStream(OutputStream*, AVFormatContext*, const AVCodec**, AVCodecID)':
/ddnet-source/src/engine/client/video.cpp:829:2: error: 'c' was not declared in this scope
  c->thread_count = 1;
  ^
At global scope:

def- avatar Sep 09 '22 11:09 def-

just tested it on debian sid, for me win64 works:

cmake .. -GNinja -DCMAKE_RUST_COMPILER_TARGET=x86_64-pc-windows-gnu -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/mingw64.toolchain

compile time: ninja 270,64s user 14,90s system 922% cpu 30,968 total

vs. no rust (067e82057ad4fd7154a1198514701c54d9af54d2 around that time): ninja 212,25s user 10,94s system 1266% cpu 17,618 total

That's a bit longer, but only on a clean compile, for me its kinda ok anyway since only 4seconds, and we have the advantage of cargo. Nice work already @heinrich5991

Jupeyy avatar Sep 09 '22 14:09 Jupeyy

Ah! Can you try again without the PATH and PREFIX manipulations for the Windows builds? Just remove them, I think. The correct compilers are still getting set by the -DCMAKE_TOOLCHAIN_FILE in the actual build_windows function.

heinrich5991 avatar Sep 10 '22 10:09 heinrich5991