Monocypher icon indicating copy to clipboard operation
Monocypher copied to clipboard

Had to change soname to install_name on macos, but I don't really know why

Open SethArchambault opened this issue 2 years ago • 2 comments

Was getting this error:

$ make
cc -pedantic -Wall -Wextra -O3 -march=native -L/opt/homebrew/opt/llvm/lib -shared -Wl,-soname,libmonocypher.so.4 -o lib/libmonocypher.so.4 lib/monocypher.o lib/monocypher-ed25519.o
ld: unknown options: -soname
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [lib/libmonocypher.so.4] Error 1

And someone on stackoverflow said to change soname to install_name, so I did that: https://stackoverflow.com/questions/4580789/ld-unknown-option-soname-on-os-x

And it worked! But not very scientific and could have downsides.. But figured I'd let ya know.

-	$(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-soname,$(SONAME) -o $@ $(MAIN_O)
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-install_name,$(SONAME) -o $@ $(MAIN_O)

SethArchambault avatar Oct 20 '23 00:10 SethArchambault

Hmm, good catch, but I’ll need to investigate. I have a couple fixes in mind:

  1. Accepting your change, if it turns out it works with other compilers and linkers.
  2. Put the -soname option itself into a variable instead of hard coding it.
  3. Use ld or $(LD) or similar instead of $(CC) for the link step. May be combined with step 2 to work with clang, should someone use it to, say, enable link-time-optimisation or use a special link script.

Putting it on hold for now, I should get to it in one or two weeks. In the mean time, if you fancy doing some testing let me know what you find, this’ll help me.

LoupVaillant avatar Oct 20 '23 21:10 LoupVaillant

but I don't really know why

No soname for Darwin, but there's a similar feature "Install name". It was used by you as a workaround but it's Darwin-only, so no way this gonna work anywhere else.

aikawayataro avatar Nov 13 '23 14:11 aikawayataro