Skip to content

Commit 4c3367a

Browse files
committed
lib: add support for omitting soname
This commit adds the `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 db6d02b commit 4c3367a

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+
soname: ?bool,
2122
unwind_tables: ?std.builtin.UnwindTables,
2223
single_threaded: ?bool,
2324
stack_protector: ?bool,
@@ -247,6 +248,7 @@ pub const CreateOptions = struct {
247248
link_libcpp: ?bool = null,
248249
single_threaded: ?bool = null,
249250
strip: ?bool = null,
251+
soname: ?bool = null,
250252
unwind_tables: ?std.builtin.UnwindTables = null,
251253
dwarf_format: ?std.dwarf.Format = null,
252254
code_model: std.builtin.CodeModel = .default,
@@ -296,6 +298,7 @@ pub fn init(
296298
.frameworks = .{},
297299
.link_objects = .{},
298300
.strip = options.strip,
301+
.soname = options.soname,
299302
.unwind_tables = options.unwind_tables,
300303
.single_threaded = options.single_threaded,
301304
.stack_protector = options.stack_protector,
@@ -545,6 +548,7 @@ pub fn appendZigProcessFlags(
545548
const b = m.owner;
546549

547550
try addFlag(zig_args, m.strip, "-fstrip", "-fno-strip");
551+
try addFlag(zig_args, m.soname, "-fsoname", "-fno-soname");
548552
try addFlag(zig_args, m.single_threaded, "-fsingle-threaded", "-fno-single-threaded");
549553
try addFlag(zig_args, m.stack_check, "-fstack-check", "-fno-stack-check");
550554
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+
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+
.soname = overlay.soname,
100102
});
101103

102104
if (overlay.objcpp_source_bytes) |bytes| {

0 commit comments

Comments
 (0)