Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion packages/spark_standalone/templates/nvme_tcp/setup_nvmet.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import argparse
import logging
import os
import shlex
import socket
import subprocess
import time

from utils import exec_cmd, InfoLogFormat, is_distro_like, run_cmd, setup_logger
Expand All @@ -16,6 +18,24 @@
logger = setup_logger(__name__, logging.INFO, InfoLogFormat)


ENUM_INT_MISMATCH_FLAG = "-Wno-error=enum-int-mismatch"


def compiler_supports_flag(flag):
compiler = shlex.split(os.environ.get("CC", "cc"))
try:
result = subprocess.run(
compiler + ["-x", "c", "-c", "-o", os.devnull, flag, "-"],
input=b"int x;\n",
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
check=False,
)
except OSError:
return False
return result.returncode == 0


def build_nvme_cli(real):
if is_distro_like("centos"):
exec_cmd("dnf install -y libuuid-devel", real)
Expand All @@ -30,7 +50,13 @@ def build_nvme_cli(real):
os.chdir(cli_util_path)
exec_cmd("git checkout 274a49759c8cbdd991253455c64136e0ea73cb6b", for_real=True)
exec_cmd("make clean", real)
exec_cmd("make CFLAGS+='-Wno-error=enum-int-mismatch' && make install", real)
if compiler_supports_flag(ENUM_INT_MISMATCH_FLAG):
exec_cmd(f"make CFLAGS+='{ENUM_INT_MISMATCH_FLAG}' && make install", real)
else:
logger.info(
f"Compiler does not support {ENUM_INT_MISMATCH_FLAG}; building without it"
)
exec_cmd("make && make install", real)
logger.info(f"chdir to {ROOT_PATH}")
os.chdir(ROOT_PATH)
exec_cmd("nvme list", real)
Expand Down
Loading