Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3e30c43
create pr with this
DhashS Sep 29, 2023
4b02438
Update src/Compilation.zig
DhashS Sep 30, 2023
e260a2a
make changes suggested by @motiejus
DhashS Sep 30, 2023
ccdb979
Merge branch 'add-no-undefined-version-linker-arg' of github.com:Dhas…
DhashS Sep 30, 2023
9bd334b
push flag thru Compilation and Elf
DhashS Sep 30, 2023
94b5bd8
Merge branch 'master' into add-no-undefined-version-linker-arg
DhashS Sep 30, 2023
8ff5bb0
woops
DhashS Sep 30, 2023
d7f165c
Merge branch 'add-no-undefined-version-linker-arg' of github.com:Dhas…
DhashS Sep 30, 2023
4451275
more woops
DhashS Sep 30, 2023
3ac80ac
Update src/link.zig
DhashS Sep 30, 2023
719ddf3
Update src/link/Elf.zig
DhashS Sep 30, 2023
4a6271d
Update src/Compilation.zig
DhashS Sep 30, 2023
9672c58
Update src/Compilation.zig
DhashS Sep 30, 2023
d7d2901
remove duplicate
DhashS Sep 30, 2023
a9b7fed
Update src/link/Elf.zig
DhashS Oct 7, 2023
202d9ba
Update src/link.zig
DhashS Oct 7, 2023
b0de657
Update src/main.zig
DhashS Oct 7, 2023
8f37748
Update src/main.zig
DhashS Oct 7, 2023
c7c1382
Update src/main.zig
DhashS Oct 7, 2023
a7b6364
Update src/Compilation.zig
DhashS Oct 7, 2023
bc66160
Update src/Compilation.zig
DhashS Oct 7, 2023
82b28c7
Update src/main.zig
DhashS Oct 7, 2023
2ea0369
Merge branch 'master' into add-no-undefined-version-linker-arg
DhashS Oct 7, 2023
f40fcb6
modify docstring to be LLD's
DhashS Oct 9, 2023
af85118
Merge branch 'master' into add-no-undefined-version-linker-arg
DhashS Oct 9, 2023
f86ac25
bump linker implementation version
DhashS Oct 14, 2023
a49a735
Merge branch 'add-no-undefined-version-linker-arg' of github.com:Dhas…
DhashS Oct 14, 2023
c578638
add to cache
DhashS Oct 14, 2023
8aec947
Merge branch 'master' into add-no-undefined-version-linker-arg
DhashS Oct 15, 2023
682bd7c
Update src/Compilation.zig
DhashS Oct 30, 2023
59ad896
Update src/link/Elf.zig
DhashS Oct 30, 2023
c0df02c
Merge branch 'master' into add-no-undefined-version-linker-arg
DhashS Oct 30, 2023
84840bb
Merge branch 'master' into add-no-undefined-version-linker-arg
DhashS Nov 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ pub const InitOptions = struct {
linker_script: ?[]const u8 = null,
version_script: ?[]const u8 = null,
soname: ?[]const u8 = null,
linker_no_undefined_version: ?bool = null,
linker_gc_sections: ?bool = null,
linker_allow_shlib_undefined: ?bool = null,
linker_bind_global_refs_locally: ?bool = null,
Expand All @@ -645,6 +646,8 @@ pub const InitOptions = struct {
linker_shared_memory: bool = false,
linker_global_base: ?u64 = null,
linker_export_symbol_names: []const []const u8 = &.{},
linker_undefined_version: ?bool = null,
linker_no_undefined_version: ?bool = null,
linker_print_gc_sections: bool = false,
linker_print_icf_sections: bool = false,
linker_print_map: bool = false,
Expand Down Expand Up @@ -1586,6 +1589,8 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
.shared_memory = options.linker_shared_memory,
.global_base = options.linker_global_base,
.export_symbol_names = options.linker_export_symbol_names,
.undefined_version = options.linker_undefined_version,
.no_undefined_version = options.linker.no_undefined_version,
.print_gc_sections = options.linker_print_gc_sections,
.print_icf_sections = options.linker_print_icf_sections,
.print_map = options.linker_print_map,
Expand Down
2 changes: 2 additions & 0 deletions src/link.zig
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ pub const Options = struct {
sort_section: ?SortSection,
major_subsystem_version: ?u32,
minor_subsystem_version: ?u32,
undefined_version: ?bool,
no_undefined_version: ?bool,
gc_sections: ?bool = null,
allow_shlib_undefined: ?bool,
subsystem: ?std.Target.SubSystem,
Expand Down
8 changes: 8 additions & 0 deletions src/link/Elf.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2054,6 +2054,14 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
try argv.append(arg);
}

if (self.base.options.undefined_version) {
try argv.append("--undefined-version");
}

if (self.base.options.no_undefined_version) {
try argv.append("--no-undefined-version");
}

if (gc_sections) {
try argv.append("--gc-sections");
}
Expand Down
12 changes: 11 additions & 1 deletion src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,8 @@ const usage_build_generic =
\\ -search_static_only Only search for static libs.
\\ -T[script], --script [script] Use a custom linker script
\\ --version-script [path] Provide a version .map file
\\ --undefined-version Allow the linker to link with symbols with undefined version
\\ --no-undefined-version Cause a fatal error if the linker attempts to link to a symbol with an undefined version
\\ --dynamic-linker [path] Set the dynamic interpreter path (usually ld.so)
\\ --sysroot [path] Set the system root directory (usually /)
\\ --version [ver] Dynamic library semver
Expand Down Expand Up @@ -843,6 +845,8 @@ fn buildOutputType(
var version_script: ?[]const u8 = null;
var disable_c_depfile = false;
var linker_sort_section: ?link.SortSection = null;
var linker_undefined_version: ?bool = null;
var linker_no_undefined_version: ?bool = null;
var linker_gc_sections: ?bool = null;
var linker_compress_debug_sections: ?link.CompressDebugSections = null;
var linker_allow_shlib_undefined: ?bool = null;
Expand Down Expand Up @@ -2360,7 +2364,11 @@ fn buildOutputType(
fatal("unable to parse /version '{s}': {s}", .{ arg, @errorName(err) });
};
have_version = true;
} else if (mem.eql(u8, arg, "--version")) {
} else if (mem.eql(u8, arg, "--undefined-version")) {
linker_undefined_version = true;
} else if (mem.eql(u8, arg, "--no-undefined-version")) {
linker_no_undefined_version = true;
} else if (mem.eql(u8, arg, "--version")) {
try std.io.getStdOut().writeAll("zig ld " ++ build_options.version ++ "\n");
process.exit(0);
} else {
Expand Down Expand Up @@ -3428,6 +3436,8 @@ fn buildOutputType(
.version_script = version_script,
.disable_c_depfile = disable_c_depfile,
.soname = resolved_soname,
.linker_undefined_version = linker_undefined_version,
.linker_no_undefined_version = linker_no_undefined_version,
.linker_sort_section = linker_sort_section,
.linker_gc_sections = linker_gc_sections,
.linker_allow_shlib_undefined = linker_allow_shlib_undefined,
Expand Down