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

error: output of --print=file-names missing when learning about target-specific information from rustc when building with build.rs #287

Closed
frol opened this issue Jan 9, 2025 · 4 comments · Fixed by #289
Assignees
Labels
bug Something isn't working

Comments

@frol
Copy link
Contributor

frol commented Jan 9, 2025

There is something wrong with cargo-near-build, it seems. There is a project where it used to work (cargo-near-build there is 0.3.0, but neither it works with that old version nor it works after I upgraded everything cargo-near, cargo-near-build, and the build image):

image
git clone https://github.com/near-devhub/neardevhub-treasury-dashboard
cd neardevhub-treasury-dashboard
cargo near build reproducible-wasm

I tested it on MacOS and Ubuntu, with old cargo-near 0.10.1 + cargo-near-build 0.3.0 and new cargo-near 0.13.2 + cargo-near-build 0.4.2, but it just fails and I cannot figure out what is wrong. Compiling the child contract on its own works just fine.

Here is the branch with the updated cargo-near versions: refactor/upgraded-reproducible-config

@frol frol added the bug Something isn't working label Jan 9, 2025
petersalomonsen added a commit to NEAR-DevHub/neardevhub-treasury-dashboard that referenced this issue Jan 12, 2025
@petersalomonsen
Copy link

To work around this I've added a cargo build step to build the nested contract, as you can see here: https://github.com/NEAR-DevHub/neardevhub-treasury-dashboard/pull/207/files#diff-4af2e002392c142167c9436d9f8d3a3fb8a476e2e70e9452c8234de9b639647dR18. So the problem seems to be whencargo near build is building another project in build.rs.

frol pushed a commit to NEAR-DevHub/neardevhub-treasury-dashboard that referenced this issue Jan 13, 2025
- Update workflow to use the correct environment variables for
deployment credentials
- Adjustments for using the latest cargo-near cli
- Added a redundant `cargo build` command because of
near/cargo-near#287

See successful build and deployment here:
https://github.com/NEAR-DevHub/neardevhub-treasury-dashboard/actions/workflows/deploy-treasury-factory-contract.yml
dj8yfo pushed a commit to dj8yfo/neardevhub-treasury-dashboard that referenced this issue Jan 13, 2025
@dj8yfo
Copy link
Collaborator

dj8yfo commented Jan 22, 2025

the cause of the issue is that RUSTFLAGS="-A warnings" during abi build for parent contract gets set as CARGO_ENCODED_RUSTFLAGS in build script for child contract
(which is normal behaviour for build scripts)
,
which takes precedence over RUSTFLAGS set for child contract by cargo-near-build
according to https://doc.rust-lang.org/cargo/reference/config.html#buildrustflags

@dj8yfo
Copy link
Collaborator

dj8yfo commented Jan 22, 2025

the failure itself is caused by what looks like a cargo bug #294

@dj8yfo
Copy link
Collaborator

dj8yfo commented Jan 22, 2025

issue was somewhat hard to figure out because CARGO_ENCODED_RUSTFLAGS is not set explicitly by and code within cargo-near,
rather it's set implicitly by cargo's machinery for build scripts.

The fix is to always unset whatever value of CARGO_ENCODED_RUSTFLAGS was set in environment during
both stages of cargo-near-build's build.

suggested alternative NEAR-DevHub/neardevhub-treasury-dashboard#212 doesn't run child's contract build
during a parent contract's abi build, as the correct child contract
isn't required to compute the parent's abi and is replaced with an empty stub file instead during build.
That's why this issue isn't encountered therein.


these commentaries were added due to suggestion in #289 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants