diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2021-12-17 00:18:45 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-12-18 17:55:53 -0800 |
| commit | a08137330c20ce77724a9fc80acf46a7e7978a90 (patch) | |
| tree | 64495bae9db54d234e2bc78599a7594d7529d3d2 /src/Compilation.zig | |
| parent | 9a8fdbe0a07ed9ece1d44634c6fe82c23b6209eb (diff) | |
| download | zig-a08137330c20ce77724a9fc80acf46a7e7978a90.tar.gz zig-a08137330c20ce77724a9fc80acf46a7e7978a90.zip | |
macho: handle -install_name option for dylibs/MachO
The status quo for the `build.zig` build system is preserved in
the sense that, if the user does not explicitly override
`dylib.setInstallName(...);` in their build script, the default
of `@rpath/libname.dylib` applies. However, should they want to
override the default behaviour, they can either:
1) unset it with
```dylib.setIntallName(null);```
2) set it to an explicit string with
```dylib.setInstallName("somename.dylib");```
When it comes to the command line however, the default is not to
use `@rpath` for the install name when creating a dylib. The user
will now be required to explicitly specify the `@rpath` as part
of the desired install name should they choose so like so:
1) with `build-lib`
```
zig build-lib -dynamic foo.zig -install_name @rpath/libfoo.dylib
```
2) with `cc`
```
zig cc -shared foo.c -o libfoo.dylib -Wl,"-install_name=@rpath/libfoo.dylib"
```
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index b3c2608c05..861771def4 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -780,6 +780,8 @@ pub const InitOptions = struct { enable_link_snapshots: bool = false, /// (Darwin) Path and version of the native SDK if detected. native_darwin_sdk: ?std.zig.system.darwin.DarwinSDK = null, + /// (Darwin) Install name of the dylib + install_name: ?[]const u8 = null, }; fn addPackageTableToCacheHash( @@ -1509,6 +1511,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { .use_stage1 = use_stage1, .enable_link_snapshots = options.enable_link_snapshots, .native_darwin_sdk = options.native_darwin_sdk, + .install_name = options.install_name, }); errdefer bin_file.destroy(); comp.* = .{ |
