OSX force_load option (#743)

* Update clang.rs

* fmt
This commit is contained in:
Dongjia "toka" Zhang 2022-08-27 15:51:11 +02:00 committed by GitHub
parent fc349bb7b1
commit 2389f677f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -264,7 +264,10 @@ impl CompilerWrapper for ClangWrapper {
if cfg!(unix) {
if cfg!(target_vendor = "apple") {
self.add_link_arg(lib_file)
// Same as --whole-archive on linux
// Without this option, the linker picks the first symbols it finds and does not care if it's a weak or a strong symbol
// See: <https://stackoverflow.com/questions/13089166/how-to-make-gcc-link-strong-symbol-in-static-library-to-overwrite-weak-symbol>
self.add_link_arg("-Wl,-force_load").add_link_arg(lib_file)
} else {
self.add_link_arg("-Wl,--whole-archive")
.add_link_arg(lib_file)