From 6edc3b934d37a82517269748709333a267b5262b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20Ker=C3=A4nen?= Date: Tue, 25 Apr 2023 23:43:28 +0300 Subject: [PATCH] Add install name for MacOS dylib Without setting the install name, the copied object will still reference to the original object, which is not going to work if it is ever moved out of CBQN directory: $ otool -L libcbqn.dylib libcbqn.dylib: build/obj2/linker-4qa8skka2dk9e991rjom3lns7elgmlak4h98e0bcb0t8os3o6o5/res (compatibility version 0.0.0, current version 0.0.0) With this change the install name of the dylib object is set to @rpath/libcbqn.dylib, so it's loaded the same way .so files on Linux are. --- build/src/build.bqn | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/build/src/build.bqn b/build/src/build.bqn index afab576e..a850ef8b 100755 --- a/build/src/build.bqn +++ b/build/src/build.bqn @@ -320,14 +320,15 @@ po ← { # parsed options args∾↩ GetOpt "lf" args∾↩ GetOpt "CCFLAGS" args∾↩ GetOpt "LDFLAGS" - args∾↩ ( emcc) / ⟨"-s", "EXPORTED_FUNCTIONS=_main,_cbqn_runLine,_cbqn_evalSrc", "-s", "EXPORTED_RUNTIME_METHODS=ccall,cwrap", "-s", "ALLOW_MEMORY_GROWTH=1"⟩ - args∾↩ ( wasi) / ⟨"-lwasi-emulated-mman", "--target=wasm32-wasi", "-Wl,-z,stack-size=8388608", "-Wl,--initial-memory=67108864"⟩ - args∾↩ (shared ∧ wasi) / ⟨"-mexec-model=reactor", "-Wl,--export-dynamic", "-Wl,--export=malloc", "-Wl,--export=free"⟩ - args∾↩ (shared ∧¬wasi) / ⟨"-shared"⟩ - args∾↩ ( rdynamic) / ⟨"-rdynamic"⟩ - args∾↩ ((¬wasm)∧ ¬pie) / ⟨"-no-pie"⟩ - args∾↩ (pie ∧ ¬shared) / ⟨"-fPIE", "-pie"⟩ - args∾↩ ( windows) / ⟨"-lpthread"⟩ + args∾↩ ( emcc) / ⟨"-s", "EXPORTED_FUNCTIONS=_main,_cbqn_runLine,_cbqn_evalSrc", "-s", "EXPORTED_RUNTIME_METHODS=ccall,cwrap", "-s", "ALLOW_MEMORY_GROWTH=1"⟩ + args∾↩ ( wasi) / ⟨"-lwasi-emulated-mman", "--target=wasm32-wasi", "-Wl,-z,stack-size=8388608", "-Wl,--initial-memory=67108864"⟩ + args∾↩ (shared ∧ wasi) / ⟨"-mexec-model=reactor", "-Wl,--export-dynamic", "-Wl,--export=malloc", "-Wl,--export=free"⟩ + args∾↩ (shared ∧ ¬wasi) / ⟨"-shared"⟩ + args∾↩ (shared ∧ macos) / ⟨"-install_name", "@rpath/libcbqn.dylib"⟩ + args∾↩ ( rdynamic) / ⟨"-rdynamic"⟩ + args∾↩ ((¬wasm)∧ ¬pie) / ⟨"-no-pie"⟩ + args∾↩ (pie ∧ ¬shared) / ⟨"-fPIE", "-pie"⟩ + args∾↩ ( windows) / ⟨"-lpthread"⟩ args ↩ args (¬∘∊/⊣) GetOpt "rm_lf" {"linker: "∾•Repr 𝕩} _verboseLog args linker ↩ args