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

Fix release build #71

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

Fix release build #71

wants to merge 1 commit into from

Conversation

ole
Copy link

@ole ole commented May 23, 2022

Make some Swift functions public so that the linker can see them when linking CEcho.

If they're not public, release builds would fail with undefined symbols errors:

Undefined symbols for architecture arm64:
  "_lookupSection", referenced from:
      __loadImageFunc in CEcho.o
  "_registerProtocolConformances", referenced from:
      __loadImageFunc in CEcho.o
  "_registerProtocols", referenced from:
      __loadImageFunc in CEcho.o
  "_registerTypeMetadata", referenced from:
      __loadImageFunc in CEcho.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Fixes #54 and fixes #60 (cc @NSExceptional @stephencelis).

Make some Swift functions public so that the linker can see them when linking CEcho.

If they're not public, release builds would fail with undefined symbols errors:

Undefined symbols for architecture arm64:
  "_lookupSection", referenced from:
      __loadImageFunc in CEcho.o
  "_registerProtocolConformances", referenced from:
      __loadImageFunc in CEcho.o
  "_registerProtocols", referenced from:
      __loadImageFunc in CEcho.o
  "_registerTypeMetadata", referenced from:
      __loadImageFunc in CEcho.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
@NSExceptional
Copy link

Hell yeah, nice work!

@ole
Copy link
Author

ole commented May 23, 2022

I should add: I tested this on macOS 12.4, Xcode 13.4 (Swift 5.6.1), Apple Silicon. When these functions are internal, release builds fail with the abovementioned linker errors. Making the functions public fixes it.

I don't know enough about the linker to see why that is. Does the optimizer remove these functions in release builds because nobody is calling them from Swift? If so, does that mean there is a less invasive fix than making them public?

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.

Echo does not build for release "Undefined symbols" when trying to Profile in Xcode
2 participants