Built using Xcode Version 13.1 (13A1030d) on macOS Monterey 12.0.1.
The dylib was built in a release configuration with architectures set to $(ARCHS_STANDARD). This builds a FAT binary with x86_64 and arm64, as expected.
However, when I dlopen it with RTLD_NOW | RTLD_GLOBAL, it fails and dlerror reports "slice is not page aligned" twice, and a message saying that it is looking for x86_64h but only finds x86_64,arm64 is reported.
Not sure what the root cause is, but certainly the slice not being page aligned is causing issues. The question may therefore be: how can I ensure the dylib generated as a FAT binary has its slices aligned in Xcode 13?
how can I ensure the dylib generated as a FAT binary has its slices aligned in Xcode 13?
In general this should happen automatically, that is, the tools that generate universal binaries should make sure that each slice is aligned according to the constraints of that architecture.
You’re building the library with Xcode, right? In that case I wouldn’t expect you to have to do anything special.
Honestly, I think that something else weird is happening and this message is an artefact of the code going down some weird error path.
Are you testing this on Intel?
Is this misbehaviour tied to your main app? That is, if you create a small test app (from one of the built-in templates) that simply tries to dlopen your library, does that have the same problem?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"