Skip to content

Saigo toolchain (first attempt) #971

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

Closed
wants to merge 10 commits into from
Closed

Saigo toolchain (first attempt) #971

wants to merge 10 commits into from

Conversation

illwieckz
Copy link
Member

@illwieckz illwieckz commented Nov 21, 2023

Obsoleted by:


DO NOT MERGE THIS

This PR only exists because yesterday I toyed with the Saigo toolchain to change my mind, and then I thought I can still share the code, and we may have a dedicated thread if people want to talk about it.

It doesn't work.

How to use:

Get the Saigo toolchain, see:

Symlink the native_client/toolchain/linux_x86/saigo_newlib folder into external_deps/linux-amd64-default_9.

Then do:

mkdir build/vms-saigo
cd build/vms-saigo
cmake ../.. -DUSE_NACL_SAIGO=ON -DBUILD_GAME_NACL=ON -DBUILD_GAME_NACL_TARGETS=native \
	-DBUILD_GAME_NATIVE_DLL=OFF -DBUILD_GAME_NATIVE_EXE=OFF \
	-DBUILD_CLIENT=OFF -DBUILD_SERVER=OFF -DBUILD_TTY_CLIENT=OFF \
&& make -j$(nproc)

@illwieckz illwieckz marked this pull request as draft November 21, 2023 09:32
@illwieckz illwieckz force-pushed the illwieckz/saigo branch 2 times, most recently from 0cb7c20 to d3198c9 Compare November 21, 2023 09:41
@illwieckz
Copy link
Member Author

What I get when building the cgame:

[ 12%] Performing configure step for 'nacl-vms-amd64'
-- Detected architecture: pnacl
CMake Warning (dev) at /usr/share/cmake-3.27/Modules/CMakeDependentOption.cmake:89 (message):
  Policy CMP0127 is not set: cmake_dependent_option() supports full Condition
  Syntax.  Run "cmake --help-policy CMP0127" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.
Call Stack (most recent call first):
  daemon/CMakeLists.txt:164 (cmake_dependent_option)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- git reported v0.54.0-1183-gd12550737+dirty
-- Detected architecture: pnacl
-- Configuring done (0.3s)
-- Generating done (0.1s)
-- Build files have been written to: Unvanquished/build/vms-saigo/nacl-vms-amd64
[ 25%] Performing build step for 'nacl-vms-amd64'
[  0%] Building CXX object CMakeFiles/RMLUI_LIB.dir/libs/RmlUi/Source/Core/SystemInterface.cpp.obj
Unknown TLS model
UNREACHABLE executed at /b/s/w/ir/x/w/native_client/toolchain_build/src/llvm-saigo/llvm/lib/Target/X86/X86ISelLowering.cpp:18521!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: Unvanquished/daemon/external_deps/linux-amd64-default_9/saigo_newlib/bin/x86_64-nacl-clang++ -DARCH_STRING=pnacl -DDAEMON_ARCH_pnacl -DDAEMON_BUILD_Release -DGLM_FORCE_EXPLICIT_CTOR -DLUA_COMPAT_APIINTCASTS -DNACL_ARCH_STRING=pnacl -DNACL_BUILD_ARCH=x86 -DNACL_BUILD_SUBARCH=64 -DRC_MAX_LAYERS_DEF=63 -DRC_MAX_NEIS_DEF=16 -DRMLUI_STATIC_LIB -DTHIS_IS_NOT_A_DEBUG_BUILD @CMakeFiles/RMLUI_LIB.dir/includes_CXX.rsp -std=gnu++14 -ffast-math -fvisibility=hidden -stdlib=libc++ -O3 -DNDEBUG -O3 -DNDEBUG -fPIC -MD -MT CMakeFiles/RMLUI_LIB.dir/libs/RmlUi/Source/Core/SystemInterface.cpp.obj -MF CMakeFiles/RMLUI_LIB.dir/libs/RmlUi/Source/Core/SystemInterface.cpp.obj.d -o CMakeFiles/RMLUI_LIB.dir/libs/RmlUi/Source/Core/SystemInterface.cpp.obj -c Unvanquished/libs/RmlUi/Source/Core/SystemInterface.cpp
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'Unvanquished/libs/RmlUi/Source/Core/SystemInterface.cpp'.
4.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@_ZN3Rml15SystemInterface10LogMessageENS_3Log4TypeERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE'
 #0 0x00007fc36ad51af7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libLLVM-18git.so+0x2151af7)
 #1 0x00007fc36ad4f64e llvm::sys::RunSignalHandlers() (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libLLVM-18git.so+0x214f64e)
 #2 0x00007fc36ad50eb3 llvm::sys::CleanupOnSignal(unsigned long) (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libLLVM-18git.so+0x2150eb3)
 #3 0x00007fc36ac8da16 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x00007fc368842910 (/lib/x86_64-linux-gnu/libc.so.6+0x42910)
 #5 0x00007fc36889999b pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9999b)
 #6 0x00007fc368842866 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42866)
 #7 0x00007fc3688268b7 abort (/lib/x86_64-linux-gnu/libc.so.6+0x268b7)
 #8 0x00007fc36ac9fbef (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libLLVM-18git.so+0x209fbef)
 #9 0x00007fc36d2af927 llvm::X86TargetLowering::LowerGlobalTLSAddress(llvm::SDValue, llvm::SelectionDAG&) const X86ISelLowering.cpp:0:0
