ITADN

Mac compatibility

#128Pull Requestntjohnson1 创建于 2025-08-07
N
ntjohnson1commented
Closes #127 On mac with xcode apple clang is available but `llvm-ar` is not. Whatever version of `ar` mac comes with adds newline bytes to pad out the `wasm32.o` but that isn't parsed correctly downstream which leads to the `llvm: section too large` error. The solution in this PR is to add a `.pad` section with 12 bytes of zeros to bring the `.o` to 408 bytes. Then if `llvm-ar` is not detected when clang is we use this padded version. An alternative is to just always use this padded version but I didn't check this anywhere else besides Mac so uncertain if different padding schemes would be unhappy with 408 bytes. ## Extra Details Padded version created via this command since copyobj seemed to not play nice with wasm. Empty.bin just 12 bytes of zeros to make the math work. ```console wasm-custom-section psm/src/arch/wasm32_pad.o add .pad < empty.bin ``` I assume you'll want to verify I didn't do anything weird on the object yourself but here were my local comparisons ```console hexdump -C wasm32.o > extracted.hex && hexdump -C wasm32_pad.o > original.hex && diff original.hex extracted.hex 25,27c25,26 < 00000180 3c 02 06 46 04 00 11 04 2e 70 61 64 00 00 00 00 |<..F.....pad....| < 00000190 00 00 00 00 00 00 00 00 |........| < 00000198 --- > 00000180 3c 02 06 46 04 |<..F.| > 00000185 ``` ```console llvm-readobj --sections wasm32_pad.o File: wasm32_pad.o Format: WASM Arch: wasm32 AddressSize: 32bit Sections [ Section { Type: TYPE (0x1) Size: 27 Offset: 14 } Section { Type: IMPORT (0x2) Size: 81 Offset: 47 } Section { Type: FUNCTION (0x3) Size: 5 Offset: 134 } Section { Type: CODE (0xA) Size: 78 Offset: 145 } Section { Type: CUSTOM (0x0) Size: 112 Offset: 229 Name: linking } Section { Type: CUSTOM (0x0) Size: 23 Offset: 355 Name: reloc.CODE } Section { Type: CUSTOM (0x0) Size: 12 Offset: 391 Name: .pad } ] ```
合并状态:未合并 5 条评论