Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document cross compilation target == host bugfix. #6803

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ use ``--no-binary``.

$ pip install cryptography --no-binary cryptography

Cross Compiling
~~~~~~~~~~~~~~~

If you are cross compiling for a target system that has the same target triple
as the build host you should add these variables in your environment to prevent
cargo from linking host build-scripts against the target libraries.

.. code-block:: console

__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS="nightly"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DO_NOT_USE_THIS is kind of a red-flag that this probably isn't the right way to do this 😂

I'm not sure I understand the use case here, what does it mean to cross-compile for a target with the same triple as the host?

Copy link
Contributor Author

@jameshilliard jameshilliard Jan 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DO_NOT_USE_THIS is kind of a red-flag that this probably isn't the right way to do this 😂

It's the correct way to do this on a stable rust toolchain, because the fix is behind a nightly flag and that's the only way to enable a nightly flag on the stable toolchain. By policy nightly flags are not supported/documented as available on stable toolchains but there's not actually a technical reason that they won't work(they work effectively the same as they do on a nightly toolchain if you set __CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS="nightly"), this particular nightly only feature is needed to fix a critical cross compilation toolchain bug. I've been trying to stabilize this for a while but that's stalled for unclear reasons.

I'm not sure I understand the use case here, what does it mean to cross-compile for a target with the same triple as the host?

For example if the host triple(ie x86_64-unknown-linux-gnu) is identical to the target triple(ie x86_64-unknown-linux-gnu) then you need to set this in the env when cross compiling otherwise the build will likely fail with cryptic build script linker errors due to cargo using the wrong linker for build scripts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you want to cross compile at all if the host triple is the target triple? Wouldn't you just compile it? I'm assuming there's a nuance I'm missing here 😄

Copy link
Contributor Author

@jameshilliard jameshilliard Jan 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you want to cross compile at all if the host triple is the target triple?

For example I'm trying to cross compile a rootfs image for an embedded x86_64 board using buildroot.

Wouldn't you just compile it?

We can't compile on the target because the target does not have a compiler.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are currently using this fix with our infrastructure to build python-cryptography.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Apologies for not following up here more promptly.)

I guess the thing I don't understand is why this is considered cross-compilation at all? If the host and target are both "the same", what's being solved here?

CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true"
CARGO_TARGET_APPLIES_TO_HOST="false"

Using your own OpenSSL on Linux
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down