#10 0x00007fc36b69627b (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) LegalizeDAG.cpp:0:0
#11 0x00007fc36b695441 llvm::SelectionDAG::Legalize() (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libLLVM-18git.so+0x2a95441)
#12 0x00007fc36b8326e0 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libLLVM-18git.so+0x2c326e0)
#13 0x00007fc36b830545 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libLLVM-18git.so+0x2c30545)
#14 0x00007fc36b82d345 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libLLVM-18git.so+0x2c2d345)
#15 0x00007fc36d270c19 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#16 0x00007fc36b23fb0e llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libLLVM-18git.so+0x263fb0e)
#17 0x00007fc36aef2b3b llvm::FPPassManager::runOnFunction(llvm::Function&) (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libLLVM-18git.so+0x22f2b3b)
#18 0x00007fc36aefae71 llvm::FPPassManager::runOnModule(llvm::Module&) (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libLLVM-18git.so+0x22fae71)
#19 0x00007fc36aef35c5 llvm::legacy::PassManagerImpl::run(llvm::Module&) (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libLLVM-18git.so+0x22f35c5)
#20 0x00007fc370c31c65 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libclang-cpp.so.18git+0x2e31c65)
#21 0x00007fc371076aa9 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) CodeGenAction.cpp:0:0
#22 0x00007fc36f82b454 clang::ParseAST(clang::Sema&, bool, bool) (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libclang-cpp.so.18git+0x1a2b454)
#23 0x00007fc371cfcf40 clang::FrontendAction::Execute() (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libclang-cpp.so.18git+0x3efcf40)
#24 0x00007fc371c6ebbf clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libclang-cpp.so.18git+0x3e6ebbf)
#25 0x00007fc371d8fcac clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libclang-cpp.so.18git+0x3f8fcac)
#26 0x0000559f476ca59e cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (Unvanquished/daemon/external_deps/linux-amd64-default_9/saigo_newlib/bin/x86_64-nacl-clang+++0x1659e)
#27 0x0000559f476c6e1d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#28 0x00007fc37185b5f9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_1>(long) Job.cpp:0:0
#29 0x00007fc36ac8d75d llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libLLVM-18git.so+0x208d75d)
#30 0x00007fc37185ad2f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libclang-cpp.so.18git+0x3a5ad2f)
#31 0x00007fc37181616f clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libclang-cpp.so.18git+0x3a1616f)
#32 0x00007fc371816427 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libclang-cpp.so.18git+0x3a16427)
#33 0x00007fc371837727 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../lib/libclang-cpp.so.18git+0x3a37727)
#34 0x0000559f476c62c7 clang_main(int, char**, llvm::ToolContext const&) (Unvanquished/daemon/external_deps/linux-amd64-default_9/saigo_newlib/bin/x86_64-nacl-clang+++0x122c7)
#35 0x0000559f476d6ef1 main (Unvanquished/daemon/external_deps/linux-amd64-default_9/saigo_newlib/bin/x86_64-nacl-clang+++0x22ef1)
#36 0x00007fc3688280d0 (/lib/x86_64-linux-gnu/libc.so.6+0x280d0)
#37 0x00007fc368828189 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x28189)
#38 0x0000559f476c2f4a _start (Unvanquished/daemon/external_deps/linux-amd64-default_9/saigo_newlib/bin/x86_64-nacl-clang+++0xef4a)
x86_64-nacl-clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 18.0.0 (https://chromium.googlesource.com/a/native_client/nacl-llvm-project-v10.git 65262d842b48c9888e9e2f7eedd1ee3e2ee1b0a7)
Target: x86_64-unknown-nacl
Thread model: posix
InstalledDir: Unvanquished/daemon/external_deps/linux-amd64-default_9/saigo_newlib/bin
x86_64-nacl-clang++: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
x86_64-nacl-clang++: note: diagnostic msg: /tmp/SystemInterface-4d5615.cpp
x86_64-nacl-clang++: note: diagnostic msg: /tmp/SystemInterface-4d5615.sh
x86_64-nacl-clang++: note: diagnostic msg: 

********************
make[5]: *** [CMakeFiles/RMLUI_LIB.dir/build.make:2267: CMakeFiles/RMLUI_LIB.dir/libs/RmlUi/Source/Core/SystemInterface.cpp.obj] Error 1
make[4]: *** [CMakeFiles/Makefile2:108: CMakeFiles/RMLUI_LIB.dir/all] Error 2
make[3]: *** [Makefile:91: all] Error 2
make[2]: *** [CMakeFiles/nacl-vms-amd64.dir/build.make:86: nacl-vms-amd64-prefix/src/nacl-vms-amd64-stamp/nacl-vms-amd64-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:210: CMakeFiles/nacl-vms-amd64.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

@illwieckz
Copy link
Member Author

illwieckz commented Nov 21, 2023

What I get when building the sgame:

[ 22%] Performing configure step for 'nacl-vms-amd64'
-- Detected architecture: pnacl
CMake Warning (dev) at /usr/share/cmake-3.27/Modules/CMakeDependentOption.cmake:89 (message):
  Policy CMP0127 is not set: cmake_dependent_option() supports full Condition
  Syntax.  Run "cmake --help-policy CMP0127" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.
Call Stack (most recent call first):
  daemon/CMakeLists.txt:164 (cmake_dependent_option)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- git reported v0.54.0-1183-gd12550737+dirty
-- Detected architecture: pnacl
-- Using CBSE Python executable: /usr/bin/python3
-- Configuring done (0.4s)
-- Generating done (0.0s)
-- Build files have been written to: Unvanquished/build/vms-saigo/nacl-vms-amd64
[ 33%] Performing build step for 'nacl-vms-amd64'
[  1%] Built target src-sgame-entities.yaml
[  1%] Building C object daemon_build/CMakeFiles/srclibs-zlib.dir/libs/zlib/gzlib.c.obj
x86_64-nacl-clang: warning: argument unused during compilation: '-stdlib=libc++' [-Wunused-command-line-argument]
Unvanquished/daemon/libs/zlib/gzlib.c:75:12: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
   75 | local void gz_reset(state)
      |            ^
Unvanquished/daemon/libs/zlib/gzlib.c:91:14: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
   91 | local gzFile gz_open(path, fd, mode)
      |              ^
Unvanquished/daemon/libs/zlib/gzlib.c:256:24: error: call to undeclared function 'lseek'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  256 |         state->start = LSEEK(state->fd, 0, SEEK_CUR);
      |                        ^
Unvanquished/daemon/libs/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
   14 | #  define LSEEK lseek
      |                 ^
Unvanquished/daemon/libs/zlib/gzlib.c:256:24: note: did you mean 'fseek'?
Unvanquished/daemon/libs/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
   14 | #  define LSEEK lseek
      |                 ^
native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../x86_64-nacl/include/stdio.h:207:12: note: 'fseek' declared here
  207 | int     _EXFUN(fseek, (FILE *, long, int));
      |                ^
native_client/workspace/depot/native_client/toolchain/linux_x86/saigo_newlib/bin/../x86_64-nacl/include/_ansi.h:65:30: note: expanded from macro '_EXFUN'
   65 | #define _EXFUN(name, proto)             name proto
      |                                         ^
Unvanquished/daemon/libs/zlib/gzlib.c:268:16: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
  268 | gzFile ZEXPORT gzopen(path, mode)
      |                ^
Unvanquished/daemon/libs/zlib/gzlib.c:276:16: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
  276 | gzFile ZEXPORT gzopen64(path, mode)
      |                ^
Unvanquished/daemon/libs/zlib/gzlib.c:284:16: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
  284 | gzFile ZEXPORT gzdopen(fd, mode)
      |                ^
Unvanquished/daemon/libs/zlib/gzlib.c:314:13: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
  314 | int ZEXPORT gzbuffer(file, size)
      |             ^
Unvanquished/daemon/libs/zlib/gzlib.c:339:13: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
  339 | int ZEXPORT gzrewind(file)
      |             ^
Unvanquished/daemon/libs/zlib/gzlib.c:355:9: error: call to undeclared function 'lseek'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  355 |     if (LSEEK(state->fd, state->start, SEEK_SET) == -1)
      |         ^
Unvanquished/daemon/libs/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
   14 | #  define LSEEK lseek
      |                 ^
Unvanquished/daemon/libs/zlib/gzlib.c:362:19: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
  362 | z_off64_t ZEXPORT gzseek64(file, offset, whence)
      |                   ^
Unvanquished/daemon/libs/zlib/gzlib.c:396:15: error: call to undeclared function 'lseek'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  396 |         ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR);
      |               ^
Unvanquished/daemon/libs/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
   14 | #  define LSEEK lseek
      |                 ^
Unvanquished/daemon/libs/zlib/gzlib.c:439:17: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
  439 | z_off_t ZEXPORT gzseek(file, offset, whence)
      |                 ^
Unvanquished/daemon/libs/zlib/gzlib.c:451:19: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
  451 | z_off64_t ZEXPORT gztell64(file)
      |                   ^
Unvanquished/daemon/libs/zlib/gzlib.c:468:17: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
  468 | z_off_t ZEXPORT gztell(file)
      |                 ^
Unvanquished/daemon/libs/zlib/gzlib.c:478:19: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
  478 | z_off64_t ZEXPORT gzoffset64(file)
      |                   ^
Unvanquished/daemon/libs/zlib/gzlib.c:492:14: error: call to undeclared function 'lseek'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  492 |     offset = LSEEK(state->fd, 0, SEEK_CUR);
      |              ^
Unvanquished/daemon/libs/zlib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
   14 | #  define LSEEK lseek
      |                 ^
Unvanquished/daemon/libs/zlib/gzlib.c:501:17: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
  501 | z_off_t ZEXPORT gzoffset(file)
      |                 ^
Unvanquished/daemon/libs/zlib/gzlib.c:511:13: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
  511 | int ZEXPORT gzeof(file)
      |             ^
Unvanquished/daemon/libs/zlib/gzlib.c:528:22: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
  528 | const char * ZEXPORT gzerror(file, errnum)
      |                      ^
Unvanquished/daemon/libs/zlib/gzlib.c:549:14: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
  549 | void ZEXPORT gzclearerr(file)
      |              ^
Unvanquished/daemon/libs/zlib/gzlib.c:575:20: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
  575 | void ZLIB_INTERNAL gz_error(state, err, msg)
      |                    ^
17 warnings and 4 errors generated.
make[5]: *** [daemon_build/CMakeFiles/srclibs-zlib.dir/build.make:152: daemon_build/CMakeFiles/srclibs-zlib.dir/libs/zlib/gzlib.c.obj] Error 1
make[4]: *** [CMakeFiles/Makefile2:321: daemon_build/CMakeFiles/srclibs-zlib.dir/all] Error 2
make[3]: *** [Makefile:91: all] Error 2
make[2]: *** [CMakeFiles/nacl-vms-amd64.dir/build.make:86: nacl-vms-amd64-prefix/src/nacl-vms-amd64-stamp/nacl-vms-amd64-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:238: CMakeFiles/nacl-vms-amd64.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

And also:

Unvanquished/daemon/libs/zlib/gzread.c:20:11: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
   20 | local int gz_load(state, buf, len, have)
      |           ^
Unvanquished/daemon/libs/zlib/gzwrite.c:15:11: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
   15 | local int gz_init(state)
      |           ^
Unvanquished/daemon/libs/zlib/gzread.c:30:15: error: call to undeclared function 'read'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   30 |         ret = read(state->fd, buf + *have, len - *have);
      |               ^

@illwieckz
Copy link
Member Author

And also that with sgame:

[ 22%] Performing build step for 'nacl-vms-amd64'
[  0%] Built target src-sgame-entities.yaml
[  7%] Built target srclibs-recast
[ 14%] Built target srclibs-detour
[ 15%] Built target srclibs-fastlz
[ 16%] Building C object daemon_build/CMakeFiles/srclibs-nacl-module.dir/libs/nacl/native_client/src/untrusted/nacl/imc_accept.c.obj
x86_64-nacl-clang: warning: argument unused during compilation: '-stdlib=libc++' [-Wunused-command-line-argument]
In file included from Unvanquished/daemon/libs/nacl/native_client/src/untrusted/nacl/imc_accept.c:15:
Unvanquished/daemon/libs/nacl/native_client/src/untrusted/nacl/syscall_bindings_trampoline.h:127:40: error: unknown type name 'int32_t'
  127 | typedef void (*TYPE_nacl_thread_exit) (int32_t *stack_flag);
      |                                        ^
Unvanquished/daemon/libs/nacl/native_client/src/untrusted/nacl/syscall_bindings_trampoline.h:159:38: error: unknown type name 'int32_t'
  159 | typedef int (*TYPE_nacl_sem_create) (int32_t value);
      |                                      ^
2 errors generated.
make[5]: *** [daemon_build/CMakeFiles/srclibs-nacl-module.dir/build.make:107: daemon_build/CMakeFiles/srclibs-nacl-module.dir/libs/nacl/native_client/src/untrusted/nacl/imc_accept.c.obj] Error 1
make[4]: *** [CMakeFiles/Makefile2:267: daemon_build/CMakeFiles/srclibs-nacl-module.dir/all] Error 2
make[3]: *** [Makefile:91: all] Error 2
make[2]: *** [CMakeFiles/nacl-vms-amd64.dir/build.make:86: nacl-vms-amd64-prefix/src/nacl-vms-amd64-stamp/nacl-vms-amd64-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:237: CMakeFiles/nacl-vms-amd64.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

@illwieckz
Copy link
Member Author

illwieckz commented Dec 2, 2023

PNACl uses set_c_cxx_flag("-stdlib=libc++") to workaround the same issues I get with Saigo when compiling C files used by the sgame (see above). Yes, setting a c++ library in C flags to compile C files.

With Saigo, adding this C flag just prints that when compiling C files:

warning: argument unused during compilation: '-stdlib=libc++' [-Wunused-command-line-argument]

And then clang errors out on those errors when compiling C files.

To say it otherwise, if I only do set_cxx_flag("-stdlib=libc++") (without _c) with PNaCl, I reproduce the same errors I get with Saigo when compiling sgame.

@illwieckz illwieckz force-pushed the illwieckz/saigo branch 2 times, most recently from a56af8c to ccc789b Compare December 2, 2023 14:50
@illwieckz
Copy link
Member Author

PNACl uses set_c_cxx_flag("-stdlib=libc++") to workaround the same issues I get with Saigo when compiling C files used by the sgame (see above). Yes, setting a c++ library in C flags to compile C files.

Adding #include <unistd.h> to libs/zlib/gzguts.h fixes those errors.

@illwieckz
Copy link
Member Author

I confirm Saigo do not ship nacl/nacl_exception.h, this is probably the last thing preventing to build the sgame with Saigo.

@illwieckz
Copy link
Member Author

illwieckz commented Dec 2, 2023

Well, nacl/nacl_minidump.h is also missing.

@illwieckz
Copy link
Member Author

illwieckz commented Dec 2, 2023

I managed to build the amd64 sgame with Saigo and run it:

Extracting VM module sgame-amd64.nexe from /home/illwieckz/dev/Unvanquished/build/engine-linux/pkg/vms-saigo_0.dpk... 
Loading VM module sgame-amd64.nexe... 
Using loader args:  /home/illwieckz/dev/Unvanquished/build/engine-linux/nacl_helper_bootstrap
    /home/illwieckz/dev/Unvanquished/build/engine-linux/nacl_loader
    --r_debug=0xXXXXXXXXXXXXXXXX --reserved_at_zero=0xXXXXXXXXXXXXXXXX -v
    -B /home/illwieckz/dev/Unvanquished/build/engine-linux/irt_core-amd64.nexe
    -e -i 100:38 -- /home/illwieckz/.local/share/unvanquished/sgame-amd64.nexe 100 

Building cgame doesn't work because building RmlUi makes clang assert.

@illwieckz
Copy link
Member Author

I can also build sgame for i686 but not arm one.

@illwieckz
Copy link
Member Author

illwieckz commented Dec 2, 2023

So current status is:

  • ✅️: build
  • ❌️: doesn't build
  • ❔️: untested
module amd64 i686 armhf
sgame ✅️ ✅️ ❌️
cgame ❌️ ❌️ ❌️

Summary:

  • armhf:

weird compilation errors:

error: Cannot represent a difference across sections
error: expected relocatable expression
error: out of range pc-relative fixup value
  • amd64 cgame:

Saigo clang segfaults when building RmlUi:

[ 18%] Building CXX object CMakeFiles/RMLUI_LIB.dir/libs/RmlUi/Source/Core/SystemInterface.cpp.obj
Unknown TLS model
UNREACHABLE executed at
  /b/s/w/ir/x/w/native_client/toolchain_build/src/llvm-saigo/llvm/lib/Target/X86/X86ISelLowering.cpp:18521!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace,
  preprocessed source, and associated run script.
  • i686 cgame:
[ 76%] Linking CXX executable cgame.nexe
Unvanquished/daemon/external_deps/linux-amd64-default_9/pnacl_deps/lib/libfreetype.a: 
  error adding symbols: File format not recognized

If we fix that it may work, as it happens in the very last step when linking cgame.nexe.

@illwieckz
Copy link
Member Author

About i686:

If we fix that it may work, as it happens in the very last step when linking cgame.nexe.

Maybe I'm linking against amd64 .a

@illwieckz
Copy link
Member Author

illwieckz commented Dec 2, 2023

About i686:

If we fix that it may work, as it happens in the very last step when linking cgame.nexe.

Maybe I'm linking against amd64 .a

No, it's more stupid than that, those .a are arch-independent PNaCl binaries…

We can't use them.

We need to build libfreetype.a, liblua.a and libpng16.a for every nexe architecture if we want to build the cgame.nexe with Saigo.

@illwieckz
Copy link
Member Author

illwieckz commented Dec 3, 2023

Here is an example of compilation error happening when trying to build the sgame as arm nexe:

[  1%] Building C object daemon_build/CMakeFiles/srclibs-zlib.dir/libs/zlib/compress.c.obj
Unvanquished/daemon/libs/zlib/compress.c:22:13: warning: a function definition without
  a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
   22 | int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
      |             ^
Unvanquished/daemon/libs/zlib/compress.c:62:13: warning: a function definition without
  a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
   62 | int ZEXPORT compress (dest, destLen, source, sourceLen)
      |             ^
Unvanquished/daemon/libs/zlib/compress.c:75:15: warning: a function definition without
  a prototype is deprecated in all versions of C and is not supported in C23 [-Wdeprecated-non-prototype]
   75 | uLong ZEXPORT compressBound (sourceLen)
      |               ^
error: Cannot represent a difference across sections
error: Cannot represent a difference across sections
3 warnings and 2 errors generated.

I guess the warning is wrong and is misinterpreting another error (like some type not being defined, or I don't know what else), but I don't get what is the real error I have to look for.

@illwieckz
Copy link
Member Author

Well, this one is even more mysterious:

[  2%] Building CXX object CMakeFiles/srclibs-recast.dir/libs/recastnavigation/Recast/Source/RecastAlloc.cpp.obj
error: Cannot represent a difference across sections
error: Cannot represent a difference across sections
error: Cannot represent a difference across sections
3 errors generated.

@illwieckz
Copy link
Member Author

illwieckz commented Dec 3, 2023

More details:

[  2%] Building CXX object CMakeFiles/srclibs-recast.dir/libs/recastnavigation/Recast/Source/RecastAlloc.cpp.obj
/home/illwieckz/dev/Unvanquished/daemon/external_deps/linux-amd64-default_9/saigo_newlib/bin/arm-nacl-clang++
  -DARCH_STRING=pnacl -DDAEMON_ARCH_pnacl -DDAEMON_BUILD_Release -DGLM_FORCE_EXPLICIT_CTOR
  -DNACL_ARCH_STRING=pnacl -DNACL_BUILD_ARCH=x86 -DNACL_BUILD_SUBARCH=64 -DRC_MAX_LAYERS_DEF=63
  -DRC_MAX_NEIS_DEF=16 -DTHIS_IS_NOT_A_DEBUG_BUILD -DUSE_NACL_SAIGO
  @CMakeFiles/srclibs-recast.dir/includes_CXX.rsp
  -std=gnu++14 -ffast-math -fvisibility=hidden -O3 -DNDEBUG -O3 -DNDEBUG -fPIC -MD
  -MT CMakeFiles/srclibs-recast.dir/libs/recastnavigation/Recast/Source/RecastAlloc.cpp.obj
  -MF CMakeFiles/srclibs-recast.dir/libs/recastnavigation/Recast/Source/RecastAlloc.cpp.obj.d
  -o CMakeFiles/srclibs-recast.dir/libs/recastnavigation/Recast/Source/RecastAlloc.cpp.obj
  -c /home/illwieckz/dev/Unvanquished/libs/recastnavigation/Recast/Source/RecastAlloc.cpp
error: Cannot represent a difference across sections
error: Cannot represent a difference across sections
error: Cannot represent a difference across sections
3 errors generated.

@illwieckz
Copy link
Member Author

This looks fishy: -DNACL_BUILD_ARCH=x86 -DNACL_BUILD_SUBARCH=64

We have this in DaemonNacl.cmake:

if( NACL )
  # Build nexe binary.
  # Those defines looks to be meaningless to produce arch-independent pexe,
  # but they must be set to anything supported by native builds. this
  # requirement looks to be a NaCl bug.
  add_definitions( -DNACL_BUILD_ARCH=x86 )
  add_definitions( -DNACL_BUILD_SUBARCH=64 )

@illwieckz
Copy link
Member Author

Setting the right define helps in no way:

[  1%] Building CXX object daemon_build/CMakeFiles/srclibs-nacl-module.dir/libs/nacl/native_client/src/shared/imc/nacl/nacl_imc.cc.obj
cd /home/illwieckz/dev/Unvanquished/build/vms-saigo/nacl-vms-armhf/daemon_build
&& /home/illwieckz/dev/Unvanquished/daemon/external_deps/linux-amd64-default_9/saigo_newlib/bin/arm-nacl-clang++
  -DARCH_STRING=pnacl -DDAEMON_ARCH_pnacl -DDAEMON_BUILD_Release -DNACL_ARCH_STRING=pnacl
  -DNACL_BUILD_ARCH=arm -DTHIS_IS_NOT_A_DEBUG_BUILD -DUSE_NACL_SAIGO
  @CMakeFiles/srclibs-nacl-module.dir/includes_CXX.rsp
  -std=gnu++14 -ffast-math -fvisibility=hidden -O3 -DNDEBUG -O3 -DNDEBUG -fPIC -MD
  -MT daemon_build/CMakeFiles/srclibs-nacl-module.dir/libs/nacl/native_client/src/shared/imc/nacl/nacl_imc.cc.obj
  -MF CMakeFiles/srclibs-nacl-module.dir/libs/nacl/native_client/src/shared/imc/nacl/nacl_imc.cc.obj.d
  -o CMakeFiles/srclibs-nacl-module.dir/libs/nacl/native_client/src/shared/imc/nacl/nacl_imc.cc.obj
  -c /home/illwieckz/dev/Unvanquished/daemon/libs/nacl/native_client/src/shared/imc/nacl/nacl_imc.cc
error: Cannot represent a difference across sections

@illwieckz
Copy link
Member Author

illwieckz commented Dec 3, 2023

Hmmm, removing -fPIC from the command seems to make this command work:

( cd /home/illwieckz/dev/Unvanquished/build/vms-saigo/nacl-vms-armhf/daemon_build
&& /home/illwieckz/dev/Unvanquished/daemon/external_deps/linux-amd64-default_9/saigo_newlib/bin/arm-nacl-clang++
  -DARCH_STRING=pnacl -DDAEMON_ARCH_pnacl -DDAEMON_BUILD_Release -DNACL_ARCH_STRING=pnacl
  -DNACL_BUILD_ARCH=arm -DTHIS_IS_NOT_A_DEBUG_BUILD -DUSE_NACL_SAIGO
  @CMakeFiles/srclibs-nacl-module.dir/includes_CXX.rsp
  -std=gnu++14 -ffast-math -fvisibility=hidden -O3 -DNDEBUG -O3 -DNDEBUG -MD
  -MT daemon_build/CMakeFiles/srclibs-nacl-module.dir/libs/nacl/native_client/src/shared/imc/nacl/nacl_imc.cc.obj
  -MF CMakeFiles/srclibs-nacl-module.dir/libs/nacl/native_client/src/shared/imc/nacl/nacl_imc.cc.obj.d
  -o CMakeFiles/srclibs-nacl-module.dir/libs/nacl/native_client/src/shared/imc/nacl/nacl_imc.cc.obj
  -c /home/illwieckz/dev/Unvanquished/daemon/libs/nacl/native_client/src/shared/imc/nacl/nacl_imc.cc )
# no error message

@illwieckz
Copy link
Member Author

I close this to reopen it with another branch name.

@illwieckz illwieckz closed this Dec 3, 2023
@illwieckz illwieckz deleted the illwieckz/saigo branch December 3, 2023 01:55
@illwieckz illwieckz changed the title WIP: Saigo toolchain Saigo toolchain (first attempt) Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant