From 18a4e882dceb1e92a04ed060c94ff9abb0bc240a Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sun, 9 Jul 2023 16:56:06 -0600 Subject: [PATCH] Meta: Setup rpath/install_name for macOS libraries and binaries in gn --- Meta/gn/build/toolchain/BUILD.gn | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Meta/gn/build/toolchain/BUILD.gn b/Meta/gn/build/toolchain/BUILD.gn index 52e944619e6..3fec4745730 100644 --- a/Meta/gn/build/toolchain/BUILD.gn +++ b/Meta/gn/build/toolchain/BUILD.gn @@ -68,7 +68,7 @@ template("unix_toolchain") { tool("solink") { outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}" if (current_os == "ios" || current_os == "mac") { - command = "$ld -shared {{ldflags}} -o $outfile {{inputs}} {{libs}} {{frameworks}}" + command = "$ld -shared {{ldflags}} -o $outfile {{inputs}} {{libs}} {{frameworks}} -Wl,-install_name,@rpath/{{target_output_name}}{{output_extension}}" default_output_extension = ".dylib" } else { command = "$ld -shared {{ldflags}} -Wl,-soname,{{target_output_name}}{{output_extension}} -Wl,-rpath,\\\$ORIGIN -o $outfile {{inputs}} {{libs}}" @@ -86,7 +86,7 @@ template("unix_toolchain") { tool("solink_module") { outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}" if (current_os == "ios" || current_os == "mac") { - command = "$ld -shared {{ldflags}} -Wl,-flat_namespace -Wl,-undefined,suppress -o $outfile {{inputs}} {{libs}} {{frameworks}}" + command = "$ld -shared {{ldflags}} -Wl,-flat_namespace -Wl,-undefined,suppress -o $outfile {{inputs}} {{libs}} {{frameworks}} -Wl,-install_name,@rpath/{{target_output_name}}{{output_extension}}" default_output_extension = ".dylib" } else { command = "$ld -shared {{ldflags}} -Wl,-soname,{{target_output_name}}{{output_extension}} -Wl,-rpath,\\\$ORIGIN -o $outfile {{inputs}} {{libs}}" @@ -103,8 +103,7 @@ template("unix_toolchain") { tool("link") { outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}" if (current_os == "ios" || current_os == "mac") { - command = - "$ld {{ldflags}} -o $outfile {{inputs}} {{libs}} {{frameworks}}" + command = "$ld {{ldflags}} -o $outfile {{inputs}} {{libs}} {{frameworks}} -Wl,-rpath,@executable_path/../lib" } else { command = "$ld {{ldflags}} -o $outfile -Wl,--start-group {{inputs}} -Wl,--end-group -Wl,-rpath,\\\$ORIGIN/../lib {{libs}}" }