@@ -215,11 +215,11 @@ pub const LangToExt = std.ComptimeStringMap(FileExt, .{
215
215
.{ "c" , .c },
216
216
.{ "c-header" , .h },
217
217
.{ "c++" , .cpp },
218
- .{ "c++-header" , .h },
218
+ .{ "c++-header" , .hpp },
219
219
.{ "objective-c" , .m },
220
- .{ "objective-c-header" , .h },
220
+ .{ "objective-c-header" , .hm },
221
221
.{ "objective-c++" , .mm },
222
- .{ "objective-c++-header" , .h },
222
+ .{ "objective-c++-header" , .hmm },
223
223
.{ "assembler" , .assembly },
224
224
.{ "assembler-with-cpp" , .assembly_with_cpp },
225
225
.{ "cuda" , .cu },
@@ -788,6 +788,8 @@ pub const ClangPreprocessorMode = enum {
788
788
yes ,
789
789
/// This means we are doing `zig cc -E`.
790
790
stdout ,
791
+ /// precompiled C header
792
+ pch ,
791
793
};
792
794
793
795
pub const Framework = link .Framework ;
@@ -4610,6 +4612,10 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P
4610
4612
.assembly_with_cpp = > "assembler-with-cpp" ,
4611
4613
.c = > "c" ,
4612
4614
.cpp = > "c++" ,
4615
+ .h = > "c-header" ,
4616
+ .hpp = > "c++-header" ,
4617
+ .hm = > "objective-c-header" ,
4618
+ .hmm = > "objective-c++-header" ,
4613
4619
.cu = > "cuda" ,
4614
4620
.m = > "objective-c" ,
4615
4621
.mm = > "objective-c++" ,
@@ -4635,10 +4641,11 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P
4635
4641
else
4636
4642
"/dev/null" ;
4637
4643
4638
- try argv .ensureUnusedCapacity (5 );
4644
+ try argv .ensureUnusedCapacity (6 );
4639
4645
switch (comp .clang_preprocessor_mode ) {
4640
- .no = > argv .appendSliceAssumeCapacity (&[_ ][]const u8 { "-c" , "-o" , out_obj_path }),
4641
- .yes = > argv .appendSliceAssumeCapacity (&[_ ][]const u8 { "-E" , "-o" , out_obj_path }),
4646
+ .no = > argv .appendSliceAssumeCapacity (&.{ "-c" , "-o" , out_obj_path }),
4647
+ .yes = > argv .appendSliceAssumeCapacity (&.{ "-E" , "-o" , out_obj_path }),
4648
+ .pch = > argv .appendSliceAssumeCapacity (&.{ "-Xclang" , "-emit-pch" , "-o" , out_obj_path }),
4642
4649
.stdout = > argv .appendAssumeCapacity ("-E" ),
4643
4650
}
4644
4651
@@ -4673,10 +4680,11 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P
4673
4680
try argv .appendSlice (c_object .src .extra_flags );
4674
4681
try argv .appendSlice (c_object .src .cache_exempt_flags );
4675
4682
4676
- try argv .ensureUnusedCapacity (5 );
4683
+ try argv .ensureUnusedCapacity (6 );
4677
4684
switch (comp .clang_preprocessor_mode ) {
4678
4685
.no = > argv .appendSliceAssumeCapacity (&.{ "-c" , "-o" , out_obj_path }),
4679
4686
.yes = > argv .appendSliceAssumeCapacity (&.{ "-E" , "-o" , out_obj_path }),
4687
+ .pch = > argv .appendSliceAssumeCapacity (&.{ "-Xclang" , "-emit-pch" , "-o" , out_obj_path }),
4680
4688
.stdout = > argv .appendAssumeCapacity ("-E" ),
4681
4689
}
4682
4690
if (comp .clang_passthrough_mode ) {
@@ -5300,15 +5308,15 @@ pub fn addCCArgs(
5300
5308
try argv .appendSlice (&[_ ][]const u8 { "-target" , llvm_triple });
5301
5309
5302
5310
if (target .os .tag == .windows ) switch (ext ) {
5303
- .c , .cpp , .m , .mm , .h , .cu , .rc , .assembly , .assembly_with_cpp = > {
5311
+ .c , .cpp , .m , .mm , .h , .hpp , .hm , .hmm , . cu , .rc , .assembly , .assembly_with_cpp = > {
5304
5312
const minver : u16 = @truncate (@intFromEnum (target .os .getVersionRange ().windows .min ) >> 16 );
5305
5313
try argv .append (try std .fmt .allocPrint (argv .allocator , "-D_WIN32_WINNT=0x{x:0>4}" , .{minver }));
5306
5314
},
5307
5315
else = > {},
5308
5316
};
5309
5317
5310
5318
switch (ext ) {
5311
- .c , .cpp , .m , .mm , .h , .cu , .rc = > {
5319
+ .c , .cpp , .m , .mm , .h , .hpp , .hm , .hmm , . cu , .rc = > {
5312
5320
try argv .appendSlice (&[_ ][]const u8 {
5313
5321
"-nostdinc" ,
5314
5322
"-fno-spell-checking" ,
@@ -5931,6 +5939,9 @@ pub const FileExt = enum {
5931
5939
cpp ,
5932
5940
cu ,
5933
5941
h ,
5942
+ hpp ,
5943
+ hm ,
5944
+ hmm ,
5934
5945
m ,
5935
5946
mm ,
5936
5947
ll ,
@@ -5949,7 +5960,7 @@ pub const FileExt = enum {
5949
5960
5950
5961
pub fn clangSupportsDepFile (ext : FileExt ) bool {
5951
5962
return switch (ext ) {
5952
- .c , .cpp , .h , .m , .mm , .cu = > true ,
5963
+ .c , .cpp , .h , .hpp , .hm , .hmm , . m , .mm , .cu = > true ,
5953
5964
5954
5965
.ll ,
5955
5966
.bc ,
@@ -5974,6 +5985,9 @@ pub const FileExt = enum {
5974
5985
.cpp = > ".cpp" ,
5975
5986
.cu = > ".cu" ,
5976
5987
.h = > ".h" ,
5988
+ .hpp = > ".h" ,
5989
+ .hm = > ".h" ,
5990
+ .hmm = > ".h" ,
5977
5991
.m = > ".m" ,
5978
5992
.mm = > ".mm" ,
5979
5993
.ll = > ".ll" ,
0 commit comments