Component
Other — PTODSL runtime native toolchain (ptodsl/ptodsl/_runtime/toolchain.py)
Description
ptodsl._runtime.toolchain.common_include_flags() raises an unhandled PermissionError when an include-path candidate has a non-searchable ancestor directory.
The immediate cause is _append_include_flag():
def _append_include_flag(flags: list[str], path: Path) -> None:
if not path.is_dir():
return
Path.is_dir() returns False for a missing path, but it may raise OSError (in this case PermissionError) when the path cannot be inspected. _append_include_flag() does not handle or contextualize that exception.
This was first observed with the default candidate /usr/local/Ascend/driver/kernel/inc, because /usr/local/Ascend/driver/kernel was installed as root:root with mode 0500. That installation permission is an environment problem. The PTODSL issue reported here is narrower: native toolchain discovery terminates with a raw pathlib exception and provides no PTODSL/toolchain diagnostic.
Reproduction (minimal)
The following reproducer is self-contained and does not require changing the system Ascend installation:
repro_dir=$(mktemp -d)
mkdir -p "$repro_dir/driver/kernel/inc"
chmod 000 "$repro_dir/driver/kernel"
ASCEND_DRIVER_PATH="$repro_dir/driver" python - <<'PY'
from ptodsl._runtime.toolchain import common_include_flags
common_include_flags()
PY
# Cleanup after the failing command.
chmod 700 "$repro_dir/driver/kernel"
rm -r "$repro_dir"
ASCEND_HOME_PATH must point to the normal CANN toolkit installation, as required by common_include_flags().
Expected behavior
Toolchain path discovery should handle a candidate that cannot be inspected in a defined way. For example, it may either:
- skip the candidate consistently with the existing missing-directory behavior; or
- raise a PTODSL-specific environment/toolchain error that names the inaccessible path and explains that search/read permission is required.
It should not expose an unhandled PermissionError from pathlib without context.
Actual behavior / error logs
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "ptodsl/ptodsl/_runtime/toolchain.py", line 124, in common_include_flags
_append_include_flag(flags, driver / "kernel" / "inc")
File "ptodsl/ptodsl/_runtime/toolchain.py", line 88, in _append_include_flag
if not path.is_dir():
File ".../python3.11/pathlib.py", line 1250, in is_dir
return S_ISDIR(self.stat().st_mode)
File ".../python3.11/pathlib.py", line 1013, in stat
return os.stat(self, follow_symlinks=follow_symlinks)
PermissionError: [Errno 13] Permission denied: '<tmp>/driver/kernel/inc'
The original environment failure occurred before Bisheng invocation while PTODSL was constructing native compile flags. Correcting or bypassing the inaccessible driver path allowed native compilation and kernel launch to proceed, confirming that the reported exception belongs to toolchain path discovery rather than PTO IR generation.
Git commit
26212b2
Host platform
Linux (x86_64)
Target Ascend arch (if relevant)
N/A
PTOAS build level (if relevant)
N/A
Component
Other — PTODSL runtime native toolchain (
ptodsl/ptodsl/_runtime/toolchain.py)Description
ptodsl._runtime.toolchain.common_include_flags()raises an unhandledPermissionErrorwhen an include-path candidate has a non-searchable ancestor directory.The immediate cause is
_append_include_flag():Path.is_dir()returnsFalsefor a missing path, but it may raiseOSError(in this casePermissionError) when the path cannot be inspected._append_include_flag()does not handle or contextualize that exception.This was first observed with the default candidate
/usr/local/Ascend/driver/kernel/inc, because/usr/local/Ascend/driver/kernelwas installed asroot:rootwith mode0500. That installation permission is an environment problem. The PTODSL issue reported here is narrower: native toolchain discovery terminates with a rawpathlibexception and provides no PTODSL/toolchain diagnostic.Reproduction (minimal)
The following reproducer is self-contained and does not require changing the system Ascend installation:
ASCEND_HOME_PATHmust point to the normal CANN toolkit installation, as required bycommon_include_flags().Expected behavior
Toolchain path discovery should handle a candidate that cannot be inspected in a defined way. For example, it may either:
It should not expose an unhandled
PermissionErrorfrompathlibwithout context.Actual behavior / error logs
The original environment failure occurred before Bisheng invocation while PTODSL was constructing native compile flags. Correcting or bypassing the inaccessible driver path allowed native compilation and kernel launch to proceed, confirming that the reported exception belongs to toolchain path discovery rather than PTO IR generation.
Git commit
26212b2
Host platform
Linux (x86_64)
Target Ascend arch (if relevant)
N/A
PTOAS build level (if relevant)
N/A