diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-11-30 16:35:00 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-11-30 16:35:00 -0700 |
| commit | ff9798eb265b02d572ecbced675efcd7c763aea9 (patch) | |
| tree | a76c48fca7b7458f41c4dca14f9ec9eb30325818 /src/main.zig | |
| parent | 2fae28b6afc0e5411c9a9a9def43eeb59fba840f (diff) | |
| download | zig-ff9798eb265b02d572ecbced675efcd7c763aea9.tar.gz zig-ff9798eb265b02d572ecbced675efcd7c763aea9.zip | |
rework the bundle compiler-rt feature
* it is now -fcompiler-rt and -fno-compiler-rt to override the (quite
reasonable) default of bundling compiler-rt only for executables and
dynamic libraries.
- the build.zig API is still called bundle_compiler_rt however it is
now an optional bool instead of a bool. leaving it as `null` means
to use the compiler default.
* renamed some internal identifiers to make the source more readable
* additionally support -fcompiler-rt when doing build-obj for ELF files
since that target already supports linking multiple objects into one.
- includes an error message when attempting this for non-ELF. in the
future this could additionally be supported with a more advanced
implementation that does not rely on the linker.
* properly populate the linker cache hash
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/main.zig b/src/main.zig index 76e49cde2e..5e406152d3 100644 --- a/src/main.zig +++ b/src/main.zig @@ -314,7 +314,7 @@ const usage_build_generic = \\ -fno-soname (Linux) Disable emitting a SONAME \\ -fLLD Force using LLD as the linker \\ -fno-LLD Prevent using LLD as the linker - \\ -fcompiler-rt Always including compiler-rt symbols in output + \\ -fcompiler-rt Always include compiler-rt symbols in output \\ -fno-compiler-rt Prevent including compiler-rt symbols in output \\ -rdynamic Add all symbols to the dynamic symbol table \\ -rpath [path] Add directory to the runtime library search path @@ -480,6 +480,7 @@ fn buildOutputType( var want_sanitize_c: ?bool = null; var want_stack_check: ?bool = null; var want_valgrind: ?bool = null; + var want_compiler_rt: ?bool = null; var rdynamic: bool = false; var linker_script: ?[]const u8 = null; var version_script: ?[]const u8 = null; @@ -492,7 +493,6 @@ fn buildOutputType( var test_evented_io = false; var stack_size_override: ?u64 = null; var image_base_override: ?u64 = null; - var bundle_compiler_rt = false; var use_llvm: ?bool = null; var use_lld: ?bool = null; var use_clang: ?bool = null; @@ -797,8 +797,10 @@ fn buildOutputType( if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg}); i += 1; override_lib_dir = args[i]; - } else if (mem.eql(u8, arg, "--bundle-compiler-rt")) { - bundle_compiler_rt = true; + } else if (mem.eql(u8, arg, "-fcompiler-rt")) { + want_compiler_rt = true; + } else if (mem.eql(u8, arg, "-fno-compiler-rt")) { + want_compiler_rt = false; } else if (mem.eql(u8, arg, "-feach-lib-rpath")) { each_lib_rpath = true; } else if (mem.eql(u8, arg, "-fno-each-lib-rpath")) { @@ -1693,6 +1695,7 @@ fn buildOutputType( .want_sanitize_c = want_sanitize_c, .want_stack_check = want_stack_check, .want_valgrind = want_valgrind, + .want_compiler_rt = want_compiler_rt, .use_llvm = use_llvm, .use_lld = use_lld, .use_clang = use_clang, @@ -1710,7 +1713,6 @@ fn buildOutputType( .link_emit_relocs = link_emit_relocs, .stack_size_override = stack_size_override, .image_base_override = image_base_override, - .bundle_compiler_rt = bundle_compiler_rt, .strip = strip, .single_threaded = single_threaded, .function_sections = function_sections, |
