mirror of
https://github.com/QuixiAI/nvdriver.git
synced 2026-12-06 06:28:39 +00:00
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Build the freestanding i386 compat32 RM control probe binary."""
|
|
import argparse
|
|
from pathlib import Path
|
|
import subprocess
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
ALLOWED_NODES = ('/dev/nvidiactl', '/dev/nvidia-rsctl')
|
|
|
|
|
|
def main(argv=None) -> None:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--node', required=True)
|
|
parser.add_argument('--out', type=Path, required=True)
|
|
args = parser.parse_args(argv)
|
|
if args.node not in ALLOWED_NODES:
|
|
raise SystemExit('Explicit original or replacement control node required')
|
|
source = ROOT / 'tests/oracles/compat32-client.c'
|
|
if not source.is_file():
|
|
raise SystemExit(f'compat32 probe source not found: {source}')
|
|
args.out.parent.mkdir(parents=True, exist_ok=True)
|
|
subprocess.run(
|
|
[
|
|
'cc', '-m32', '-std=c11', '-Wall', '-Wextra', '-Werror',
|
|
'-Wno-misleading-indentation', '-ffreestanding', '-fno-pic', '-fno-pie',
|
|
'-nostdlib', '-static', '-fno-stack-protector', '-Wl,-e,_start',
|
|
'-DCONTROL_NODE="' + args.node + '"', str(source), '-o', str(args.out),
|
|
],
|
|
check=True,
|
|
)
|
|
print(args.out)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|