aboutsummaryrefslogtreecommitdiff
path: root/src/linker.cpp
diff options
context:
space:
mode:
authorLaytan Laats <laytanlaats@hotmail.com>2024-09-04 23:45:30 +0200
committerLaytan Laats <laytanlaats@hotmail.com>2024-09-05 00:12:16 +0200
commit6778598bc648a4c605fb1b488185fad59668185a (patch)
tree6d4701f9cc29468b62ff20c31395bf5a9253db77 /src/linker.cpp
parent0aa971207ba14f791b1cae3652e67e674710cf8e (diff)
support the rpath changes on macos
Diffstat (limited to 'src/linker.cpp')
-rw-r--r--src/linker.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/linker.cpp b/src/linker.cpp
index cdda87697..500fead69 100644
--- a/src/linker.cpp
+++ b/src/linker.cpp
@@ -549,11 +549,7 @@ gb_internal i32 linker_stage(LinkerData *gen) {
// local to the executable (unless the system collection is used, in which case we search
// the system library paths for the library file).
if (string_ends_with(lib, str_lit(".a")) || string_ends_with(lib, str_lit(".o")) || string_ends_with(lib, str_lit(".so")) || string_contains_string(lib, str_lit(".so."))) {
- // static libs and object files, absolute full path relative to the file in which the lib was imported from
lib_str = gb_string_append_fmt(lib_str, " -l:\"%.*s\" ", LIT(lib));
-
- // NOTE(laytan): If .so, I think we can check for the existence of "$OUT_DIRECTORY/$lib" here and print an error telling the user to copy over the file, or we can even do the copy for them?
-
} else {
// dynamic or static system lib, just link regularly searching system library paths
lib_str = gb_string_append_fmt(lib_str, " -l%.*s ", LIT(lib));
@@ -642,9 +638,13 @@ gb_internal i32 linker_stage(LinkerData *gen) {
}
if (!build_context.no_rpath) {
- // Set the rpath to the $ORIGIN (the path of the executable),
+ // Set the rpath to the $ORIGIN/@loader_path (the path of the executable),
// so that dynamic libraries are looked for at that path.
- gb_string_appendc(link_settings, "-Wl,-rpath,\\$ORIGIN ");
+ if (build_context.metrics.os == TargetOs_darwin) {
+ link_settings = gb_string_appendc(link_settings, "-Wl,-rpath,@loader_path ");
+ } else {
+ link_settings = gb_string_appendc(link_settings, "-Wl,-rpath,\\$ORIGIN ");
+ }
}
if (!build_context.no_crt) {