upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/main_gui.cpp
diff options
context:
space:
mode:
authorBitflash <btf01@proton.me>2026-07-29 16:33:02 -0300
committerGitHub <noreply@github.com>2026-07-29 16:33:02 -0300
commitc404e1c7f5d3f04d07e7e5b35a7a8ffcc998d855 (patch)
tree314935e341d2e6fe0d6cd927e01efbb87b74df36 /src/main_gui.cpp
parentab24958f1470cb62a4637126345fdf14c2ec0bd4 (diff)
build: headless Linux node that does not need libGL (#37)
The GUI build requires libGL at load time even when started with -nogui. The dynamic loader resolves every dependency before main() runs, so the flag arrives far too late -- on a clean server the binary dies with error while loading shared libraries: libGL.so.1: cannot open shared object file and nothing suggests it would otherwise have worked. A server is where a node most naturally lives, so this is the deployment that mattered most and the one that failed. The AppImage additionally needs FUSE, which minimal servers lack. Bundling libGL into the AppImage would be the wrong fix: GL has to come from the host's driver stack, and shipping our own breaks machines that have a real GPU. So: a second binary, built from the same node objects without ImGui, GLFW or OpenGL. `make linux-node` produces bitflash-node-<version>-x86_64, 2.5 MB stripped, with no graphics or FUSE dependency at all. `make linux` now builds it alongside the AppImage. Anyone wanting a window keeps using the AppImage. Two small moves were needed. MainFrameRepaint is called from main.cpp and net.cpp but defined in gui.cpp, so headless.cpp provides an empty one rather than putting ifdefs at six call sites. DateTimeStr also lived in gui.cpp while main.cpp logs block times with it -- nothing about formatting a date is GUI work, so it moved to util.cpp and both builds share one definition. Verified on Debian 13: ldd bitflash-node | grep -iE 'libGL|glfw|X11' -> nothing ldd bitflash | grep -iE 'libGL|glfw' -> libglfw.so.3, libGL.so.1, libGLdispatch.so.0 and at runtime, from an empty datadir: btfseed: reached ygffz37...btf via 90.156.222.107:8434 rendezvous: registered at 90.156.222.107:8434, waiting for a dial self-resolve OK (meeting_node=90.156.222.107:8434) btfpeers: kept 15 of 15 descriptor(s) first block at ~30s, 3182 blocks accepted, synced to the tip The GUI builds on Linux and Windows were rebuilt and are unaffected.
Diffstat (limited to 'src/main_gui.cpp')
-rw-r--r--src/main_gui.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 9f7e34e..99e63d4 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -5,7 +5,11 @@
5#include <csignal> 5#include <csignal>
6#endif 6#endif
7 7
8// BITFLASH_NO_GUI builds the same entry point without ImGui, GLFW or OpenGL,
9// so the binary does not need libGL present just to start. See headless.cpp.
10#ifndef BITFLASH_NO_GUI
8int RunGUI(int argc, char* argv[]); 11int RunGUI(int argc, char* argv[]);
12#endif
9 13
10// Global definitions (were in ui.cpp, now here) 14// Global definitions (were in ui.cpp, now here)
11map<string,string> mapAddressBook; 15map<string,string> mapAddressBook;
@@ -186,8 +190,13 @@ int main(int argc, char* argv[])
186 if (_beginthread(ThreadBitcoinMiner, 0, NULL) == (uintptr_t)-1) 190 if (_beginthread(ThreadBitcoinMiner, 0, NULL) == (uintptr_t)-1)
187 printf("Error: _beginthread(ThreadBitcoinMiner) failed\n"); 191 printf("Error: _beginthread(ThreadBitcoinMiner) failed\n");
188 192
193#ifdef BITFLASH_NO_GUI
194 // Nothing else this binary can do; /nogui is accepted and redundant.
195 bool fHeadless = true;
196#else
189 bool fHeadless = arg(argc,argv,"/nogui") || arg(argc,argv,"-nogui") || 197 bool fHeadless = arg(argc,argv,"/nogui") || arg(argc,argv,"-nogui") ||
190 arg(argc,argv,"/daemon") || arg(argc,argv,"-daemon"); 198 arg(argc,argv,"/daemon") || arg(argc,argv,"-daemon");
199#endif
191 200
192 if (fHeadless) { 201 if (fHeadless) {
193#ifndef _WIN32 202#ifndef _WIN32
@@ -200,8 +209,12 @@ int main(int argc, char* argv[])
200 return 0; 209 return 0;
201 } 210 }
202 211
212#ifdef BITFLASH_NO_GUI
213 return 0; // unreachable: fHeadless is always true in this build
214#else
203 int ret = RunGUI(argc, argv); 215 int ret = RunGUI(argc, argv);
204 fShutdown = true; 216 fShutdown = true;
205 StopNode(); 217 StopNode();
206 return ret; 218 return ret;
219#endif
207} 220}