Echo icon indicating copy to clipboard operation
Echo copied to clipboard

Fix release build

Open ole opened this issue 3 years ago • 2 comments

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).

ole avatar May 23 '22 20:05 ole

Hell yeah, nice work!

NSExceptional avatar May 23 '22 20:05 NSExceptional

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?

ole avatar May 23 '22 20:05 ole