zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 2f41bd3be438dae2a188cfae3295dc28f4e9d434 (tree)
parent 35423b005440c9f31a4cc6a53ccf6b7edd08b859
Author: Daniel Saier <mail@danielsaier.de>
Date:   Thu, 27 Jan 2022 08:40:06 +0100

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.

Diffstat:
Msrc/Compilation.zig | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/Compilation.zig b/src/Compilation.zig @@ -4198,7 +4198,10 @@ 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"); + mem.endsWith(u8, filename, ".cxx") or + 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 hasObjCExt(filename: []const u8) bool {