@@ -218,11 +218,11 @@ pub const LangToExt = std.ComptimeStringMap(FileExt, .{
218
218
.{ "c" , .c },
219
219
.{ "c-header" , .h },
220
220
.{ "c++" , .cpp },
221
- .{ "c++-header" , .h },
221
+ .{ "c++-header" , .hpp },
222
222
.{ "objective-c" , .m },
223
- .{ "objective-c-header" , .h },
223
+ .{ "objective-c-header" , .hm },
224
224
.{ "objective-c++" , .mm },
225
- .{ "objective-c++-header" , .h },
225
+ .{ "objective-c++-header" , .hmm },
226
226
.{ "assembler" , .assembly },
227
227
.{ "assembler-with-cpp" , .assembly_with_cpp },
228
228
.{ "cuda" , .cu },
@@ -793,6 +793,8 @@ pub const ClangPreprocessorMode = enum {
793
793
yes ,
794
794
/// This means we are doing `zig cc -E`.
795
795
stdout ,
796
+ /// precompiled C header
797
+ pch ,
796
798
};
797
799
798
800
pub const Framework = link .Framework ;
@@ -4655,6 +4657,10 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P
4655
4657
.assembly_with_cpp = > "assembler-with-cpp" ,
4656
4658
.c = > "c" ,
4657
4659
.cpp = > "c++" ,
4660
+ .h = > "c-header" ,
4661
+ .hpp = > "c++-header" ,
4662
+ .hm = > "objective-c-header" ,
4663
+ .hmm = > "objective-c++-header" ,
4658
4664
.cu = > "cuda" ,
4659
4665
.m = > "objective-c" ,
4660
4666
.mm = > "objective-c++" ,
@@ -4680,10 +4686,11 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P
4680
4686
else
4681
4687
"/dev/null" ;
4682
4688
4683
- try argv .ensureUnusedCapacity (5 );
4689
+ try argv .ensureUnusedCapacity (6 );
4684
4690
switch (comp .clang_preprocessor_mode ) {
4685
- .no = > argv .appendSliceAssumeCapacity (&[_ ][]const u8 { "-c" , "-o" , out_obj_path }),
4686
- .yes = > argv .appendSliceAssumeCapacity (&[_ ][]const u8 { "-E" , "-o" , out_obj_path }),
4691
+ .no = > argv .appendSliceAssumeCapacity (&.{ "-c" , "-o" , out_obj_path }),
4692
+ .yes = > argv .appendSliceAssumeCapacity (&.{ "-E" , "-o" , out_obj_path }),
4693
+ .pch = > argv .appendSliceAssumeCapacity (&.{ "-Xclang" , "-emit-pch" , "-o" , out_obj_path }),
4687
4694
.stdout = > argv .appendAssumeCapacity ("-E" ),
4688
4695
}
4689
4696
@@ -4718,10 +4725,11 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P
4718
4725
try argv .appendSlice (c_object .src .extra_flags );
4719
4726
try argv .appendSlice (c_object .src .cache_exempt_flags );
4720
4727
4721
- try argv .ensureUnusedCapacity (5 );
4728
+ try argv .ensureUnusedCapacity (6 );
4722
4729
switch (comp .clang_preprocessor_mode ) {
4723
4730
.no = > argv .appendSliceAssumeCapacity (&.{ "-c" , "-o" , out_obj_path }),
4724
4731
.yes = > argv .appendSliceAssumeCapacity (&.{ "-E" , "-o" , out_obj_path }),
4732
+ .pch = > argv .appendSliceAssumeCapacity (&.{ "-Xclang" , "-emit-pch" , "-o" , out_obj_path }),
4725
4733
.stdout = > argv .appendAssumeCapacity ("-E" ),
4726
4734
}
4727
4735
if (comp .clang_passthrough_mode ) {
@@ -5345,15 +5353,15 @@ pub fn addCCArgs(
5345
5353
try argv .appendSlice (&[_ ][]const u8 { "-target" , llvm_triple });
5346
5354
5347
5355
if (target .os .tag == .windows ) switch (ext ) {
5348
- .c , .cpp , .m , .mm , .h , .cu , .rc , .assembly , .assembly_with_cpp = > {
5356
+ .c , .cpp , .m , .mm , .h , .hpp , .hm , .hmm , . cu , .rc , .assembly , .assembly_with_cpp = > {
5349
5357
const minver : u16 = @truncate (@intFromEnum (target .os .getVersionRange ().windows .min ) >> 16 );
5350
5358
try argv .append (try std .fmt .allocPrint (argv .allocator , "-D_WIN32_WINNT=0x{x:0>4}" , .{minver }));
5351
5359
},
5352
5360
else = > {},
5353
5361
};
5354
5362
5355
5363
switch (ext ) {
5356
- .c , .cpp , .m , .mm , .h , .cu , .rc = > {
5364
+ .c , .cpp , .m , .mm , .h , .hpp , .hm , .hmm , . cu , .rc = > {
5357
5365
try argv .appendSlice (&[_ ][]const u8 {
5358
5366
"-nostdinc" ,
5359
5367
"-fno-spell-checking" ,
@@ -5976,6 +5984,9 @@ pub const FileExt = enum {
5976
5984
cpp ,
5977
5985
cu ,
5978
5986
h ,
5987
+ hpp ,
5988
+ hm ,
5989
+ hmm ,
5979
5990
m ,
5980
5991
mm ,
5981
5992
ll ,
@@ -5994,7 +6005,7 @@ pub const FileExt = enum {
5994
6005
5995
6006
pub fn clangSupportsDepFile (ext : FileExt ) bool {
5996
6007
return switch (ext ) {
5997
- .c , .cpp , .h , .m , .mm , .cu = > true ,
6008
+ .c , .cpp , .h , .hpp , .hm , .hmm , . m , .mm , .cu = > true ,
5998
6009
5999
6010
.ll ,
6000
6011
.bc ,
@@ -6019,6 +6030,9 @@ pub const FileExt = enum {
6019
6030
.cpp = > ".cpp" ,
6020
6031
.cu = > ".cu" ,
6021
6032
.h = > ".h" ,
6033
+ .hpp = > ".h" ,
6034
+ .hm = > ".h" ,
6035
+ .hmm = > ".h" ,
6022
6036
.m = > ".m" ,
6023
6037
.mm = > ".mm" ,
6024
6038
.ll = > ".ll" ,
0 commit comments