Skip to content

Conversation

weihanglo
Copy link
Member

@weihanglo weihanglo commented Aug 23, 2025

Read a real target spec JSON so we no longer need to hardcode
a target spec JSON here.
Cargo itself should not care about the spec schema.

Let's stop bothering compiler contributors.

@rustbot
Copy link
Collaborator

rustbot commented Aug 23, 2025

r? @ehuss

rustbot has assigned @ehuss.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 23, 2025
@bjorn3
Copy link
Member

bjorn3 commented Aug 23, 2025

Instead of having a specific target json file would an option be to ask rustc for the target json file of an existing target and just remove the is-builtim flag before passing it back to cargo? That way it will remain correct even if the target json spec format changes in any way other than renaming the is-builtin field.

@weihanglo
Copy link
Member Author

@bjorn3 good idea, though where is the is-builtin flag you were talking about?

$ rustc +nightly --print target-spec-json -Zunstable-options --target wasm32-unknown-unknown
{
  "arch": "wasm32",
  "binary-format": "wasm",
  "crt-objects-fallback": "true",
  "data-layout": "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-S128-ni:1:10:20",
  "dll-prefix": "",
  "dll-suffix": ".wasm",
  "dynamic-linking": true,
  "eh-frame-header": false,
  "emit-debug-gdb-scripts": false,
  "exe-suffix": ".wasm",
  "generate-arange-section": false,
  "has-thread-local": true,
  "is-like-wasm": true,
  "limit-rdylib-exports": false,
  "linker": "rust-lld",
  "linker-flavor": "wasm-lld",
  "linker-is-gnu": false,
  "lld-flavor": "wasm",
  "llvm-target": "wasm32-unknown-unknown",
  "max-atomic-width": 64,
  "metadata": {
    "description": "WebAssembly",
    "host_tools": false,
    "std": true,
    "tier": 2
  },
  "only-cdylib": true,
  "os": "unknown",
  "panic-strategy": "abort",
  "pre-link-args": {
    "wasm-lld": [
      "-z",
      "stack-size=1048576",
      "--stack-first",
      "--allow-undefined",
      "--no-demangle",
      "--no-entry"
    ],
    "wasm-lld-cc": [
      "-Wl,-z",
      "-Wl,stack-size=1048576",
      "-Wl,--stack-first",
      "-Wl,--allow-undefined",
      "-Wl,--no-demangle",
      "--target=wasm32-unknown-unknown",
      "-Wl,--no-entry"
    ]
  },
  "relocation-model": "static",
  "singlethread": true,
  "target-family": [
    "wasm"
  ],
  "target-pointer-width": "32",
  "tls-model": "local-exec"
}

@weihanglo weihanglo force-pushed the spec-json-schema-change branch from e42c164 to 5c706e8 Compare August 24, 2025 01:52
@weihanglo weihanglo changed the title test: make it nightly only as schema may change in the future test: avoid hardcoded target spec json Aug 24, 2025
@weihanglo weihanglo marked this pull request as draft August 24, 2025 01:57
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 24, 2025
@weihanglo
Copy link
Member Author

I should go ahead and remove _all" hardcoded target spec jsons.

@weihanglo weihanglo force-pushed the spec-json-schema-change branch from 5c706e8 to 6b907f0 Compare August 24, 2025 02:25
@rustbot rustbot added the A-testing-cargo-itself Area: cargo's tests label Aug 24, 2025
Read a real target spec JSON so we no longer need to hardcode
a target spec JSON here.
Cargo itself should not care about the spec schema.

Let's stop bothering compiler contributors.
@weihanglo weihanglo force-pushed the spec-json-schema-change branch from 6b907f0 to 56f44bb Compare August 24, 2025 02:26
@weihanglo weihanglo marked this pull request as ready for review August 24, 2025 02:26
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 24, 2025
@bjorn3
Copy link
Member

bjorn3 commented Aug 24, 2025

I guess rustc itself nowadays already filters out the is-builtin field before printing.

Copy link
Member

@WaffleLapkin WaffleLapkin left a comment

Choose a reason for hiding this comment

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

This matches the changes that I did locally (i.e. it fixes all the places that I fixed).

@epage epage added this pull request to the merge queue Aug 25, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 25, 2025
@weihanglo weihanglo added this pull request to the merge queue Aug 26, 2025
@weihanglo
Copy link
Member Author

Run rustup update --no-self-update stable
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
error: failed to download file error=Reqwest(reqwest::Error { kind: Request, url: "https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256", source: hyper_util::client::legacy::Error(Connect, Custom { kind: Other, error: Os { code: 104, kind: ConnectionReset, message: "Connection reset by peer" } }) })
error: could not download file from 'https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256' to '/home/runner/.rustup/tmp/y2jjoktwl9rzp757_file': error downloading file: error sending request for url (https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256): client error (Connect): Connection reset by peer (os error 104)

Retried an succeeded. Merging.

Merged via the queue into rust-lang:master with commit a6c58d4 Aug 26, 2025
25 checks passed
@weihanglo weihanglo deleted the spec-json-schema-change branch August 26, 2025 23:39
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 26, 2025
bors added a commit to rust-lang/rust that referenced this pull request Aug 27, 2025
Update cargo submodule

3 commits in 623d536836b4cde09ce38609232a024d5b25da81..a6c58d43051d01d83f55a3e61ef5f5b2b0dd6bd9
2025-08-22 19:05:52 +0000 to 2025-08-26 23:05:12 +0000
- test: avoid hardcoded target spec json (rust-lang/cargo#15880)
- test(add): Cover some frontmatter corner cases (rust-lang/cargo#15886)
- Add more context to publish-failed error message (rust-lang/cargo#15879)

r? ghost
bors added a commit to rust-lang/rust that referenced this pull request Aug 27, 2025
Update cargo submodule

3 commits in 623d536836b4cde09ce38609232a024d5b25da81..a6c58d43051d01d83f55a3e61ef5f5b2b0dd6bd9
2025-08-22 19:05:52 +0000 to 2025-08-26 23:05:12 +0000
- test: avoid hardcoded target spec json (rust-lang/cargo#15880)
- test(add): Cover some frontmatter corner cases (rust-lang/cargo#15886)
- Add more context to publish-failed error message (rust-lang/cargo#15879)

r? ghost
@rustbot rustbot added this to the 1.91.0 milestone Aug 27, 2025
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Aug 30, 2025
Update cargo submodule

3 commits in 623d536836b4cde09ce38609232a024d5b25da81..a6c58d43051d01d83f55a3e61ef5f5b2b0dd6bd9
2025-08-22 19:05:52 +0000 to 2025-08-26 23:05:12 +0000
- test: avoid hardcoded target spec json (rust-lang/cargo#15880)
- test(add): Cover some frontmatter corner cases (rust-lang/cargo#15886)
- Add more context to publish-failed error message (rust-lang/cargo#15879)

r? ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testing-cargo-itself Area: cargo's tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants