Skip to content

Commit

Permalink
Bug 1794001 - Part 6: Patch rure to remove cdylib and staticlib targe…
Browse files Browse the repository at this point in the history
…ts, r=#xpcom-reviewers CLOSED TREE

Cargo will attempt to build all targets for dependencies, and there
appears to be no option to turn that functionality off (see
rust-lang/cargo#11232). If we try to build the
`rure` crate as a cdylib during a PGO build, it causes linker issues,
which make the build fail. As this artifact isn't necessary for our
build, we can patch the crate to remove the cdylib and staticlib
crate-type definitions, making the build pass as only the artifact we
need is built.

Differential Revision: https://phabricator.services.mozilla.com/D159332
  • Loading branch information
mystor committed Oct 13, 2022
1 parent 28b6c5c commit 1e93d06
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Cargo.toml
Expand Up @@ -138,6 +138,13 @@ web-sys = { path = "build/rust/dummy-web/web-sys" }
# Overrides to allow easier use of common internal crates.
moz_asserts = { path = "mozglue/static/rust/moz_asserts" }

# Patch `rure` to disable building the cdylib and staticlib targets
# Cargo has no way to disable building targets your dependencies provide which
# you don't depend on, and linking the cdylib breaks during instrumentation
# builds.
# Workaround for https://github.com/rust-lang/cargo/issues/11232
rure = { path = "third_party/rust/rure" }

# Other overrides
async-task = { git = "https://github.com/smol-rs/async-task", rev="f6488e35beccb26eb6e85847b02aa78a42cd3d0e" }
chardetng = { git = "https://github.com/hsivonen/chardetng", rev="3484d3e3ebdc8931493aa5df4d7ee9360a90e76b" }
Expand Down
4 changes: 4 additions & 0 deletions supply-chain/config.toml
Expand Up @@ -126,6 +126,10 @@ notes = "This is a first-party crate which is entirely unrelated to the crates.i
audit-as-crates-io = true
notes = "This is a first-party crate which is also published to crates.io, but we should publish audits for it for the benefit of the ecosystem."

[policy.rure]
audit-as-crates-io = true
notes = "Identical to upstream, but with cdylib and staticlib targets disabled to avoid unnecessary build artifacts and linker errors."

[policy.selectors]
audit-as-crates-io = true
notes = "This is a first-party crate which is also published to crates.io, but we should publish audits for it for the benefit of the ecosystem."
Expand Down
5 changes: 0 additions & 5 deletions third_party/rust/rure/Cargo.toml
Expand Up @@ -25,11 +25,6 @@ repository = "https://github.com/rust-lang/regex"

[lib]
name = "rure"
crate-type = [
"staticlib",
"cdylib",
"rlib",
]

[dependencies.libc]
version = "0.2"
Expand Down

0 comments on commit 1e93d06

Please sign in to comment.