builder: use .dylib for -shared builds in macOS

pull/5114/head
pancake 2020-05-29 04:52:19 +02:00 committed by GitHub
parent 104c278216
commit b3f2c629c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View File

@ -44,6 +44,7 @@ fn gen_gitignore(name string) string {
'main', 'main',
'$name', '$name',
'*.so', '*.so',
'*.dylib',
'*.dll' '*.dll'
].join('\n') ].join('\n')
} }

View File

@ -5,7 +5,7 @@ module dl
pub const ( pub const (
rtld_now = C.RTLD_NOW rtld_now = C.RTLD_NOW
rtld_lazy = C.RTLD_LAZY rtld_lazy = C.RTLD_LAZY
dl_ext = '.so' dl_ext = '.so'
) )
fn C.dlopen(filename charptr, flags int) voidptr fn C.dlopen(filename charptr, flags int) voidptr

View File

@ -147,7 +147,11 @@ fn (mut v Builder) cc() {
if v.pref.is_shared { if v.pref.is_shared {
linker_flags << '-shared' linker_flags << '-shared'
a << '-fPIC' // -Wl,-z,defs' 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 { if v.pref.is_bare {
a << '-fno-stack-protector' a << '-fno-stack-protector'