Skip to content

Commit

Permalink
Add cross-compilation example to nightly
Browse files Browse the repository at this point in the history
This commit adds cross-compilation to armv7 and aarch64 to the nightly
build. This involves modifications to the way `pkg-config` is used
as described in #204.

Signed-off-by: Ionut Mihalcea <[email protected]>
  • Loading branch information
ionut-arm committed Mar 11, 2021
1 parent d758496 commit e4813fc
Show file tree
Hide file tree
Showing 11 changed files with 35,483 additions and 51 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ jobs:
run: cargo audit

coverage:
name: Calculate code coverage
name: Calculate code coverage and cross compile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the container
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu
- name: Run the container
- name: Run the code coverage script
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi --security-opt seccomp=unconfined ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/coverage.sh
- name: Collect coverage results
run: bash <(curl -s https://codecov.io/bash)
- name: Run the cross-compilation script
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/cross-compile.sh
7 changes: 7 additions & 0 deletions tss-esapi-sys/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Cargo seems to expect the -gcc variant instead of -ld

[target.armv7-unknown-linux-gnueabi]
linker = "arm-linux-gnueabihf-gcc"

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
20 changes: 19 additions & 1 deletion tss-esapi-sys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,22 @@ NOTE: Only a limited set of bindings are committed and their target triplet
is included in the name of the file - if the triplet you require is not
available, feel free to raise a Pull Request to add it or to use build-time
generation of bindings. All the committed bindings **MUST** be generated from
the library version found under the `vendor` submodule.
the library version found under the `vendor` submodule.

## Cross compiling

Cross-compilation can be done as long as you have on your build system the TSS
libraries compiled for your target system of choice. We rely on `pkg-config` to
identify the libraries which we link against. Installing `tpm2-tss` yields `.pc`
files which can be used for this purpose, but depending on the exact build
environment setup, you might need to be careful when configuring the `tpm2-tss`
build.

We include cross-compilation builds as a nightly check in Github Actions - you
can find them [here](../tss-esapi/tests/cross-compile.sh) as an example of the
steps needed. You can find more information on using `pkg-config` when cross-compiling
[here](https://github.com/parallaxsecond/rust-tss-esapi/issues/204). Our wrapper
script around `pkg-config` can be seen [here](../tss-esapi/tests/pkg-config).

Be advised that in most cases the linker used might need to be set manually in
`.cargo/config` (some entries already exist there as an example).
Loading

0 comments on commit e4813fc

Please sign in to comment.