Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Versioned Darwin dylib not working after 0.26 #2944

Closed
linzhp opened this issue Aug 27, 2021 · 3 comments · Fixed by #2947 or #2989
Closed

Versioned Darwin dylib not working after 0.26 #2944

linzhp opened this issue Aug 27, 2021 · 3 comments · Fixed by #2947 or #2989

Comments

@linzhp
Copy link
Contributor

linzhp commented Aug 27, 2021

What version of rules_go are you using?

It was working in v0.25.x, but stopped working after 0.26

What version of gazelle are you using?

d7082fb305422c27d9a33530e6e0f6be463ba178

What version of Bazel are you using?

3.7.0

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

Darwin amd64

Any other potentially useful information about your toolchain?

None

What did you do?

  1. apply this patch to rules_go master:
diff --git a/tests/core/cgo/BUILD.bazel b/tests/core/cgo/BUILD.bazel
index d205044c..c1e557a5 100644
--- a/tests/core/cgo/BUILD.bazel
+++ b/tests/core/cgo/BUILD.bazel
@@ -162,7 +162,7 @@ go_library(
         # This test exists just for versioned `.so`s on Linux,
         # but we can reuse the above test's dylib so it passes on darwin,
         # where filename suffixes are not used for library version.
-        "@io_bazel_rules_go//go/platform:darwin": [":darwin_imported_dylib"],
+        "@io_bazel_rules_go//go/platform:darwin": [":darwin_imported_versioned_dylib"],
         "//conditions:default": [":linux_imported_versioned_dylib"],
         # TODO(jayconrod): Support windows, skip others.
     }),
@@ -177,6 +177,12 @@ cc_import(
     tags = ["manual"],
 )
 
+cc_import(
+    name = "darwin_imported_versioned_dylib",
+    shared_library = "libimported.dylib.2",
+    tags = ["manual"],
+)
+
 go_test(
     name = "generated_versioned_dylib_test",
     srcs = ["dylib_test.go"],
diff --git a/tests/core/cgo/generate_imported_dylib.sh b/tests/core/cgo/generate_imported_dylib.sh
index 5c272ef4..82f43d9e 100755
--- a/tests/core/cgo/generate_imported_dylib.sh
+++ b/tests/core/cgo/generate_imported_dylib.sh
@@ -11,6 +11,7 @@ case "$(uname -s)" in
     ;;
   Darwin*)
     cc -shared -Wl,-install_name,@rpath/libimported.dylib -o libimported.dylib imported.c
+    cc -shared -Wl,-install_name,@rpath/libimported.dylib.2 -o libimported.dylib.2 imported.c
     ;;
   *)
     echo "Unsupported OS: $(uname -s)" >&2
  1. Run tests/core/cgo/generate_imported_dylib.sh
  2. Run bazel test --test_output=errors tests/core/cgo:versioned_dylib_test

What did you expect to see?

Test passes

What did you see instead?

dyld: Library not loaded: @rpath/libimported.dylib.2
  Referenced from: /private/var/tmp/_bazel_zplin/b32df389e141e2de05812b7963fff9af/sandbox/darwin-sandbox/24/execroot/io_bazel_rules_go/bazel-out/darwin-fastbuild/bin/tests/core/cgo/versioned_dylib_test_/versioned_dylib_test.runfiles/io_bazel_rules_go/tests/core/cgo/versioned_dylib_test_/versioned_dylib_test
  Reason: image not found
@linzhp linzhp changed the title Versioned Darwin dylib not working after 0.25 Versioned Darwin dylib not working after 0.26 Aug 27, 2021
@linzhp
Copy link
Contributor Author

linzhp commented Aug 27, 2021

5093917 is the culprit. @steeve

@steeve
Copy link
Contributor

steeve commented Sep 1, 2021

It seems it should around this place: 5093917#diff-b43198572b06581075fc3fdbb5fb2d25a82bda55d4e77b1600eaff2881b6365dL114

@linzhp
Copy link
Contributor Author

linzhp commented Sep 24, 2021

Reopening this, because #2947 doesn't fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants