diff --git a/util/chplenv/chpl_platform.py b/util/chplenv/chpl_platform.py index fb51d137bf26..9e2aa9327bef 100755 --- a/util/chplenv/chpl_platform.py +++ b/util/chplenv/chpl_platform.py @@ -76,6 +76,12 @@ def get(flag='host'): return platform_val +@memoize +def is_wsl(): + name = (platform.uname().release).lower() + if name.endswith('-microsoft') or name.endswith('-microsoft-standard-wsl2'): + return True + @memoize def get_mac_os_version(): release, version, machine = platform.mac_ver() diff --git a/util/chplenv/compile_link_args_utils.py b/util/chplenv/compile_link_args_utils.py index f3ac0083e5b9..c7371c5226e8 100644 --- a/util/chplenv/compile_link_args_utils.py +++ b/util/chplenv/compile_link_args_utils.py @@ -100,8 +100,11 @@ def get_runtime_link_args(runtime_subdir): sdk_path = chpl_gpu.get_sdk_path(gpu_type) if gpu_type == "nvidia": system.append("-L" + os.path.join(sdk_path, "lib64")) - system.append("-lcuda") system.append("-lcudart") + if chpl_platform.is_wsl(): + # WSL needs to link with libcuda that belongs to the driver hosted in Windows + system.append("-L" + os.path.join("/usr", "lib", "wsl", "lib")) + system.append("-lcuda") elif gpu_type == "amd": lib_path = os.path.join(sdk_path, "lib") system.append("-L" + lib_path)