From b3f2c629c68747e19f6a84d448f6133c754b6ab5 Mon Sep 17 00:00:00 2001 From: pancake Date: Fri, 29 May 2020 04:52:19 +0200 Subject: [PATCH] builder: use .dylib for -shared builds in macOS --- cmd/tools/vcreate.v | 1 + vlib/dl/dl_nix.c.v | 2 +- vlib/v/builder/cc.v | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/tools/vcreate.v b/cmd/tools/vcreate.v index 52cf7ee07c..c2c9365fc6 100644 --- a/cmd/tools/vcreate.v +++ b/cmd/tools/vcreate.v @@ -44,6 +44,7 @@ fn gen_gitignore(name string) string { 'main', '$name', '*.so', + '*.dylib', '*.dll' ].join('\n') } diff --git a/vlib/dl/dl_nix.c.v b/vlib/dl/dl_nix.c.v index 3e54e1710e..82d9d98f91 100644 --- a/vlib/dl/dl_nix.c.v +++ b/vlib/dl/dl_nix.c.v @@ -5,7 +5,7 @@ module dl pub const ( rtld_now = C.RTLD_NOW rtld_lazy = C.RTLD_LAZY - dl_ext = '.so' + dl_ext = '.so' ) fn C.dlopen(filename charptr, flags int) voidptr diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index 8662fbec15..f2c04b4292 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -147,7 +147,11 @@ fn (mut v Builder) cc() { if v.pref.is_shared { linker_flags << '-shared' a << '-fPIC' // -Wl,-z,defs' - v.pref.out_name += '.so' + $if macos { + v.pref.out_name += '.dylib' + } $else { + v.pref.out_name += '.so' + } } if v.pref.is_bare { a << '-fno-stack-protector'