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