From a95573d444f2cf1eaa979a9bdeba66e56a3fbef2 Mon Sep 17 00:00:00 2001 From: Joost VandeVondele Date: Fri, 22 Sep 2023 21:55:19 +0200 Subject: [PATCH] Use the native target if available in SF Also deal with the Makefile shell script permission issue on Linux worker. That should be solved by: https://github.com/official-stockfish/Stockfish/pull/4803 --- server/fishtest/api.py | 2 +- worker/games.py | 20 +++++++++++++++++++- worker/sri.txt | 2 +- worker/worker.py | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/server/fishtest/api.py b/server/fishtest/api.py index 091f98e5f..21adbb861 100644 --- a/server/fishtest/api.py +++ b/server/fishtest/api.py @@ -25,7 +25,7 @@ on how frequently the main instance flushes its run cache. """ -WORKER_VERSION = 216 +WORKER_VERSION = 217 def validate_request(request): diff --git a/worker/games.py b/worker/games.py index c6b82c6bd..2dfcb3c14 100644 --- a/worker/games.py +++ b/worker/games.py @@ -525,6 +525,7 @@ def make_targets(): with subprocess.Popen( ["make", "help"], stdout=subprocess.PIPE, + stderr=subprocess.PIPE, universal_newlines=True, bufsize=1, close_fds=not IS_WINDOWS, @@ -539,6 +540,11 @@ def make_targets(): targets.append(line.split()[0]) if "Supported archs:" in line: read_targets = True + for line in iter(p.stderr.readline, ""): + if "native" in targets and "get_native_properties.sh" in line: + targets.remove("native") + break + except (OSError, subprocess.SubprocessError) as e: print("Exception while executing make help:\n", e, sep="", file=sys.stderr) raise FatalException("It appears 'make' is not properly installed") @@ -556,6 +562,13 @@ def make_targets(): def find_arch(compiler): """Find the best arch string based on the cpu/g++ capabilities and Makefile targets""" targets = make_targets() + + # recent SF support a native target + if "native" in targets: + print("Using native target architecture") + return "native" + + # older SF will need to fall back to this implementation props = gcc_props() if compiler == "g++" else clang_props() if is_64bit(): @@ -681,7 +694,12 @@ def setup_engine( # TODO: 'make strip' works fine with the new Makefile, # 'try' should be safely dropped in the future try: - subprocess.run("make strip COMP={}".format(comp), shell=True, check=True) + subprocess.run( + "make strip COMP={}".format(comp), + stderr=subprocess.DEVNULL, + shell=True, + check=True, + ) except Exception as e: print("Exception stripping binary:\n", e, sep="", file=sys.stderr) diff --git a/worker/sri.txt b/worker/sri.txt index d45de7556..a3b3f439f 100644 --- a/worker/sri.txt +++ b/worker/sri.txt @@ -1 +1 @@ -{"__version": 216, "updater.py": "Mg+pWOgGA0gSo2TuXuuLCWLzwGwH91rsW1W3ixg3jYauHQpRMtNdGnCfuD1GqOhV", "worker.py": "+j8t596hJHgRde7jqxJibKLXPvgi1ygjM7cp/hKzEWF97aRCehCBiSEMsgkZkTUo", "games.py": "A1+dhkNt3mfL7rde3srtxVl0gDGDq3EaJNbmrKsQXON20bdCaC1sZSnB1VwLCQlw"} +{"__version": 217, "updater.py": "Mg+pWOgGA0gSo2TuXuuLCWLzwGwH91rsW1W3ixg3jYauHQpRMtNdGnCfuD1GqOhV", "worker.py": "cFunWo4iviMvzdV9b/8PTfOLoXbovy4hWwmGR6OI70agi5dkwoCJ07BoYwBU+xjd", "games.py": "pqyY62ZE491mecjnXvByfr1mMuhXU5NDg6BbE6WZ4aKuzR12bSFQUSHrQnDt7374"} diff --git a/worker/worker.py b/worker/worker.py index f39096c9c..372b94da7 100644 --- a/worker/worker.py +++ b/worker/worker.py @@ -54,7 +54,7 @@ # Several packages are called "expression". # So we make sure to use the locally installed one. -WORKER_VERSION = 216 +WORKER_VERSION = 217 FILE_LIST = ["updater.py", "worker.py", "games.py"] HTTP_TIMEOUT = 30.0 INITIAL_RETRY_TIME = 15.0