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

Compilation in setuptools_rust fails with 1.70.0-nightly toolchain #320

Closed
yasuo-ozu opened this issue Mar 29, 2023 · 3 comments · Fixed by #322
Closed

Compilation in setuptools_rust fails with 1.70.0-nightly toolchain #320

yasuo-ozu opened this issue Mar 29, 2023 · 3 comments · Fixed by #322

Comments

@yasuo-ozu
Copy link
Contributor

Assumptions

  • problematic toolchain
    -- rustc 1.70.0-nightly (db0cbc48d 2023-03-26)
    -- rustc 1.70.0-nightly (478cbb42b 2023-03-28)
  • toolchain not affected
    -- rustc 1.68.0-stable

Description

wheel package generation fails with latest toolchain, when crate-type = ["cdylib"] is not contained in Cargo.toml.

Cause

The following command in build process will not work:

cargo rustc --lib --message-format=json-render-diagnostics --manifest-path Cargo.toml --release -v --features 'python pyo3/extension-module' --no-default-features -- --crate-type cdylib

Instead, following works:

cargo rustc --lib --message-format=json-render-diagnostics --manifest-path Cargo.toml --release -v --features 'python pyo3/extension-module' --no-default-features --crate-type cdylib

Workaround

any of the following avoids the bug:

  • Write crate-type = ["cdylib"] in Cargo.toml
  • Write args=["--crate-type", "cdylib"] in initializer of RustExtension

Sample:

                RustExtension(
                    'namespace.package', 'Cargo.toml',
                    binding = Binding.PyO3,
                    args = ["--crate-type", "cdylib"],
                )

I will create PRs later.

@messense
Copy link
Member

The following command in build process will not work:

cargo rustc --lib --message-format=json-render-diagnostics --manifest-path Cargo.toml --release -v --features 'python pyo3/extension-module' --no-default-features -- --crate-type cdylib

What's the error message?

@yasuo-ozu
Copy link
Contributor Author

With following commands:

$ cd examples/html-py-ever
$ rustup default nightly
$ rustc --version
rustc 1.70.0-nightly (478cbb42b 2023-03-28)
$ vi Cargo.toml
# Here, remove line 'crate-type = ["dyllib"]'
$ cargo rustc --lib --message-format=json-render-diagnostics --manifest-path Cargo.toml --release -v --features pyo3/extension-module -- --crate-type cdylib

I get

   Compiling html-py-ever v0.1.0 (/home/yasuo/ghq/github.com/PyO3/setuptools-rust/examples/html-py-ever)
     Running `rustc --crate-name html_py_ever --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=159 --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --crate-type cdylib -C metadata=46a88f8ad81bd4e9 -C extra-filename=-46a88f8ad81bd4e9 --out-dir /home/yasuo/ghq/github.com/PyO3/setuptools-rust/examples/html-py-ever/target/release/deps -L dependency=/home/yasuo/ghq/github.com/PyO3/setuptools-rust/examples/html-py-ever/target/release/deps --extern kuchiki=/home/yasuo/ghq/github.com/PyO3/setuptools-rust/examples/html-py-ever/target/release/deps/libkuchiki-17d7bf24f9e68077.rmeta --extern pyo3=/home/yasuo/ghq/github.com/PyO3/setuptools-rust/examples/html-py-ever/target/release/deps/libpyo3-d3ecaf764808e42c.rmeta --extern tendril=/home/yasuo/ghq/github.com/PyO3/setuptools-rust/examples/html-py-ever/target/release/deps/libtendril-e113a85045e3a1e9.rmeta`
error: crate `pyo3` required to be available in rlib format, but was not found in this form

error: crate `tendril` required to be available in rlib format, but was not found in this form

error: crate `kuchiki` required to be available in rlib format, but was not found in this form

error: could not compile `html-py-ever` (lib) due to 3 previous errors

Caused by:
  process didn't exit successfully: `rustc --crate-name html_py_ever --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=159 --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --crate-type cdylib -C metadata=46a88f8ad81bd4e9 -C extra-filename=-46a88f8ad81bd4e9 --out-dir /home/yasuo/ghq/github.com/PyO3/setuptools-rust/examples/html-py-ever/target/release/deps -L dependency=/home/yasuo/ghq/github.com/PyO3/setuptools-rust/examples/html-py-ever/target/release/deps --extern kuchiki=/home/yasuo/ghq/github.com/PyO3/setuptools-rust/examples/html-py-ever/target/release/deps/libkuchiki-17d7bf24f9e68077.rmeta --extern pyo3=/home/yasuo/ghq/github.com/PyO3/setuptools-rust/examples/html-py-ever/target/release/deps/libpyo3-d3ecaf764808e42c.rmeta --extern tendril=/home/yasuo/ghq/github.com/PyO3/setuptools-rust/examples/html-py-ever/target/release/deps/libtendril-e113a85045e3a1e9.rmeta` (exit status: 1)

yasuo-ozu added a commit to yasuo-ozu/setuptools-rust that referenced this issue Mar 29, 2023
yasuo-ozu added a commit to yasuo-ozu/setuptools-rust that referenced this issue Mar 29, 2023
yasuo-ozu added a commit to yasuo-ozu/setuptools-rust that referenced this issue Mar 29, 2023
@yasuo-ozu
Copy link
Contributor Author

Actually I cannot figure out which change on rustc break the compatibility.
(it occurs between ff4b772 ... 8a73f50)

Recently --crate-type option is implemented in cargo, so I think it is safer to use --crate-type option on cargo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants