aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorMotiejus Jakštys <motiejus@jakstys.lt>2022-06-23 08:28:35 +0300
committerAndrew Kelley <andrew@ziglang.org>2023-02-16 18:44:56 -0500
commitb1b944a683a2143584055468ca7958d298a9742b (patch)
treeb7e969d756016f064f684070aaa6a2a7570e6323 /src/Compilation.zig
parentf911c933b287bd9f27b6b5f977a671aef05ca6c9 (diff)
downloadzig-b1b944a683a2143584055468ca7958d298a9742b.tar.gz
zig-b1b944a683a2143584055468ca7958d298a9742b.zip
[elf linker] add --sort-section
Tested by: created a "hello world" C file and compiled with: zig cc -v main.c -Wl,--sort-section=name -o main ... and verified the `--sort-section=name` is passed to ld.lld. Refs https://github.com/zigchroot/zig-chroot/issues/1
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index c6737ed3eb..ce0bfb9908 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -989,6 +989,7 @@ pub const InitOptions = struct {
linker_optimization: ?u8 = null,
linker_compress_debug_sections: ?link.CompressDebugSections = null,
linker_module_definition_file: ?[]const u8 = null,
+ linker_sort_section: ?link.SortSection = null,
major_subsystem_version: ?u32 = null,
minor_subsystem_version: ?u32 = null,
clang_passthrough_mode: bool = false,
@@ -1853,6 +1854,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
.bind_global_refs_locally = options.linker_bind_global_refs_locally orelse false,
.compress_debug_sections = options.linker_compress_debug_sections orelse .none,
.module_definition_file = options.linker_module_definition_file,
+ .sort_section = options.linker_sort_section,
.import_memory = options.linker_import_memory orelse false,
.import_symbols = options.linker_import_symbols,
.import_table = options.linker_import_table,
@@ -2684,6 +2686,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
man.hash.add(comp.bin_file.options.hash_style);
man.hash.add(comp.bin_file.options.compress_debug_sections);
man.hash.add(comp.bin_file.options.include_compiler_rt);
+ man.hash.addOptional(comp.bin_file.options.sort_section);
if (comp.bin_file.options.link_libc) {
man.hash.add(comp.bin_file.options.libc_installation != null);
if (comp.bin_file.options.libc_installation) |libc_installation| {