Zig Version
0.16.0
Steps to Reproduce and Observed Behavior
I ran into this while building an iOS XCFramework from a Zig static library. With Xcode 26.4, the Apple linker rejects the .a produced by Zig because the Mach-O member inside the archive is not 8-byte aligned.
Minimal repro:
tiny.zig:
exportfnadd(a:i32,b:i32)i32{returna+b;}
main.c:
extern int add(int, int);
int main(void) {
return add(1, 2);
}
Build the static library and link it with Apple's linker:
zig build-lib tiny.zig -target aarch64-ios-simulator -O ReleaseFast -femit-bin=libtiny.a
xcrun -sdk iphonesimulator clang -target arm64-apple-ios15.1-simulator main.c libtiny.a -o test-arm64-sim
On my machine this fails with:
ld: 64-bit mach-o member 'libtiny_zcu.o' not 8-byte aligned in 'libtiny.a'
clang: error: linker command failed with exit code 1
If I extract the same object file and repack it with Apple's libtool, the link succeeds:
mkdir repack
cd repack
xcrun ar -x ../libtiny.a
chmod u+rw *.o
xcrun libtool -static -o ../libtiny-repacked.a *.o
xcrun ranlib ../libtiny-repacked.a
cd ..
xcrun -sdk iphonesimulator clang -target arm64-apple-ios15.1-simulator main.c libtiny-repacked.a -o test-arm64-sim
So the object file itself seems usable; the problem appears to be the archive layout produced by Zig.
This may be related to #30572, but the failure mode here is specific to Apple's linker and 64-bit Mach-O archive members needing 8-byte alignment.
Environment:
Apple Silicon Mac
macOS 26.3.1
Xcode 26.4
target: aarch64-ios-simulator / arm64-apple-ios15.1-simulator
I can reproduce this with both Zig 0.16.0 and Zig 0.15.2. With the official 0.15.2 tarball there is also a separate Xcode 26.4 SDK/TBD issue, so for 0.15.2 I used Homebrew zig@0.15, which includes the Dylib.zig backport.
Expected Behavior
The static library produced by Zig should be accepted by Apple's linker for iOS simulator targets.
### Zig Version
0.16.0
### Steps to Reproduce and Observed Behavior
I ran into this while building an iOS XCFramework from a Zig static library. With Xcode 26.4, the Apple linker rejects the `.a` produced by Zig because the Mach-O member inside the archive is not 8-byte aligned.
Minimal repro:
`tiny.zig`:
```zig
export fn add(a: i32, b: i32) i32 {
return a + b;
}
```
`main.c`:
```c
extern int add(int, int);
int main(void) {
return add(1, 2);
}
```
Build the static library and link it with Apple's linker:
```
zig build-lib tiny.zig -target aarch64-ios-simulator -O ReleaseFast -femit-bin=libtiny.a
xcrun -sdk iphonesimulator clang -target arm64-apple-ios15.1-simulator main.c libtiny.a -o test-arm64-sim
```
On my machine this fails with:
```
ld: 64-bit mach-o member 'libtiny_zcu.o' not 8-byte aligned in 'libtiny.a'
clang: error: linker command failed with exit code 1
```
If I extract the same object file and repack it with Apple's libtool, the link succeeds:
```
mkdir repack
cd repack
xcrun ar -x ../libtiny.a
chmod u+rw *.o
xcrun libtool -static -o ../libtiny-repacked.a *.o
xcrun ranlib ../libtiny-repacked.a
cd ..
xcrun -sdk iphonesimulator clang -target arm64-apple-ios15.1-simulator main.c libtiny-repacked.a -o test-arm64-sim
```
So the object file itself seems usable; the problem appears to be the archive layout produced by Zig.
This may be related to #30572, but the failure mode here is specific to Apple's linker and 64-bit Mach-O archive members needing 8-byte alignment.
Environment:
```
Apple Silicon Mac
macOS 26.3.1
Xcode 26.4
target: aarch64-ios-simulator / arm64-apple-ios15.1-simulator
```
I can reproduce this with both Zig 0.16.0 and Zig 0.15.2. With the official 0.15.2 tarball there is also a separate Xcode 26.4 SDK/TBD issue, so for 0.15.2 I used Homebrew `zig@0.15`, which includes the Dylib.zig backport.
### Expected Behavior
The static library produced by Zig should be accepted by Apple's linker for iOS simulator targets.