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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SethArchambault
Copy link
Contributor

@SethArchambault SethArchambault commented Oct 20, 2023

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)

why.

https://stackoverflow.com/questions/4580789/ld-unknown-option-soname-on-os-x

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

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.

@aikawayataro
Copy link

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.

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

Successfully merging this pull request may close these issues.

None yet

3 participants