mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-07 14:24:43 +00:00
stage2: make cuda file extensions a separate enum tag than c++
follow-up to 2f41bd3be4.
This commit is contained in:
parent
d7feeaaa2c
commit
45cd1114f7
2 changed files with 15 additions and 8 deletions
|
|
@ -3448,7 +3448,7 @@ pub fn addCCArgs(
|
||||||
try argv.appendSlice(&[_][]const u8{ "-target", llvm_triple });
|
try argv.appendSlice(&[_][]const u8{ "-target", llvm_triple });
|
||||||
|
|
||||||
switch (ext) {
|
switch (ext) {
|
||||||
.c, .cpp, .m, .mm, .h => {
|
.c, .cpp, .m, .mm, .h, .cuda => {
|
||||||
try argv.appendSlice(&[_][]const u8{
|
try argv.appendSlice(&[_][]const u8{
|
||||||
"-nostdinc",
|
"-nostdinc",
|
||||||
"-fno-spell-checking",
|
"-fno-spell-checking",
|
||||||
|
|
@ -3747,6 +3747,7 @@ fn failCObjWithOwnedErrorMsg(
|
||||||
pub const FileExt = enum {
|
pub const FileExt = enum {
|
||||||
c,
|
c,
|
||||||
cpp,
|
cpp,
|
||||||
|
cuda,
|
||||||
h,
|
h,
|
||||||
m,
|
m,
|
||||||
mm,
|
mm,
|
||||||
|
|
@ -3761,7 +3762,7 @@ pub const FileExt = enum {
|
||||||
|
|
||||||
pub fn clangSupportsDepFile(ext: FileExt) bool {
|
pub fn clangSupportsDepFile(ext: FileExt) bool {
|
||||||
return switch (ext) {
|
return switch (ext) {
|
||||||
.c, .cpp, .h, .m, .mm => true,
|
.c, .cpp, .h, .m, .mm, .cuda => true,
|
||||||
|
|
||||||
.ll,
|
.ll,
|
||||||
.bc,
|
.bc,
|
||||||
|
|
@ -3792,10 +3793,11 @@ pub fn hasCppExt(filename: []const u8) bool {
|
||||||
return mem.endsWith(u8, filename, ".C") or
|
return mem.endsWith(u8, filename, ".C") or
|
||||||
mem.endsWith(u8, filename, ".cc") or
|
mem.endsWith(u8, filename, ".cc") or
|
||||||
mem.endsWith(u8, filename, ".cpp") or
|
mem.endsWith(u8, filename, ".cpp") or
|
||||||
mem.endsWith(u8, filename, ".cxx") or
|
mem.endsWith(u8, filename, ".cxx");
|
||||||
mem.endsWith(u8, filename, ".cu") or
|
}
|
||||||
// .stub files are compiled by nvcc when using `zig c++` as the host compiler. They contain C++ code.
|
|
||||||
mem.endsWith(u8, filename, ".stub");
|
pub fn hasCudaExt(filename: []const u8) bool {
|
||||||
|
return mem.endsWith(u8, filename, ".cu") or mem.endsWith(u8, filename, ".stub");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hasObjCExt(filename: []const u8) bool {
|
pub fn hasObjCExt(filename: []const u8) bool {
|
||||||
|
|
@ -3862,6 +3864,8 @@ pub fn classifyFileExt(filename: []const u8) FileExt {
|
||||||
return .static_library;
|
return .static_library;
|
||||||
} else if (hasObjectExt(filename)) {
|
} else if (hasObjectExt(filename)) {
|
||||||
return .object;
|
return .object;
|
||||||
|
} else if (hasCudaExt(filename)) {
|
||||||
|
return .cuda;
|
||||||
} else {
|
} else {
|
||||||
return .unknown;
|
return .unknown;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -298,6 +298,7 @@ const usage_build_generic =
|
||||||
\\ .m Objective-C source code (requires LLVM extensions)
|
\\ .m Objective-C source code (requires LLVM extensions)
|
||||||
\\ .mm Objective-C++ source code (requires LLVM extensions)
|
\\ .mm Objective-C++ source code (requires LLVM extensions)
|
||||||
\\ .bc LLVM IR Module (requires LLVM extensions)
|
\\ .bc LLVM IR Module (requires LLVM extensions)
|
||||||
|
\\ .cu .stub Cuda source code (requires LLVM extensions)
|
||||||
\\
|
\\
|
||||||
\\General Options:
|
\\General Options:
|
||||||
\\ -h, --help Print this help and exit
|
\\ -h, --help Print this help and exit
|
||||||
|
|
@ -1239,7 +1240,7 @@ fn buildOutputType(
|
||||||
.object, .static_library, .shared_library => {
|
.object, .static_library, .shared_library => {
|
||||||
try link_objects.append(.{ .path = arg });
|
try link_objects.append(.{ .path = arg });
|
||||||
},
|
},
|
||||||
.assembly, .c, .cpp, .h, .ll, .bc, .m, .mm => {
|
.assembly, .c, .cpp, .h, .ll, .bc, .m, .mm, .cuda => {
|
||||||
try c_source_files.append(.{
|
try c_source_files.append(.{
|
||||||
.src_path = arg,
|
.src_path = arg,
|
||||||
.extra_flags = try arena.dupe([]const u8, extra_cflags.items),
|
.extra_flags = try arena.dupe([]const u8, extra_cflags.items),
|
||||||
|
|
@ -1307,7 +1308,9 @@ fn buildOutputType(
|
||||||
.positional => {
|
.positional => {
|
||||||
const file_ext = Compilation.classifyFileExt(mem.sliceTo(it.only_arg, 0));
|
const file_ext = Compilation.classifyFileExt(mem.sliceTo(it.only_arg, 0));
|
||||||
switch (file_ext) {
|
switch (file_ext) {
|
||||||
.assembly, .c, .cpp, .ll, .bc, .h, .m, .mm => try c_source_files.append(.{ .src_path = it.only_arg }),
|
.assembly, .c, .cpp, .ll, .bc, .h, .m, .mm, .cuda => {
|
||||||
|
try c_source_files.append(.{ .src_path = it.only_arg });
|
||||||
|
},
|
||||||
.unknown, .shared_library, .object, .static_library => {
|
.unknown, .shared_library, .object, .static_library => {
|
||||||
try link_objects.append(.{
|
try link_objects.append(.{
|
||||||
.path = it.only_arg,
|
.path = it.only_arg,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue