Skip to content

Conversation

@illwieckz
Copy link
Member

Workarounds for latest Saigo

I need that when I build with the current Saigo (based on Clang 21).

endif()

try_c_cxx_flag(FPIC "-fPIC")
if (USE_NACL_SAIGO AND "${NACL_TARGET}" STREQUAL "armhf")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PIC is not useful with NaCl under any circumstances. Why not have the condition be simply NOT NACL?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now done.

@illwieckz
Copy link
Member Author

I also imported the commit entirely removing GAME_PIE from:

@illwieckz illwieckz force-pushed the illwieckz/saigo branch 2 times, most recently from f350a60 to e2971ec Compare December 14, 2025 22:34
@illwieckz
Copy link
Member Author

illwieckz commented Dec 14, 2025

Actually that GAME_PIE thing was a previous attempt to workaround the same limitations, except it's better to just disable PIE completely for NaCl.

For information, here is the Clang crash that happens with Google-built Saigo when building an amd64 cgame:

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:19173!
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: saigo_newlibsaigo_newlib/bin/x86_64-nacl-clang++ -DDAEMON_ARCH_nacl -DDAEMON_BUILD_RelWithDebInfo -DDAEMON_CXX_COMPILER_Saigo=1 -DDAEMON_C_COMPILER_Saigo=1 -DDAEMON_USE_ARCH_INTRINSICS=1 -DDAEMON_USE_ARCH_INTRINSICS_nacl=1 -DDAEMON_USE_COMPILER_CUSTOMIZATION=1 -DDAEMON_USE_COMPILER_INTRINSICS=1 -DGLM_FORCE_EXPLICIT_CTOR -DLUA_COMPAT_APIINTCASTS -DNACL_BUILD_ARCH=x86 -DNACL_BUILD_SUBARCH=64 -DRC_MAX_LAYERS_DEF=63 -DRC_MAX_NEIS_DEF=16 -DRMLUI_STATIC_LIB @CMakeFiles/srclibs-rmlui.dir/includes_CXX.rsp -std=gnu++14 -fvisibility=hidden -fno-strict-aliasing -pthread -fPIC -fno-strict-overflow -Wstack-protector -O2 -g -DNDEBUG -g3 -D_FORTIFY_SOURCE=2 -MD -MT CMakeFiles/srclibs-rmlui.dir/libs/RmlUi/Source/Core/SystemInterface.cpp.obj -MF CMakeFiles/srclibs-rmlui.dir/libs/RmlUi/Source/Core/SystemInterface.cpp.obj.d -o CMakeFiles/srclibs-rmlui.dir/libs/RmlUi/Source/Core/SystemInterface.cpp.obj -c saigo_newlibUnvanquished/libs/RmlUi/Source/Core/SystemInterface.cpp
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'saigo_newlibUnvanquished/libs/RmlUi/Source/Core/SystemInterface.cpp'.
4.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@_ZN3Rml15SystemInterface10LogMessageENS_3Log4TypeERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE'
 #0 0x0000775721e5bd97 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (saigo_newlib/bin/../lib/libLLVM.so.21.0git+0x265bd97)
 #1 0x0000775721e598fe llvm::sys::RunSignalHandlers() (saigo_newlib/bin/../lib/libLLVM.so.21.0git+0x26598fe)
 #2 0x0000775721e5b153 llvm::sys::CleanupOnSignal(unsigned long) (saigo_newlib/bin/../lib/libLLVM.so.21.0git+0x265b153)
 #3 0x0000775721d90fa6 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x000077571f445330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #5 0x000077571f49eb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
 #6 0x000077571f44527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
 #7 0x000077571f4288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #8 0x0000775721da414f (saigo_newlib/bin/../lib/libLLVM.so.21.0git+0x25a414f)
 #9 0x00007757247f43d8 llvm::X86TargetLowering::LowerGlobalTLSAddress(llvm::SDValue, llvm::SelectionDAG&) const X86ISelLowering.cpp:0:0
