From 7bde2ec8ca20e3c70444767a7caf995a6e3a3c13 Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Thu, 7 Nov 2019 17:21:49 -0800 Subject: [PATCH] MacOS: add linker flag "-undefined dynamic_lookup" for shared libs. Necessary for shared libraries where not all symbols are resolved until the library is loaded at runtime. Fixes #62874 --- src/librustc_codegen_ssa/back/linker.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustc_codegen_ssa/back/linker.rs b/src/librustc_codegen_ssa/back/linker.rs index 999cc40658503..d0248e5410b6c 100644 --- a/src/librustc_codegen_ssa/back/linker.rs +++ b/src/librustc_codegen_ssa/back/linker.rs @@ -361,6 +361,9 @@ impl<'a> Linker for GccLinker<'a> { self.cmd.arg("-dynamiclib"); self.linker_arg("-dylib"); + // some symbols may be defined in the program loading the library + self.linker_arg("-undefined,dynamic_lookup"); + // Note that the `osx_rpath_install_name` option here is a hack // purely to support rustbuild right now, we should get a more // principled solution at some point to force the compiler to pass