summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-12-01 14:54:19 +0800
committerGitHub <[email protected]>2025-12-01 14:54:19 +0800
commit25c3526637322cdd36a0bc78b3cd7716dcc62382 (patch)
tree0c5f55d9fb23f28a9eeb1e7a32d62659c5112706
parente6833974942a093cee2bbfc5d39f3ac154495cd6 (diff)
parentcd16881d0b2295c5585adc25785c75a8a62dc50a (diff)
Merge pull request #7082 from OpportunityLiu/fix-7077
fix check clang cuda flags, Fixes #7077
-rw-r--r--xmake/modules/core/tools/gcc/has_flags.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/xmake/modules/core/tools/gcc/has_flags.lua b/xmake/modules/core/tools/gcc/has_flags.lua
index 4d001ef6e..c743f91fb 100644
--- a/xmake/modules/core/tools/gcc/has_flags.lua
+++ b/xmake/modules/core/tools/gcc/has_flags.lua
@@ -22,6 +22,8 @@
import("core.cache.detectcache")
import("core.language.language")
import("core.base.hashset")
+import("core.base.semver")
+import("detect.sdks.find_cuda")
-- is linker?
function _islinker(flags, opt)
@@ -109,6 +111,29 @@ function _check_try_running(flags, opt, islinker)
return _try_running(opt.program, table.join(flags, "-o", tmpfile, sourcefile), opt)
end
+ -- check flags for clang cuda compiler
+ if opt.toolkind == "cu" then
+ local cuda_gpu_flags = false
+ for _, flag in ipairs(flags) do
+ if flag:startswith("--cuda-gpu-arch=") then
+ cuda_gpu_flags = true
+ break
+ end
+ end
+
+ local args = table.join(flags, "-c", "-o", tmpfile, sourcefile)
+ if not cuda_gpu_flags then
+ local cuda = get_config("cuda")
+ local cuda_sdk = find_cuda(cuda)
+ local cuda_sdkver = cuda_sdk and cuda_sdk.sdkver or "7.0"
+ if cuda_sdkver and semver.compare(cuda_sdkver, "12.0") >= 0 then
+ table.insert(args, 1, "--cuda-gpu-arch=sm_80")
+ end
+ end
+
+ return _try_running(opt.program, args, opt)
+ end
+
-- check flags for compiler
-- @note we cannot use os.nuldev() as the output file, maybe run failed for some flags, e.g. --coverage
return _try_running(opt.program, table.join(flags, "-S", "-o", tmpfile, sourcefile), opt)