Draft: Build on macOS
This patch allows stechec2 to build and run on macOS systems. It is only meant for local development and should not be used on a large scale.
The following problems were preventing stechec2 from running on macOS, that are now fixed:
- Absence of
pthread_nt
- As the name indicates, stechec2 relies on the function
pthread_timedjoin_np
, wherenp
stands for non portable, it is only available on Linux(?) systems - A replacement has been added inside
np.cc
. It is very barebones and not optimized, but it works.
- As the name indicates, stechec2 relies on the function
-
.so
and.dylib
extensions- For some obscure reasons, shared libraries on macOS do not use
.so
but.dylib
as the file extension - The functionality is the exact same, but one part of the code explicitely requested
libc.so.6
whenlibc
works just fine, it will determine the correct extension itself - Libraries built by stechec also contain the
.dylib
extension. As long as it is correctly written in YAML files, it makes no difference - Champion files are still coded to export as
.so
files. This is not an issue and they work fine too
- For some obscure reasons, shared libraries on macOS do not use
- Missing
librt
- The library
rt
cannot be found on non Linux systems. - I haven't found any place where this is explicitely used, and it seems built into libc anyway, so I made it optional
- The library
-
tictactoe
not compiling with clang- I didn't get
g++
to work, butclang++
worked.tictactoe
was missing an import which raised a warning withg++
, butclang++
considered it to be an error. The import was fixed
- I didn't get
-
gdb
hasn't been ported to the ARM architecture-
lldb
works as an alternative, using the--debug-cmd
flag
-
TODO
-
Compiling champions doesn't work without including -undefined dynamic_lookup
to the linking flags. I am not sure where or how to add this -
Documentation -
Testing on Linux -
Rust support
Notes for compiling
I got this to compile on my mac by modifying the flake and then using nix develop
. I had to add these libraries for it to compile:
diff --git a/flake.nix b/flake.nix
index 420311f..9e2a819 100644
--- a/flake.nix
+++ b/flake.nix
@@ -36,7 +36,7 @@
};
devShell = pkgs.mkShell {
- buildInputs = lib.attrValues self.packages.${system};
+ buildInputs = (lib.attrValues self.packages.${system}) ++ (with pkgs; [pkg-config cppzmq zeromq gflags ncurses lldb]);
};
}
);
Edited by Rostan