@@ -3055,50 +3055,18 @@ fn buildOutputType(
3055
3055
temp_files_for_comp .deinit ();
3056
3056
}
3057
3057
3058
- // if a c_source_file is not a regular file , dump it to a tempdir
3059
- // and replace the src_name with the newly created file.
3060
- // translate-c works fine with streams; other actions don't.
3058
+ // if a c_source_file is "-" , dump it to a tempdir and replace the src_name
3059
+ // with the newly created file. translate-c works fine with streams; other
3060
+ // actions don't.
3061
3061
if (arg_mode != .translate_c ) {
3062
- c_src_loop : for (c_source_files .items ) | * src | {
3063
- // optimization: if the file extension is known, assume it is
3064
- // a regular file and keep going. This is in the hot path.
3065
- // If we remove this check, all input files will get an extra
3066
- // syscall or two of overhead.
3067
- if (Compilation .classifyFileExt (src .src_path ) != .unknown )
3068
- continue ;
3062
+ for (c_source_files .items ) | * src | {
3063
+ if (! mem .eql (u8 , src .src_path , "-" )) continue ;
3069
3064
3070
- // if the extension was not supplied or recognized, bail.
3071
3065
if (src .ext == null )
3072
3066
fatal ("-E or -x is required when reading from a non-regular file" , .{});
3073
3067
3074
- var close_fd = true ;
3075
- const fd = blk : {
3076
- if (mem .eql (u8 , src .src_path , "-" )) {
3077
- close_fd = false ;
3078
- break :blk io .getStdIn ().handle ;
3079
- }
3080
-
3081
- // all things in a windows filesystem are files or directories.
3082
- // Therefore, if it is not stdin, it is a file.
3083
- if (builtin .os .tag == .windows )
3084
- continue :c_src_loop ;
3085
-
3086
- // On POSIX or wasm need to determine if a given path is a
3087
- // stream. 2 choices:
3088
- // 1. open + lseek. If lseek fails, it is a stream. Always 2
3089
- // syscalls.
3090
- // 2. fstat + optional open. If fstat says it's a file, return
3091
- // use it as such. If it is not a file, open and return the
3092
- // file descriptor. 1,5 syscall. Use this.
3093
- var stat_info = try std .os .fstatat (fs .cwd ().fd , src .src_path , 0 );
3094
- if (stat_info .mode & std .os .S .IFMT == std .os .S .IFREG )
3095
- continue :c_src_loop ;
3096
-
3097
- break :blk try std .os .open (src .src_path , std .os .O .RDONLY , 0 );
3098
- };
3099
- defer if (close_fd ) std .os .close (fd );
3100
-
3101
- const new_file = try copyToFile (arena , fd , local_cache_directory );
3068
+ // "-" is stdin. Dump it to a real file.
3069
+ const new_file = try copyToFile (arena , io .getStdIn ().handle , local_cache_directory );
3102
3070
try temp_files_for_comp .append (new_file );
3103
3071
src .src_path = new_file ;
3104
3072
}
0 commit comments