@@ -3147,50 +3147,18 @@ fn buildOutputType(
3147
3147
temp_files_for_comp .deinit ();
3148
3148
}
3149
3149
3150
- // if a c_source_file is not a regular file , dump it to a tempdir
3151
- // and replace the src_name with the newly created file.
3152
- // translate-c works fine with streams; other actions don't.
3150
+ // if a c_source_file is "-" , dump it to a tempdir and replace the src_name
3151
+ // with the newly created file. translate-c works fine with streams; other
3152
+ // actions don't.
3153
3153
if (arg_mode != .translate_c ) {
3154
- c_src_loop : for (c_source_files .items ) | * src | {
3155
- // optimization: if the file extension is known, assume it is
3156
- // a regular file and keep going. This is in the hot path.
3157
- // If we remove this check, all input files will get an extra
3158
- // syscall or two of overhead.
3159
- if (Compilation .classifyFileExt (src .src_path ) != .unknown )
3160
- continue ;
3154
+ for (c_source_files .items ) | * src | {
3155
+ if (! mem .eql (u8 , src .src_path , "-" )) continue ;
3161
3156
3162
- // if the extension was not supplied or recognized, bail.
3163
3157
if (src .ext == null )
3164
3158
fatal ("-E or -x is required when reading from a non-regular file" , .{});
3165
3159
3166
- var close_fd = true ;
3167
- const fd = blk : {
3168
- if (mem .eql (u8 , src .src_path , "-" )) {
3169
- close_fd = false ;
3170
- break :blk io .getStdIn ().handle ;
3171
- }
3172
-
3173
- // all things in a windows filesystem are files or directories.
3174
- // Therefore, if it is not stdin, it is a file.
3175
- if (builtin .os .tag == .windows )
3176
- continue :c_src_loop ;
3177
-
3178
- // On POSIX or wasm need to determine if a given path is a
3179
- // stream. 2 choices:
3180
- // 1. open + lseek. If lseek fails, it is a stream. Always 2
3181
- // syscalls.
3182
- // 2. fstat + optional open. If fstat says it's a file, return
3183
- // use it as such. If it is not a file, open and return the
3184
- // file descriptor. 1,5 syscall. Use this.
3185
- var stat_info = try std .os .fstatat (fs .cwd ().fd , src .src_path , 0 );
3186
- if (stat_info .mode & std .os .S .IFMT == std .os .S .IFREG )
3187
- continue :c_src_loop ;
3188
-
3189
- break :blk try std .os .open (src .src_path , std .os .O .RDONLY , 0 );
3190
- };
3191
- defer if (close_fd ) std .os .close (fd );
3192
-
3193
- const new_file = try copyToFile (arena , fd , local_cache_directory );
3160
+ // "-" is stdin. Dump it to a real file.
3161
+ const new_file = try copyToFile (arena , io .getStdIn ().handle , local_cache_directory );
3194
3162
try temp_files_for_comp .append (new_file );
3195
3163
src .src_path = new_file ;
3196
3164
}
0 commit comments