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

rust bindings: Do not unnecessarily re-run build.rs #17018

Merged
merged 2 commits into from
Sep 6, 2023

Conversation

j-baker
Copy link
Contributor

@j-baker j-baker commented Aug 5, 2023

Description

Remove unnecessary cargo:rerun-if-changed declaration.

Motivation and Context

'cargo:rerun-if-changed' declarations tell Cargo when to re-run the build script. The intention is that if the build script depends on other files, then Cargo knows to re-run if those files change. It stores the output and checks it before each build. The intention is that one emits the declarations for inputs of the build.

This rerun-if-changed declaration is a declaration on the output of the build, and stores the absolute path of the output. This is not a useful declaration because the output path is unique to the build script - there is no way for anything else to change it.

However, this does generate unnecessary rebuilds in some cases, for example if the dependent repository is moved in the filesystem. This causes me some issues when using https://crane.dev, as due to some implementation details, if a crate being moved triggers a rebuild, by default the build is broken.

To summarise:

  • declaration is redundant
  • causes issues in niche cases.

'cargo:rerun-if-changed' declarations tell Cargo when to re-run the build script. The intention is that if the build script depends on other files, then Cargo knows to re-run if those files change. It stores the output and checks it before each build.

This rerun-if-changed declaration is a declaration on the _output_ of the build, and stores the absolute path of the output. This is not a useful declaration because the output path is unique to the build script - there is no way for anything else to change it.

However, this does generate unnecessary rebuilds in some cases, for example if the dependent repository is moved in the filesystem.
@justinchuby
Copy link
Contributor

/azp run Windows GPU TensorRT CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline, onnxruntime-python-checks-ci-pipeline, orttraining-linux-ci-pipeline, orttraining-ortmodule-distributed, orttraining-linux-gpu-ci-pipeline, Linux QNN CI Pipeline, Windows ARM64 QNN CI Pipeline

@justinchuby
Copy link
Contributor

/azp run Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline, Linux Nuphar CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, Windows CPU CI Pipeline, Windows GPU CI Pipeline, Linux OpenVINO CI Pipeline

@azure-pipelines
Copy link

Azure Pipelines successfully started running 7 pipeline(s).

@azure-pipelines
Copy link

Azure Pipelines successfully started running 9 pipeline(s).

@justinchuby justinchuby merged commit 16eba53 into microsoft:main Sep 6, 2023
64 checks passed
kleiti pushed a commit to kleiti/onnxruntime that referenced this pull request Mar 22, 2024
### Description

Remove unnecessary cargo:rerun-if-changed declaration.

### Motivation and Context

'cargo:rerun-if-changed' declarations tell Cargo when to re-run the
build script. The intention is that if the build script depends on other
files, then Cargo knows to re-run if those files change. It stores the
output and checks it before each build. The intention is that one emits
the declarations for _inputs_ of the build.

This rerun-if-changed declaration is a declaration on the _output_ of
the build, and stores the absolute path of the output. This is not a
useful declaration because the output path is unique to the build script
- there is no way for anything else to change it.

However, this does generate unnecessary rebuilds in some cases, for
example if the dependent repository is moved in the filesystem. This
causes me some issues when using https://crane.dev, as due to some
implementation details, if a crate being moved triggers a rebuild, by
default the build is broken.

To summarise:
- declaration is redundant
- causes issues in niche cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants