Building fat file for libj2objc_main.a
- Dominant language
- Java
- Stars
- 6k
- Forks
- 999
- Avg merge
- 19h 20m
- Merged PRs (30d)
- 14
Description
## Problem
The `dist/lib/macosx/libj2objc_main.a` file that is produced by the jre_emul Makefile only supports the architecture of the machine used to build J2Objc. This causes a linking error when invoking [j2objcc.sh](https://github.com/google/j2objc/blob/master/scripts/j2objcc.sh) on a machine with a different architecture.
```
ld: warning: ignoring file /Users/example/j2objc/dist/lib/macosx/libj2objc_main.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
```
I found that I could successfully run j2objcc after I manually compiled `jre_emul/Classes/J2ObjCMain.m` for x86 and arm64, combined the two libs into a fat file, and then moved the fat file to `dist/lib/macosx/libj2objc_main.a`.
Given this, does it make sense to update the jre_emul Makefile to produce a fat file for `libj2objc_main.a`?
## Steps to Reproduce
Build
```
export J2OBJC_ARCHS="macosx macosx64"
make dist
```
Inspect Libraries
```
$ find dist/lib/macosx -type f -exec lipo -info {} \;
Architectures in the fat file: dist/lib/macosx/libjre_core.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjunit.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjre_net.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjre_time.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjre_icu.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjre_file.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjre_beans.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjre_concurrent.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjre_sql.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libmockito.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjsr305.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libxalan.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjre_security.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjre_zip.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjre_xml.a are: x86_64 arm64
Non-fat file: dist/lib/macosx/libj2objc_main.a is architecture: arm64
Architectures in the fat file: dist/lib/macosx/libjre_util.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjre_ssl.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjavax_inject.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libguava.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libguavaandroid.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjre_io.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjre_channels.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libtruth.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjre_emul.a are: x86_64 arm64
Architectures in the fat file: dist/lib/macosx/libjson.a are: x86_64 arm64
```
Contributor guide
Assessment
This issue has not been assessed yet.