#10 0x0000775722843b7a (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) LegalizeDAG.cpp:0:0
#11 0x0000775722842e83 llvm::SelectionDAG::Legalize() (saigo_newlib/bin/../lib/libLLVM.so.21.0git+0x3042e83)
#12 0x0000775722a0e81c llvm::SelectionDAGISel::CodeGenAndEmitDAG() (saigo_newlib/bin/../lib/libLLVM.so.21.0git+0x320e81c)
#13 0x0000775722a0c5f4 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (saigo_newlib/bin/../lib/libLLVM.so.21.0git+0x320c5f4)
#14 0x0000775722a09abf llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (saigo_newlib/bin/../lib/libLLVM.so.21.0git+0x3209abf)
#15 0x0000775722a072d9 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (saigo_newlib/bin/../lib/libLLVM.so.21.0git+0x32072d9)
#16 0x00007757223af988 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (saigo_newlib/bin/../lib/libLLVM.so.21.0git+0x2baf988)
#17 0x0000775722019e61 llvm::FPPassManager::runOnFunction(llvm::Function&) (saigo_newlib/bin/../lib/libLLVM.so.21.0git+0x2819e61)
#18 0x0000775722022191 llvm::FPPassManager::runOnModule(llvm::Module&) (saigo_newlib/bin/../lib/libLLVM.so.21.0git+0x2822191)
#19 0x000077572201a885 llvm::legacy::PassManagerImpl::run(llvm::Module&) (saigo_newlib/bin/../lib/libLLVM.so.21.0git+0x281a885)
#20 0x00007757283ec00d clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, 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>>, clang::BackendConsumer*) (saigo_newlib/bin/../lib/libclang-cpp.so.21.0git+0x2fec00d)
#21 0x00007757288a072f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (saigo_newlib/bin/../lib/libclang-cpp.so.21.0git+0x34a072f)
#22 0x0000775726e51997 clang::ParseAST(clang::Sema&, bool, bool) (saigo_newlib/bin/../lib/libclang-cpp.so.21.0git+0x1a51997)
#23 0x00007757290c0876 clang::FrontendAction::Execute() (saigo_newlib/bin/../lib/libclang-cpp.so.21.0git+0x3cc0876)
#24 0x000077572902febf clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (saigo_newlib/bin/../lib/libclang-cpp.so.21.0git+0x3c2febf)
#25 0x000077572916241c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (saigo_newlib/bin/../lib/libclang-cpp.so.21.0git+0x3d6241c)
#26 0x00005ff027175a28 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (saigo_newlibsaigo_newlib/bin/x86_64-nacl-clang+++0x14a28)
#27 0x00005ff027171f8d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#28 0x0000775728c77ed9 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 0x0000775721d90ced llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (saigo_newlib/bin/../lib/libLLVM.so.21.0git+0x2590ced)
#30 0x0000775728c775df clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (saigo_newlib/bin/../lib/libclang-cpp.so.21.0git+0x38775df)
#31 0x0000775728c3285a clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (saigo_newlib/bin/../lib/libclang-cpp.so.21.0git+0x383285a)
#32 0x0000775728c32b67 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (saigo_newlib/bin/../lib/libclang-cpp.so.21.0git+0x3832b67)
#33 0x0000775728c52cd9 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (saigo_newlib/bin/../lib/libclang-cpp.so.21.0git+0x3852cd9)
#34 0x00005ff0271715d2 clang_main(int, char**, llvm::ToolContext const&) (saigo_newlibsaigo_newlib/bin/x86_64-nacl-clang+++0x105d2)
#35 0x00005ff027181997 main (saigo_newlibsaigo_newlib/bin/x86_64-nacl-clang+++0x20997)
#36 0x000077571f42a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#37 0x000077571f42a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#38 0x00005ff02716fb3a _start (saigo_newlibsaigo_newlib/bin/x86_64-nacl-clang+++0xeb3a)
x86_64-nacl-clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 21.0.0git (https://chromium.googlesource.com/a/native_client/nacl-llvm-project-v10.git 9c7f0369cfdd591e580c5ccfc1f00fedee58029f)
Target: x86_64-unknown-nacl
Thread model: posix
InstalledDir: saigo_newlib/bin
Build config: +assertions
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-97bdbe.cpp
x86_64-nacl-clang++: note: diagnostic msg: /tmp/SystemInterface-97bdbe.sh
x86_64-nacl-clang++: note: diagnostic msg: 

********************

It doesn't crash when building the amd64 sgame though. As noticed it crashes when building RmlUi, the build errors on arm also happen when building RmlUi. Google-built Saigo has enabled assertions, while self-built one doesn't, that may explain why I didn't get the compiler crash when using my self-built Saigo. That PIE code is likely incomplete for NaCl in Saigo to begin with, hence the UNREACHABLE assertion we hit when compiling the RmlUi code.

@illwieckz illwieckz changed the title Workarounds for latest Saigo Workarounds for Saigo Clang 21 Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants