authorgravatar for mail@danielsaier.deDaniel Saier <mail@danielsaier.de> 2022-01-27 08:40:06+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-02-02 21:52:52-07:00
log922d33e5b9195587afa4e97cd60c0af0212938bd
tree868c2f8f0eda6c4b9868d8d9ff3b7f335986c2d6
parent936294e32ad3cb07b51d6753269f8ac7b13c5ffc

zig cc: Treat cu files as C++ source files

First step towards #10634. Treating stub files as C++ allows to use zig c++ as a host compiler for nvcc. Treating cu files as C++ allow using zig c++ as a host compiler in CMake. CMake calls the host compiler with -E on a cu file to identify the compiler. Using zig c++ to directly compile CUDA code is untested.

1 files changed, 4 insertions(+), 1 deletions(-)

src/Compilation.zig+4-1
...@@ -3792,7 +3792,10 @@ pub fn hasCppExt(filename: []const u8) bool {...@@ -3792,7 +3792,10 @@ pub fn hasCppExt(filename: []const u8) bool {
3792 return mem.endsWith(u8, filename, ".C") or3792 return mem.endsWith(u8, filename, ".C") or
3793 mem.endsWith(u8, filename, ".cc") or3793 mem.endsWith(u8, filename, ".cc") or
3794 mem.endsWith(u8, filename, ".cpp") or3794 mem.endsWith(u8, filename, ".cpp") or
3795 mem.endsWith(u8, filename, ".cxx");3795 mem.endsWith(u8, filename, ".cxx") or
3796 mem.endsWith(u8, filename, ".cu") or
3797 // .stub files are compiled by nvcc when using `zig c++` as the host compiler. They contain C++ code.
3798 mem.endsWith(u8, filename, ".stub");
3796}3799}
37973800
3798pub fn hasObjCExt(filename: []const u8) bool {3801pub fn hasObjCExt(filename: []const u8) bool {