Task: Build mock server binary with slices for `arch64` and `x86_64`
surpher opened this issue · 1 comments
surpher commented
❕ Problem Statement
Xcode 12.2 requires that binaries used in macOS
framework include slices for arm64
(Apple Silicon). This means the build always fails when building PactSwift
framework for macOS with Carthage dependency manager and SPM (uses a script in /Scripts/BuildPhases
).
NOTE: Unfortunately the cargo build
command fails when building a Rust dependency for aarch64-apple-darwin
triple on x86_64
host:
error: failed to run custom build command for `ring v0.16.15`
💬 Task Description
- Build the
libpact_mock_server.a
forx86_64
andarm64
architectures and create a fat library in a phase script. - Remove the
arm64
as excluded architectures inmacOS
target (reverts #53). - Consider moving PactSwift to
XCFramework
format
👩🔧 Technical Design Notes
- Script that builds the
libpact_mock_server.a
is in a script file and referenced in the build phase script. - Rust guide and pointers:
# install nightly
% rustup install nightly
# update rustup toolchains to 1.23 or newer
% RUSTUP_UPDATE_ROOT=https://dev-static.rust-lang.org/rustup sh <(curl --proto '=https' --tlsv1.2 -sSf https://dev-static.rust-lang.org/rustup/rustup-init.sh) --default-toolchain beta
# set nightly toolchain as default as it contains `aarch64-apple-darwin` toolchain for the x86_64 host
% rustup default nightly-x86_64-apple-darwin
# add the required Rust triples for currently supported architectures
% rustup target add aarch64-apple-ios aarch64-apple-darwin x86_64-apple-ios x86_64-apple-darwin
# build libpact_mock_server.a for arm64 in ./Submodules/pact-reference/rust/pact_mock_server_ffi
% cargo build --target=aarch64-apple-darwin --release
# use lipo to generate a fat binary
% lipo -create <input_file_1> <input_file_2> -output <output_file>
🤝 Relationships
🔗 Resources
surpher commented
Tried to build again for aarch64-apple-darwin
triple today but was greeted with build errors.
Dependencies seem to not be updated yet properly:
Compiling security-framework-sys v2.0.0
Compiling core-foundation v0.9.1
Compiling base64 v0.10.1
Compiling base64 v0.9.3
Compiling idna v0.1.5
error[E0308]: mismatched types
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/bhcomp.rs:62:24
|
62 | let bytes = bits / Limb::BITS;
| ^^^^^^^^^^ expected `usize`, found `u32`
error[E0277]: cannot divide `usize` by `u32`
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/bhcomp.rs:62:22
|
62 | let bytes = bits / Limb::BITS;
| ^ no implementation for `usize / u32`
|
= help: the trait `Div<u32>` is not implemented for `usize`
error[E0308]: mismatched types
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/bigcomp.rs:157:55
|
157 | let nlz = den.leading_zeros().wrapping_sub(wlz) & (u32::BITS - 1);
| ^^^^^^^^^^^^^^^ expected `usize`, found `u32`
error[E0277]: no implementation for `usize & u32`
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/bigcomp.rs:157:53
|
157 | let nlz = den.leading_zeros().wrapping_sub(wlz) & (u32::BITS - 1);
| ^ no implementation for `usize & u32`
|
= help: the trait `BitAnd<u32>` is not implemented for `usize`
error[E0308]: mismatched types
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/bigcomp.rs:175:40
|
175 | let (q, r) = shift.ceil_divmod(Limb::BITS);
| ^^^^^^^^^^ expected `usize`, found `u32`
|
help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit
|
175 | let (q, r) = shift.ceil_divmod(Limb::BITS.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1043:42
|
1043 | let mut count = index.saturating_mul(Limb::BITS);
| ^^^^^^^^^^ expected `usize`, found `u32`
|
help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit
|
1043 | let mut count = index.saturating_mul(Limb::BITS.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1058:28
|
1058 | Limb::BITS.checked_mul(x.len())
| ^^^^^^^ expected `u32`, found `usize`
|
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
|
1058 | Limb::BITS.checked_mul(x.len().try_into().unwrap())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1059:22
|
1059 | .map(|v| v - nlz)
| ^^^ expected `u32`, found `usize`
error[E0277]: cannot subtract `usize` from `u32`
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1059:20
|
1059 | .map(|v| v - nlz)
| ^ no implementation for `u32 - usize`
|
= help: the trait `Sub<usize>` is not implemented for `u32`
error[E0308]: mismatched types
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1060:20
|
1060 | .unwrap_or(usize::max_value())
| ^^^^^^^^^^^^^^^^^^ expected `u32`, found `usize`
|
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
|
1060 | .unwrap_or(usize::max_value().try_into().unwrap())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1058:5
|
1054 | pub fn bit_length(x: &[Limb]) -> usize {
| ----- expected `usize` because of return type
...
1058 | / Limb::BITS.checked_mul(x.len())
1059 | | .map(|v| v - nlz)
1060 | | .unwrap_or(usize::max_value())
| |______________________________________^ expected `usize`, found `u32`
|
help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit
|
1058 | Limb::BITS.checked_mul(x.len())
1059 | .map(|v| v - nlz)
1060 | .unwrap_or(usize::max_value()).try_into().unwrap()
|
error[E0308]: mismatched types
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1085:23
|
1085 | debug_assert!(n < bits && n != 0);
| ^^^^ expected `usize`, found `u32`
|
help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit
|
1085 | debug_assert!(n < bits.try_into().unwrap() && n != 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1092:25
|
1092 | let lshift = bits - n;
| ^ expected `u32`, found `usize`
error[E0277]: cannot subtract `usize` from `u32`
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1092:23
|
1092 | let lshift = bits - n;
| ^ no implementation for `u32 - usize`
|
= help: the trait `Sub<usize>` is not implemented for `u32`
error[E0308]: mismatched types
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1134:19
|
1134 | let rem = n % bits;
| ^^^^ expected `usize`, found `u32`
error[E0277]: cannot mod `usize` by `u32`
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1134:17
|
1134 | let rem = n % bits;
| ^ no implementation for `usize % u32`
|
= help: the trait `Rem<u32>` is not implemented for `usize`
error[E0308]: mismatched types
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1135:19
|
1135 | let div = n / bits;
| ^^^^ expected `usize`, found `u32`
error[E0277]: cannot divide `usize` by `u32`
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1135:17
|
1135 | let div = n / bits;
| ^ no implementation for `usize / u32`
|
= help: the trait `Div<u32>` is not implemented for `usize`
error[E0308]: mismatched types
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1191:23
|
1191 | debug_assert!(n < bits);
| ^^^^ expected `usize`, found `u32`
|
help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit
|
1191 | debug_assert!(n < bits.try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1201:25
|
1201 | let rshift = bits - n;
| ^ expected `u32`, found `usize`
error[E0277]: cannot subtract `usize` from `u32`
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1201:23
|
1201 | let rshift = bits - n;
| ^ no implementation for `u32 - usize`
|
= help: the trait `Sub<usize>` is not implemented for `u32`
error[E0308]: mismatched types
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1253:19
|
1253 | let rem = n % bits;
| ^^^^ expected `usize`, found `u32`
error[E0277]: cannot mod `usize` by `u32`
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1253:17
|
1253 | let rem = n % bits;
| ^ no implementation for `usize % u32`
|
= help: the trait `Rem<u32>` is not implemented for `usize`
error[E0308]: mismatched types
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1254:19
|
1254 | let div = n / bits;
| ^^^^ expected `usize`, found `u32`
error[E0277]: cannot divide `usize` by `u32`
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:1254:17
|
1254 | let div = n / bits;
| ^ no implementation for `usize / u32`
|
= help: the trait `Div<u32>` is not implemented for `usize`
error[E0308]: mismatched types
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:2065:27
|
2065 | let rs = Limb::BITS - s;
| ^ expected `u32`, found `usize`
error[E0277]: cannot subtract `usize` from `u32`
--> /Users/marko/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.4/src/atof/algorithm/math.rs:2065:25
|
2065 | let rs = Limb::BITS - s;
| ^ no implementation for `u32 - usize`
|
= help: the trait `Sub<usize>` is not implemented for `u32`
Compiling idna v0.2.0
error: aborting due to 27 previous errors
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `lexical-core`
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
! ~/D/P/pact-reference/rust/pact_mock_server_ffi >
Also keeping an eye on rust-lang/rust#73908.