From 021c1190af90514aa776ed64515cdaf3cd53b319 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 27 Jan 2022 13:39:28 -0700 Subject: [PATCH] stage2: .stub files are yet another c++ source file extension however .cu files are a superset of c++. --- src/Compilation.zig | 17 +++++++---------- src/main.zig | 8 ++++---- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/Compilation.zig b/src/Compilation.zig index 1d736b51d3..0ff27f80d2 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -3448,7 +3448,7 @@ pub fn addCCArgs( try argv.appendSlice(&[_][]const u8{ "-target", llvm_triple }); switch (ext) { - .c, .cpp, .m, .mm, .h, .cuda => { + .c, .cpp, .m, .mm, .h, .cu => { try argv.appendSlice(&[_][]const u8{ "-nostdinc", "-fno-spell-checking", @@ -3747,7 +3747,7 @@ fn failCObjWithOwnedErrorMsg( pub const FileExt = enum { c, cpp, - cuda, + cu, h, m, mm, @@ -3762,7 +3762,7 @@ pub const FileExt = enum { pub fn clangSupportsDepFile(ext: FileExt) bool { return switch (ext) { - .c, .cpp, .h, .m, .mm, .cuda => true, + .c, .cpp, .h, .m, .mm, .cu => true, .ll, .bc, @@ -3793,11 +3793,8 @@ pub fn hasCppExt(filename: []const u8) bool { return mem.endsWith(u8, filename, ".C") or mem.endsWith(u8, filename, ".cc") or mem.endsWith(u8, filename, ".cpp") or - mem.endsWith(u8, filename, ".cxx"); -} - -pub fn hasCudaExt(filename: []const u8) bool { - return mem.endsWith(u8, filename, ".cu") or mem.endsWith(u8, filename, ".stub"); + mem.endsWith(u8, filename, ".cxx") or + mem.endsWith(u8, filename, ".stub"); } pub fn hasObjCExt(filename: []const u8) bool { @@ -3864,8 +3861,8 @@ pub fn classifyFileExt(filename: []const u8) FileExt { return .static_library; } else if (hasObjectExt(filename)) { return .object; - } else if (hasCudaExt(filename)) { - return .cuda; + } else if (mem.endsWith(u8, filename, ".cu")) { + return .cu; } else { return .unknown; } diff --git a/src/main.zig b/src/main.zig index 75c881a650..1cc8492155 100644 --- a/src/main.zig +++ b/src/main.zig @@ -294,11 +294,11 @@ const usage_build_generic = \\ .s Target-specific assembly source code \\ .S Assembly with C preprocessor (requires LLVM extensions) \\ .c C source code (requires LLVM extensions) - \\ .cxx .cc .C .cpp C++ source code (requires LLVM extensions) + \\ .cxx .cc .C .cpp .stub C++ source code (requires LLVM extensions) \\ .m Objective-C source code (requires LLVM extensions) \\ .mm Objective-C++ source code (requires LLVM extensions) \\ .bc LLVM IR Module (requires LLVM extensions) - \\ .cu .stub Cuda source code (requires LLVM extensions) + \\ .cu Cuda source code (requires LLVM extensions) \\ \\General Options: \\ -h, --help Print this help and exit @@ -1240,7 +1240,7 @@ fn buildOutputType( .object, .static_library, .shared_library => { try link_objects.append(.{ .path = arg }); }, - .assembly, .c, .cpp, .h, .ll, .bc, .m, .mm, .cuda => { + .assembly, .c, .cpp, .h, .ll, .bc, .m, .mm, .cu => { try c_source_files.append(.{ .src_path = arg, .extra_flags = try arena.dupe([]const u8, extra_cflags.items), @@ -1308,7 +1308,7 @@ fn buildOutputType( .positional => { const file_ext = Compilation.classifyFileExt(mem.sliceTo(it.only_arg, 0)); switch (file_ext) { - .assembly, .c, .cpp, .ll, .bc, .h, .m, .mm, .cuda => { + .assembly, .c, .cpp, .ll, .bc, .h, .m, .mm, .cu => { try c_source_files.append(.{ .src_path = it.only_arg }); }, .unknown, .shared_library, .object, .static_library => {