authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-27 13:39:28-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-02-02 22:00:16-07:00
log021c1190af90514aa776ed64515cdaf3cd53b319
tree7d732f28eca0cbe0f2a97497385993dc75e3b1d7
parent45cd1114f76b80bae1513f10d29b8d09261ae632

stage2: .stub files are yet another c++ source file extension

however .cu files are a superset of c++.

2 files changed, 11 insertions(+), 14 deletions(-)

src/Compilation.zig+7-10
......@@ -3448,7 +3448,7 @@ pub fn addCCArgs(
34483448 try argv.appendSlice(&[_][]const u8{ "-target", llvm_triple });
34493449
34503450 switch (ext) {
3451 .c, .cpp, .m, .mm, .h, .cuda => {
3451 .c, .cpp, .m, .mm, .h, .cu => {
34523452 try argv.appendSlice(&[_][]const u8{
34533453 "-nostdinc",
34543454 "-fno-spell-checking",
......@@ -3747,7 +3747,7 @@ fn failCObjWithOwnedErrorMsg(
37473747pub const FileExt = enum {
37483748 c,
37493749 cpp,
3750 cuda,
3750 cu,
37513751 h,
37523752 m,
37533753 mm,
......@@ -3762,7 +3762,7 @@ pub const FileExt = enum {
37623762
37633763 pub fn clangSupportsDepFile(ext: FileExt) bool {
37643764 return switch (ext) {
3765 .c, .cpp, .h, .m, .mm, .cuda => true,
3765 .c, .cpp, .h, .m, .mm, .cu => true,
37663766
37673767 .ll,
37683768 .bc,
......@@ -3793,11 +3793,8 @@ pub fn hasCppExt(filename: []const u8) bool {
37933793 return mem.endsWith(u8, filename, ".C") or
37943794 mem.endsWith(u8, filename, ".cc") or
37953795 mem.endsWith(u8, filename, ".cpp") or
3796 mem.endsWith(u8, filename, ".cxx");
3797}
3798
3799pub fn hasCudaExt(filename: []const u8) bool {
3800 return mem.endsWith(u8, filename, ".cu") or mem.endsWith(u8, filename, ".stub");
3796 mem.endsWith(u8, filename, ".cxx") or
3797 mem.endsWith(u8, filename, ".stub");
38013798}
38023799
38033800pub fn hasObjCExt(filename: []const u8) bool {
......@@ -3864,8 +3861,8 @@ pub fn classifyFileExt(filename: []const u8) FileExt {
38643861 return .static_library;
38653862 } else if (hasObjectExt(filename)) {
38663863 return .object;
3867 } else if (hasCudaExt(filename)) {
3868 return .cuda;
3864 } else if (mem.endsWith(u8, filename, ".cu")) {
3865 return .cu;
38693866 } else {
38703867 return .unknown;
38713868 }
src/main.zig+4-4
......@@ -294,11 +294,11 @@ const usage_build_generic =
294294 \\ .s Target-specific assembly source code
295295 \\ .S Assembly with C preprocessor (requires LLVM extensions)
296296 \\ .c C source code (requires LLVM extensions)
297 \\ .cxx .cc .C .cpp C++ source code (requires LLVM extensions)
297 \\ .cxx .cc .C .cpp .stub C++ source code (requires LLVM extensions)
298298 \\ .m Objective-C source code (requires LLVM extensions)
299299 \\ .mm Objective-C++ source code (requires LLVM extensions)
300300 \\ .bc LLVM IR Module (requires LLVM extensions)
301 \\ .cu .stub Cuda source code (requires LLVM extensions)
301 \\ .cu Cuda source code (requires LLVM extensions)
302302 \\
303303 \\General Options:
304304 \\ -h, --help Print this help and exit
......@@ -1240,7 +1240,7 @@ fn buildOutputType(
12401240 .object, .static_library, .shared_library => {
12411241 try link_objects.append(.{ .path = arg });
12421242 },
1243 .assembly, .c, .cpp, .h, .ll, .bc, .m, .mm, .cuda => {
1243 .assembly, .c, .cpp, .h, .ll, .bc, .m, .mm, .cu => {
12441244 try c_source_files.append(.{
12451245 .src_path = arg,
12461246 .extra_flags = try arena.dupe([]const u8, extra_cflags.items),
......@@ -1308,7 +1308,7 @@ fn buildOutputType(
13081308 .positional => {
13091309 const file_ext = Compilation.classifyFileExt(mem.sliceTo(it.only_arg, 0));
13101310 switch (file_ext) {
1311 .assembly, .c, .cpp, .ll, .bc, .h, .m, .mm, .cuda => {
1311 .assembly, .c, .cpp, .ll, .bc, .h, .m, .mm, .cu => {
13121312 try c_source_files.append(.{ .src_path = it.only_arg });
13131313 },
13141314 .unknown, .shared_library, .object, .static_library => {