Skip to content

Commit d708c4c

Browse files
committed
lib: add support for omitting soname
This commit adds the `omit_soname` option for `Build.Module` and `OverlayOptions`. This controls whether `-fsoname` or `-fno-soname` is passed to the linker. This is needed to implement the new test in #19818
1 parent b80a4ae commit d708c4c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/std/Build/Module.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ frameworks: std.StringArrayHashMapUnmanaged(LinkFrameworkOptions),
1818
link_objects: std.ArrayListUnmanaged(LinkObject),
1919

2020
strip: ?bool,
21+
omit_soname: ?bool,
2122
unwind_tables: ?std.builtin.UnwindTables,
2223
single_threaded: ?bool,
2324
stack_protector: ?bool,
@@ -252,6 +253,7 @@ pub const CreateOptions = struct {
252253
link_libcpp: ?bool = null,
253254
single_threaded: ?bool = null,
254255
strip: ?bool = null,
256+
omit_soname: ?bool = null,
255257
unwind_tables: ?std.builtin.UnwindTables = null,
256258
dwarf_format: ?std.dwarf.Format = null,
257259
code_model: std.builtin.CodeModel = .default,
@@ -301,6 +303,7 @@ pub fn init(
301303
.frameworks = .{},
302304
.link_objects = .{},
303305
.strip = options.strip,
306+
.omit_soname = options.omit_soname,
304307
.unwind_tables = options.unwind_tables,
305308
.single_threaded = options.single_threaded,
306309
.stack_protector = options.stack_protector,
@@ -555,6 +558,7 @@ pub fn appendZigProcessFlags(
555558
const b = m.owner;
556559

557560
try addFlag(zig_args, m.strip, "-fstrip", "-fno-strip");
561+
try addFlag(zig_args, m.omit_soname, "-fno-soname", "-fsoname");
558562
try addFlag(zig_args, m.single_threaded, "-fsingle-threaded", "-fno-single-threaded");
559563
try addFlag(zig_args, m.stack_check, "-fstack-check", "-fno-stack-check");
560564
try addFlag(zig_args, m.stack_protector, "-fstack-protector", "-fno-stack-protector");

test/link/link.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const OverlayOptions = struct {
4444
zig_source_bytes: ?[]const u8 = null,
4545
pic: ?bool = null,
4646
strip: ?bool = null,
47+
omit_soname: ?bool = null,
4748
};
4849

4950
pub fn addExecutable(b: *std.Build, base: Options, overlay: OverlayOptions) *Compile {
@@ -97,6 +98,7 @@ fn createModule(b: *Build, base: Options, overlay: OverlayOptions) *Build.Module
9798
},
9899
.pic = overlay.pic,
99100
.strip = if (base.strip) |s| s else overlay.strip,
101+
.omit_soname = overlay.omit_soname,
100102
});
101103

102104
if (overlay.objcpp_source_bytes) |bytes| {

0 commit comments

Comments
 (0)