Skip to content

std, stage1: make shared library versioning optional #6315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 11, 2020

Conversation

ifreund
Copy link
Member

@ifreund ifreund commented Sep 10, 2020

This commit changes the behavior of stage1 to emit libfoo.so instead
of libfoo.so.0.0.0 when none of the --ver-major, --ver-minor, or
--ver-patch flags are set.

It also makes it possible to create unversioned shared libraries
using the zig build system, changing the version parameter of
addSharedLibrary() to a tagged union.

Closes #2230

Comment on lines 261 to 264
pub fn addSharedLibrary(self: *Builder, name: []const u8, root_src: ?[]const u8, kind: union(enum) {
versioned: Version,
unversioned: void,
}) *LibExeObjStep {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This takes a tagged union instead of ?Version due to @andrewrk's suggestion in #2230 (comment). However, I'm not sure this achieves the desired effect. Leaving off the version is still the "easier" option, and setting a version becomes more cumbersome:

const lib = b.addSharedLibrary("foo", "foo.zig", .unversioned);
const lib = b.addSharedLibrary("foo", "foo.zig", .{ .versioned = b.version(0,1,0) });

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if b.version() returned an instance of this union?

That way its: b.version(0,1,0) vs .unversioned.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, seems obvious now.

This commit changes the behavior of stage1 to emit libfoo.so instead
of libfoo.so.0.0.0 when none of the --ver-major, --ver-minor, or
--ver-patch flags are set.

It also makes it possible to create unversioned shared libraries
using the zig build system, changing the version parameter of
addSharedLibrary() to a tagged union.
@ifreund ifreund force-pushed the optional-shlib-version branch from 59f1b2e to 0a76a9b Compare September 11, 2020 08:46
@andrewrk andrewrk merged commit 42c32db into ziglang:master Sep 11, 2020
@ifreund ifreund deleted the optional-shlib-version branch September 11, 2020 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

shared library version should be optional
3 participants