Repository: firedancer-io/firedancer (C)

Issue:
Build fails on Linux 6.8 (SYS_landlock)
```
#######################################################################
# Compiling C source src/util/sandbox/fd_sandbox.c to build/native/gcc/obj/util/sandbox/fd_sandbox.o
#######################################################################
mkdir -pv build/native/gcc/obj/util/sandbox/ && \
gcc -isystem ./opt/include -DFD_LOG_UNCLEAN_EXIT=1 -DFD_HAS_BACKTRACE=0 -DFD_USING_GCC=1 -march=native -mtune=native -Werror -Wall -Wextra -Wpedantic -Wstrict-aliasing=2 -Wconversion -Wdouble-promotion -Wformat-security -Wimplicit-fallthrough -Wimplicit-fallthrough=2 -O3 -ffast-math -fno-associative-math -fno-reciprocal-math -DFD_HAS_OPTIMIZATION=1 -g  -fno-omit-frame-pointer -D_FORTIFY_SOURCE=2 -fPIC -Wl,-z,now -fstack-protector-strong -DFD_HAS_INT128=1 -DFD_HAS_DOUBLE=1 -DFD_HAS_ALLOCA=1 -DFD_HAS_THREADS=1 -DFD_HAS_OPENSSL=1 -DFD_HAS_X86=1 -DFD_HAS_SSE=1 -DFD_IS_X86_64=1 -DFD_HAS_AESNI=1 -D_XOPEN_SOURCE=700 -DFD_HAS_HOSTED=1 -pthread -DFD_HAS_THREADS=1 -DFD_HAS_ATOMIC=1 -mfpmath=sse -falign-functions=32 -mbranch-cost=5 -falign-jumps=32 -falign-labels=32 -falign-loops=32 -DFD_HAS_UCONTEXT=1 -DFD_BUILD_INFO=\"build/native/gcc/info\" -std=c17 -Wstrict-prototypes -DFD_HAS_SECP256K1=1 -DFD_HAS_ZSTD=1 -DFD_HAS_ROCKSDB=1 -DROCKSDB_LITE=1 -c src/util/sandbox/fd_sandbox.c -o build/native/gcc/obj/util/sandbox/fd_sandbox.o
src/util/sandbox/fd_sandbox.c:31:9: error: "SYS_landlock_create_ruleset" redefined [-Werror]
   31 | #define SYS_landlock_create_ruleset 444
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/sys/syscall.h:29,
                 from src/util/sandbox/fd_sandbox.c:17:
/usr/include/bits/syscall.h:839:10: note: this is the location of the previous definition
  839 | # define SYS_landlock_create_ruleset __NR_landlock_create_ruleset
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/util/sandbox/fd_sandbox.c:32:9: error: "SYS_landlock_restrict_self" redefined [-Werror]
   32 | #define SYS_landlock_restrict_self 446
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/bits/syscall.h:843:10: note: this is the location of the previous definition
  843 | # define SYS_landlock_restrict_self __NR_landlock_restrict_self
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [config/everything.mk:311: build/native/gcc/obj/util/sandbox/fd_sandbox.o] Error 1
ripatel@caexcel17:~/firedancer$ uname -a
Linux caexcel17 6.8.11-300.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 27 14:53:33 UTC 2024 x86_64 GNU/Linux
```



Fix (patch):
diff --git a/src/app/fdctl/run/run.c b/src/app/fdctl/run/run.c
index e87e1a4cb18..e3faf972cd6 100644
--- a/src/app/fdctl/run/run.c
+++ b/src/app/fdctl/run/run.c
@@ -406,8 +406,15 @@ run_firedancer( config_t * const config,
   fd_topo_print_log( 0, &config->topo );
 
 #if defined(__x86_64__)
+
+#ifndef SYS_landlock_create_ruleset
 #define SYS_landlock_create_ruleset 444
+#endif
+
+#ifndef LANDLOCK_CREATE_RULESET_VERSION
 #define LANDLOCK_CREATE_RULESET_VERSION (1U << 0)
+#endif
+
 #endif
   long abi = syscall( SYS_landlock_create_ruleset, NULL, 0, LANDLOCK_CREATE_RULESET_VERSION );
   if( -1L==abi && (errno==ENOSYS || errno==EOPNOTSUPP ) ) {
diff --git a/src/util/sandbox/fd_sandbox.c b/src/util/sandbox/fd_sandbox.c
index da857f31fae..397f0cb5ec3 100644
--- a/src/util/sandbox/fd_sandbox.c
+++ b/src/util/sandbox/fd_sandbox.c
@@ -28,10 +28,17 @@
 #if !defined(__x86_64__)
 #error "Target architecture is unsupported by seccomp."
 #else
+
+#ifndef SYS_landlock_create_ruleset
 #define SYS_landlock_create_ruleset 444
+#endif
+
+#ifndef SYS_landlock_restrict_self
 #define SYS_landlock_restrict_self 446
 #endif
 
+#endif
+
 extern char ** environ;
 
 void FD_FN_SENSITIVE