| author | |
| committer | |
| log | 2ee864ca5eb46468e8e0f4237a5532b76b60d715 |
| tree | a70213c0c4c9f5c861e4c784e5980d6b60fea08d |
| parent | 927e59d0532c77e2fb3ead0c9c4f7ead0454785a |
6 files changed, 52 insertions(+), 4 deletions(-)
src/Compilation.zig+8| ... | ... | @@ -825,6 +825,7 @@ pub const InitOptions = struct { |
| 825 | 825 | rdynamic: bool = false, |
| 826 | 826 | strip: bool = false, |
| 827 | 827 | function_sections: bool = false, |
| 828 | no_builtin: bool = false, | |
| 828 | 829 | is_native_os: bool, |
| 829 | 830 | is_native_abi: bool, |
| 830 | 831 | time_report: bool = false, |
| ... | ... | @@ -1351,6 +1352,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1351 | 1352 | cache.hash.add(omit_frame_pointer); |
| 1352 | 1353 | cache.hash.add(link_mode); |
| 1353 | 1354 | cache.hash.add(options.function_sections); |
| 1355 | cache.hash.add(options.no_builtin); | |
| 1354 | 1356 | cache.hash.add(strip); |
| 1355 | 1357 | cache.hash.add(link_libc); |
| 1356 | 1358 | cache.hash.add(link_libcpp); |
| ... | ... | @@ -1682,6 +1684,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1682 | 1684 | .is_native_os = options.is_native_os, |
| 1683 | 1685 | .is_native_abi = options.is_native_abi, |
| 1684 | 1686 | .function_sections = options.function_sections, |
| 1687 | .no_builtin = options.no_builtin, | |
| 1685 | 1688 | .allow_shlib_undefined = options.linker_allow_shlib_undefined, |
| 1686 | 1689 | .bind_global_refs_locally = options.linker_bind_global_refs_locally orelse false, |
| 1687 | 1690 | .import_memory = options.linker_import_memory orelse false, |
| ... | ... | @@ -3925,6 +3928,10 @@ pub fn addCCArgs( |
| 3925 | 3928 | try argv.append("-ffunction-sections"); |
| 3926 | 3929 | } |
| 3927 | 3930 | |
| 3931 | if (comp.bin_file.options.no_builtin) { | |
| 3932 | try argv.append("-fno-builtin"); | |
| 3933 | } | |
| 3934 | ||
| 3928 | 3935 | if (comp.bin_file.options.link_libcpp) { |
| 3929 | 3936 | const libcxx_include_path = try std.fs.path.join(arena, &[_][]const u8{ |
| 3930 | 3937 | comp.zig_lib_directory.path.?, "libcxx", "include", |
| ... | ... | @@ -4997,6 +5004,7 @@ fn buildOutputFromZig( |
| 4997 | 5004 | .optimize_mode = comp.compilerRtOptMode(), |
| 4998 | 5005 | .link_mode = .Static, |
| 4999 | 5006 | .function_sections = true, |
| 5007 | .no_builtin = true, | |
| 5000 | 5008 | .want_sanitize_c = false, |
| 5001 | 5009 | .want_stack_check = false, |
| 5002 | 5010 | .want_red_zone = comp.bin_file.options.red_zone, |
src/clang_options_data.zig+16-2| ... | ... | @@ -2529,7 +2529,14 @@ flagpd1("fborland-extensions"), |
| 2529 | 2529 | flagpd1("fbounds-check"), |
| 2530 | 2530 | sepd1("fbracket-depth"), |
| 2531 | 2531 | flagpd1("fbranch-count-reg"), |
| 2532 | flagpd1("fbuiltin"), | |
| 2532 | .{ | |
| 2533 | .name = "fbuiltin", | |
| 2534 | .syntax = .flag, | |
| 2535 | .zig_equivalent = .builtin, | |
| 2536 | .pd1 = true, | |
| 2537 | .pd2 = false, | |
| 2538 | .psl = false, | |
| 2539 | }, | |
| 2533 | 2540 | flagpd1("fbuiltin-module-map"), |
| 2534 | 2541 | flagpd1("fcall-saved-x10"), |
| 2535 | 2542 | flagpd1("fcall-saved-x11"), |
| ... | ... | @@ -2925,7 +2932,14 @@ flagpd1("fno-blocks"), |
| 2925 | 2932 | flagpd1("fno-borland-extensions"), |
| 2926 | 2933 | flagpd1("fno-bounds-check"), |
| 2927 | 2934 | flagpd1("fno-branch-count-reg"), |
| 2928 | flagpd1("fno-builtin"), | |
| 2935 | .{ | |
| 2936 | .name = "fno-builtin", | |
| 2937 | .syntax = .flag, | |
| 2938 | .zig_equivalent = .no_builtin, | |
| 2939 | .pd1 = true, | |
| 2940 | .pd2 = false, | |
| 2941 | .psl = false, | |
| 2942 | }, | |
| 2929 | 2943 | flagpd1("fno-caller-saves"), |
| 2930 | 2944 | .{ |
| 2931 | 2945 | .name = "fno-caret-diagnostics", |
src/codegen/llvm.zig+3-1| ... | ... | @@ -2347,7 +2347,9 @@ pub const DeclGen = struct { |
| 2347 | 2347 | if (comp.unwind_tables) { |
| 2348 | 2348 | dg.addFnAttr(llvm_fn, "uwtable"); |
| 2349 | 2349 | } |
| 2350 | if (comp.bin_file.options.skip_linker_dependencies) { | |
| 2350 | if (comp.bin_file.options.skip_linker_dependencies or | |
| 2351 | comp.bin_file.options.no_builtin) | |
| 2352 | { | |
| 2351 | 2353 | // The intent here is for compiler-rt and libc functions to not generate |
| 2352 | 2354 | // infinite recursion. For example, if we are compiling the memcpy function, |
| 2353 | 2355 | // and llvm detects that the body is equivalent to memcpy, it may replace the |
src/link.zig+1| ... | ... | @@ -108,6 +108,7 @@ pub const Options = struct { |
| 108 | 108 | link_libcpp: bool, |
| 109 | 109 | link_libunwind: bool, |
| 110 | 110 | function_sections: bool, |
| 111 | no_builtin: bool, | |
| 111 | 112 | eh_frame_hdr: bool, |
| 112 | 113 | emit_relocs: bool, |
| 113 | 114 | rdynamic: bool, |
src/main.zig+16-1| ... | ... | @@ -381,6 +381,10 @@ const usage_build_generic = |
| 381 | 381 | \\ -fno-stage1 Prevent using bootstrap compiler as the codegen backend |
| 382 | 382 | \\ -fsingle-threaded Code assumes there is only one thread |
| 383 | 383 | \\ -fno-single-threaded Code may not assume there is only one thread |
| 384 | \\ -fbuiltin Enable implicit builtin knowledge of functions | |
| 385 | \\ -fno-builtin Disable implicit builtin knowledge of functions | |
| 386 | \\ -ffunction-sections Places each function in a separate section | |
| 387 | \\ -fno-function-sections All functions go into same section | |
| 384 | 388 | \\ --strip Omit debug symbols |
| 385 | 389 | \\ -ofmt=[mode] Override target object format |
| 386 | 390 | \\ elf Executable and Linking Format |
| ... | ... | @@ -398,7 +402,6 @@ const usage_build_generic = |
| 398 | 402 | \\ -D[macro]=[value] Define C [macro] to [value] (1 if [value] omitted) |
| 399 | 403 | \\ --libc [file] Provide a file which specifies libc paths |
| 400 | 404 | \\ -cflags [flags] -- Set extra flags for the next positional C source files |
| 401 | \\ -ffunction-sections Places each function in a separate section | |
| 402 | 405 | \\ |
| 403 | 406 | \\Link Options: |
| 404 | 407 | \\ -l[lib], --library [lib] Link against system library (only if actually used) |
| ... | ... | @@ -604,6 +607,7 @@ fn buildOutputType( |
| 604 | 607 | var compatibility_version: ?std.builtin.Version = null; |
| 605 | 608 | var strip = false; |
| 606 | 609 | var function_sections = false; |
| 610 | var no_builtin = false; | |
| 607 | 611 | var watch = false; |
| 608 | 612 | var debug_compile_errors = false; |
| 609 | 613 | var verbose_link = std.process.hasEnvVarConstant("ZIG_VERBOSE_LINK"); |
| ... | ... | @@ -1241,6 +1245,12 @@ fn buildOutputType( |
| 1241 | 1245 | single_threaded = false; |
| 1242 | 1246 | } else if (mem.eql(u8, arg, "-ffunction-sections")) { |
| 1243 | 1247 | function_sections = true; |
| 1248 | } else if (mem.eql(u8, arg, "-fno-function-sections")) { | |
| 1249 | function_sections = false; | |
| 1250 | } else if (mem.eql(u8, arg, "-fbuiltin")) { | |
| 1251 | no_builtin = false; | |
| 1252 | } else if (mem.eql(u8, arg, "-fno-builtin")) { | |
| 1253 | no_builtin = true; | |
| 1244 | 1254 | } else if (mem.eql(u8, arg, "--eh-frame-hdr")) { |
| 1245 | 1255 | link_eh_frame_hdr = true; |
| 1246 | 1256 | } else if (mem.eql(u8, arg, "--emit-relocs")) { |
| ... | ... | @@ -1464,6 +1474,8 @@ fn buildOutputType( |
| 1464 | 1474 | .no_omit_frame_pointer => omit_frame_pointer = false, |
| 1465 | 1475 | .function_sections => function_sections = true, |
| 1466 | 1476 | .no_function_sections => function_sections = false, |
| 1477 | .builtin => no_builtin = false, | |
| 1478 | .no_builtin => no_builtin = true, | |
| 1467 | 1479 | .color_diagnostics => color = .on, |
| 1468 | 1480 | .no_color_diagnostics => color = .off, |
| 1469 | 1481 | .stack_check => want_stack_check = true, |
| ... | ... | @@ -2847,6 +2859,7 @@ fn buildOutputType( |
| 2847 | 2859 | .strip = strip, |
| 2848 | 2860 | .single_threaded = single_threaded, |
| 2849 | 2861 | .function_sections = function_sections, |
| 2862 | .no_builtin = no_builtin, | |
| 2850 | 2863 | .self_exe_path = self_exe_path, |
| 2851 | 2864 | .thread_pool = &thread_pool, |
| 2852 | 2865 | .clang_passthrough_mode = clang_passthrough_mode, |
| ... | ... | @@ -4572,6 +4585,8 @@ pub const ClangArgIterator = struct { |
| 4572 | 4585 | no_omit_frame_pointer, |
| 4573 | 4586 | function_sections, |
| 4574 | 4587 | no_function_sections, |
| 4588 | builtin, | |
| 4589 | no_builtin, | |
| 4575 | 4590 | color_diagnostics, |
| 4576 | 4591 | no_color_diagnostics, |
| 4577 | 4592 | stack_check, |
tools/update_clang_options.zig+8| ... | ... | @@ -320,6 +320,14 @@ const known_options = [_]KnownOpt{ |
| 320 | 320 | .name = "fno-function-sections", |
| 321 | 321 | .ident = "no_function_sections", |
| 322 | 322 | }, |
| 323 | .{ | |
| 324 | .name = "fbuiltin", | |
| 325 | .ident = "builtin", | |
| 326 | }, | |
| 327 | .{ | |
| 328 | .name = "fno-builtin", | |
| 329 | .ident = "no_builtin", | |
| 330 | }, | |
| 323 | 331 | .{ |
| 324 | 332 | .name = "fcolor-diagnostics", |
| 325 | 333 | .ident = "color_diagnostics", |