| ... | ... | @@ -272,22 +272,69 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 272 | 272 | const s = path.sep_str; |
| 273 | 273 | const linux_prefix = lib_libc_glibc ++ |
| 274 | 274 | "sysdeps" ++ s ++ "unix" ++ s ++ "sysv" ++ s ++ "linux" ++ s; |
| 275 | | const deps = [_][]const u8{ |
| 276 | | lib_libc_glibc ++ "stdlib" ++ s ++ "atexit.c", |
| 277 | | lib_libc_glibc ++ "stdlib" ++ s ++ "at_quick_exit.c", |
| 278 | | linux_prefix ++ "stat.c", |
| 279 | | linux_prefix ++ "fstat.c", |
| 280 | | linux_prefix ++ "lstat.c", |
| 281 | | linux_prefix ++ "stat64.c", |
| 282 | | linux_prefix ++ "fstat64.c", |
| 283 | | linux_prefix ++ "lstat64.c", |
| 284 | | linux_prefix ++ "fstatat.c", |
| 285 | | linux_prefix ++ "fstatat64.c", |
| 286 | | linux_prefix ++ "mknodat.c", |
| 287 | | lib_libc_glibc ++ "io" ++ s ++ "mknod.c", |
| 288 | | lib_libc_glibc ++ "sysdeps" ++ s ++ "pthread" ++ s ++ "pthread_atfork.c", |
| 289 | | lib_libc_glibc ++ "debug" ++ s ++ "stack_chk_fail_local.c", |
| 290 | | lib_libc_glibc ++ "csu" ++ s ++ "errno.c", |
| 275 | const Flavor = enum { nonshared, shared }; |
| 276 | const Dep = struct { path: []const u8, flavor: Flavor }; |
| 277 | const deps = [_]Dep{ |
| 278 | .{ |
| 279 | .path = lib_libc_glibc ++ "stdlib" ++ s ++ "atexit.c", |
| 280 | .flavor = .nonshared, |
| 281 | }, |
| 282 | .{ |
| 283 | .path = lib_libc_glibc ++ "stdlib" ++ s ++ "at_quick_exit.c", |
| 284 | .flavor = .nonshared, |
| 285 | }, |
| 286 | .{ |
| 287 | .path = linux_prefix ++ "stat.c", |
| 288 | .flavor = .shared, |
| 289 | }, |
| 290 | .{ |
| 291 | .path = linux_prefix ++ "fstat.c", |
| 292 | .flavor = .shared, |
| 293 | }, |
| 294 | .{ |
| 295 | .path = linux_prefix ++ "lstat.c", |
| 296 | .flavor = .shared, |
| 297 | }, |
| 298 | .{ |
| 299 | .path = linux_prefix ++ "stat64.c", |
| 300 | .flavor = .shared, |
| 301 | }, |
| 302 | .{ |
| 303 | .path = linux_prefix ++ "fstat64.c", |
| 304 | .flavor = .shared, |
| 305 | }, |
| 306 | .{ |
| 307 | .path = linux_prefix ++ "lstat64.c", |
| 308 | .flavor = .shared, |
| 309 | }, |
| 310 | .{ |
| 311 | .path = linux_prefix ++ "fstatat.c", |
| 312 | .flavor = .shared, |
| 313 | }, |
| 314 | .{ |
| 315 | .path = linux_prefix ++ "fstatat64.c", |
| 316 | .flavor = .shared, |
| 317 | }, |
| 318 | .{ |
| 319 | .path = linux_prefix ++ "mknodat.c", |
| 320 | .flavor = .shared, |
| 321 | }, |
| 322 | .{ |
| 323 | .path = lib_libc_glibc ++ "io" ++ s ++ "mknod.c", |
| 324 | .flavor = .shared, |
| 325 | }, |
| 326 | .{ |
| 327 | .path = lib_libc_glibc ++ "sysdeps" ++ s ++ "pthread" ++ s ++ "pthread_atfork.c", |
| 328 | .flavor = .nonshared, |
| 329 | }, |
| 330 | .{ |
| 331 | .path = lib_libc_glibc ++ "debug" ++ s ++ "stack_chk_fail_local.c", |
| 332 | .flavor = .nonshared, |
| 333 | }, |
| 334 | .{ |
| 335 | .path = lib_libc_glibc ++ "csu" ++ s ++ "errno.c", |
| 336 | .flavor = .shared, |
| 337 | }, |
| 291 | 338 | }; |
| 292 | 339 | |
| 293 | 340 | var c_source_files: [deps.len]Compilation.CSourceFile = undefined; |
| ... | ... | @@ -298,12 +345,19 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 298 | 345 | "-std=gnu11", |
| 299 | 346 | "-fgnu89-inline", |
| 300 | 347 | "-fmerge-all-constants", |
| 348 | "-frounding-math", |
| 301 | 349 | "-fno-stack-protector", |
| 350 | "-fno-common", |
| 302 | 351 | "-fmath-errno", |
| 303 | 352 | "-ftls-model=initial-exec", |
| 304 | 353 | "-Wno-ignored-attributes", |
| 305 | 354 | }); |
| 306 | 355 | try add_include_dirs(comp, arena, &args); |
| 356 | |
| 357 | const shared_def = switch (dep.flavor) { |
| 358 | .shared => "-DSHARED", |
| 359 | .nonshared => "-DLIBC_NONSHARED=1", |
| 360 | }; |
| 307 | 361 | try args.appendSlice(&[_][]const u8{ |
| 308 | 362 | "-D_LIBC_REENTRANT", |
| 309 | 363 | "-include", |
| ... | ... | @@ -313,11 +367,11 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 313 | 367 | "-include", |
| 314 | 368 | try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"), |
| 315 | 369 | "-DPIC", |
| 316 | | "-DLIBC_NONSHARED=1", |
| 370 | shared_def, |
| 317 | 371 | "-DTOP_NAMESPACE=glibc", |
| 318 | 372 | }); |
| 319 | 373 | c_source_files[i] = .{ |
| 320 | | .src_path = try lib_path(comp, arena, dep), |
| 374 | .src_path = try lib_path(comp, arena, dep.path), |
| 321 | 375 | .extra_flags = args.items, |
| 322 | 376 | }; |
| 323 | 377 | } |