-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_per_program_autotune.py
More file actions
35 lines (25 loc) · 1.11 KB
/
Copy pathrun_per_program_autotune.py
File metadata and controls
35 lines (25 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
"""Thin CLI wrapper for perprog_tune.runner.
The RFunipass Autophase library is built against a newer system libstdc++ than
the one bundled in the active conda Python. Re-exec before importing the runner
so dlopen resolves LLVM's C++ runtime from the system directory.
"""
from __future__ import annotations
import os
import sys
def _ensure_system_libstdcxx_first() -> None:
system_lib_dir = "/usr/lib/x86_64-linux-gnu"
if os.environ.get("PERPROG_LIBSTDCXX_REEXECED") == "1":
return
if not os.path.exists(os.path.join(system_lib_dir, "libstdc++.so.6")):
return
current = [item for item in os.environ.get("LD_LIBRARY_PATH", "").split(":") if item]
if current and current[0] == system_lib_dir:
return
os.environ["LD_LIBRARY_PATH"] = ":".join([system_lib_dir, *[item for item in current if item != system_lib_dir]])
os.environ["PERPROG_LIBSTDCXX_REEXECED"] = "1"
os.execv(sys.executable, [sys.executable, *sys.argv])
if __name__ == "__main__":
_ensure_system_libstdcxx_first()
from perprog_tune.runner import main
raise SystemExit(main())