authorgravatar for mail@danielsaier.deDaniel Saier <mail@danielsaier.de> 2022-01-27 08:40:06+01:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-01-27 19:23:55+02:00
log2f41bd3be438dae2a188cfae3295dc28f4e9d434
treeee5a10c3a7de2ae9d86a743187a7d77b94ebd6ca
parent35423b005440c9f31a4cc6a53ccf6b7edd08b859

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
...@@ -4198,7 +4198,10 @@ pub fn hasCppExt(filename: []const u8) bool {...@@ -4198,7 +4198,10 @@ pub fn hasCppExt(filename: []const u8) bool {
4198 return mem.endsWith(u8, filename, ".C") or4198 return mem.endsWith(u8, filename, ".C") or
4199 mem.endsWith(u8, filename, ".cc") or4199 mem.endsWith(u8, filename, ".cc") or
4200 mem.endsWith(u8, filename, ".cpp") or4200 mem.endsWith(u8, filename, ".cpp") or
4201 mem.endsWith(u8, filename, ".cxx");4201 mem.endsWith(u8, filename, ".cxx") or
4202 mem.endsWith(u8, filename, ".cu") or
4203 // .stub files are compiled by nvcc when using `zig c++` as the host compiler. They contain C++ code.
4204 mem.endsWith(u8, filename, ".stub");
4202}4205}
42034206
4204pub fn hasObjCExt(filename: []const u8) bool {4207pub fn hasObjCExt(filename: []const u8) bool {