Skip to content

Conversation

MikeMcQuaid
Copy link
Member

Provided as part of Homebrew/brew#20380

Don't merge until Homebrew/brew#20380 in a stable release.

@github-actions github-actions bot added rust Rust use is a significant feature of the PR or issue long build Set a long timeout for formula testing labels Aug 6, 2025
@github-actions github-actions bot added the autosquash Automatically squash pull request commits according to Homebrew style. label Aug 6, 2025
@MikeMcQuaid MikeMcQuaid force-pushed the append_to_rustflags branch from c1e08bb to 2660433 Compare August 6, 2025 18:16
@github-actions github-actions bot removed the autosquash Automatically squash pull request commits according to Homebrew style. label Aug 6, 2025
@MikeMcQuaid MikeMcQuaid added the CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. label Aug 7, 2025
@MikeMcQuaid MikeMcQuaid force-pushed the append_to_rustflags branch from 2660433 to 42c64a5 Compare August 7, 2025 11:17
@MikeMcQuaid MikeMcQuaid marked this pull request as ready for review August 8, 2025 07:31
@MikeMcQuaid MikeMcQuaid marked this pull request as draft August 8, 2025 07:43
@MikeMcQuaid MikeMcQuaid marked this pull request as ready for review August 11, 2025 13:34
@MikeMcQuaid MikeMcQuaid requested a review from carlocab August 11, 2025 13:35
Copy link
Contributor

:shipit: @MikeMcQuaid has requested bottles to be published to this PR.

Caution

Please do not push to this PR branch before the bottle commits have been pushed, as this results in a state that is difficult to recover from. If you need to resolve a merge conflict, please use a merge commit. Do not force-push to this PR branch.

@github-actions github-actions bot added the CI-published-bottle-commits The commits for the built bottles have been pushed to the PR branch. label Aug 11, 2025
@BrewTestBot BrewTestBot enabled auto-merge August 11, 2025 13:44
@BrewTestBot BrewTestBot added this pull request to the merge queue Aug 11, 2025
Merged via the queue into main with commit 7ee6905 Aug 11, 2025
26 checks passed
@BrewTestBot BrewTestBot deleted the append_to_rustflags branch August 11, 2025 14:16
Copy link
Contributor

@carlocab bottle request for qsv failed.

Comment on lines -38 to +36
ENV["RUSTFLAGS"] = "-C target-cpu=apple-m1" if OS.mac? && Hardware::CPU.arm?
ENV.append_to_rustflags "-C target-cpu=apple-m1" if OS.mac? && Hardware::CPU.arm?
Copy link
Member

Choose a reason for hiding this comment

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

It seems this broke arm64 macOS builds, unfortunately: https://github.com/Homebrew/homebrew-core/actions/runs/16884130215

Copy link
Member Author

Choose a reason for hiding this comment

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

@carlocab I saw that but I didn't see anything that looked consistent with the changes here. I just managed to build qsv locally with HOMEBREW_NO_INSTALL_FROM_API=1 brew install -s qsv on an ARM Mac.

Unrelatedly but seems confusing that that workflow doesn't actually show failed builds as 🔴?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@carlocab I'm talking about https://github.com/Homebrew/homebrew-core/actions/runs/16884130215 which you linked where upload is the only failing job but yet one of the bottles failed to build.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, yes. They actually all failed to build. But, as for why the builds themselves aren't 🔴: brew test-bot doesn't treat build failures as errors when there is no existing bottle (except for new formulae).

We could probably adjust that for dispatch-build-bottle, but it's worked fine as-is for quite a while now, so I haven't put in the time to change it.

Copy link
Member Author

Choose a reason for hiding this comment

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

We could probably adjust that for dispatch-build-bottle, but it's worked fine as-is for quite a while now, so I haven't put in the time to change it.

Yeh, think that would be nice 👍🏻

Copy link
Contributor

@carlocab bottle request for aptos failed.

Copy link
Contributor

@carlocab bottle request for mlc failed.

Comment on lines 26 to +28
# Explicitly set linker to avoid Cargo defaulting to
# incorrect or outdated linker (e.g. x86_64-apple-darwin14-clang)
ENV["RUSTFLAGS"] = "-C linker=#{ENV.cc}"
ENV.append_to_rustflags "-C linker=#{ENV.cc}"
Copy link
Member

Choose a reason for hiding this comment

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

Looks like these RUSTFLAGS aren't actually making it to rustc for some reason:

https://github.com/Homebrew/homebrew-core/actions/runs/16884114006/job/47827335082#step:4:255

Copy link
Member Author

Choose a reason for hiding this comment

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

@carlocab How can it be that these RUSTFLAGS are both breaking builds and not making it through?

Which of these can you reproduce locally?

Copy link
Member

Choose a reason for hiding this comment

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

How can it be that these RUSTFLAGS are both breaking builds and not making it through?

Because they aren't breaking builds, they are making them succeed (so their not making it through results in build failure).

Which of these can you reproduce locally?

Haven't been able to try a local build; I won't probably be able to get to it until tomorrow.

Copy link
Contributor

@carlocab bottle request for gstreamer failed.

carlocab added a commit that referenced this pull request Aug 11, 2025
I think this shouldn't be needed anymore, and will fix the build failure
we're now seeing after #232566.
@MikeMcQuaid
Copy link
Member Author

Looks like these RUSTFLAGS aren't actually making it to rustc for some reason:

They are definitely making it through to rustc. I've done:

$ brew uninstall -f qsv; HOMEBREW_NO_INSTALL_FROM_API=1 brew install -sv qsv

with

diff --git i/Library/Homebrew/extend/ENV/shared.rb w/Library/Homebrew/extend/ENV/shared.rb
index 28e66d480e2..a41fa701e0f 100644
--- i/Library/Homebrew/extend/ENV/shared.rb
+++ w/Library/Homebrew/extend/ENV/shared.rb
@@ -116,6 +116,7 @@ module SharedEnvExtension
   sig { params(rustflags: String).void }
   def append_to_rustflags(rustflags)
     append("HOMEBREW_RUSTFLAGS", rustflags)
+    p [:append_to_rustflags, self["HOMEBREW_RUSTFLAGS"]]
   end
 
   # Prepends a directory to `PATH`.
diff --git i/Library/Homebrew/extend/ENV/std.rb w/Library/Homebrew/extend/ENV/std.rb
index f4b5f34f113..88d44509c23 100644
--- i/Library/Homebrew/extend/ENV/std.rb
+++ w/Library/Homebrew/extend/ENV/std.rb
@@ -36,6 +36,7 @@ module Stdenv
     self["MAKEFLAGS"] = "-j#{make_jobs}"
     self["RUSTC_WRAPPER"] = "#{HOMEBREW_SHIMS_PATH}/super/rustc_wrapper"
     self["HOMEBREW_RUSTFLAGS"] = Hardware.rustflags_target_cpu(effective_arch)
+    p [:std_setup_build_environment, self["HOMEBREW_RUSTFLAGS"]]
 
     if HOMEBREW_PREFIX.to_s != "/usr/local"
       # /usr/local is already an -isystem and -L directory so we skip it
diff --git i/Library/Homebrew/extend/ENV/super.rb w/Library/Homebrew/extend/ENV/super.rb
index bf083f31654..88b4f58edb0 100644
--- i/Library/Homebrew/extend/ENV/super.rb
+++ w/Library/Homebrew/extend/ENV/super.rb
@@ -64,6 +64,7 @@ module Superenv
     self["MAKEFLAGS"] ||= "-j#{determine_make_jobs}"
     self["RUSTC_WRAPPER"] = "#{HOMEBREW_SHIMS_PATH}/super/rustc_wrapper"
     self["HOMEBREW_RUSTFLAGS"] = Hardware.rustflags_target_cpu(effective_arch)
+    p [:super_setup_build_environment, self["HOMEBREW_RUSTFLAGS"]]
     self["PATH"] = determine_path
     self["PKG_CONFIG_PATH"] = determine_pkg_config_path
     self["PKG_CONFIG_LIBDIR"] = determine_pkg_config_libdir || ""

and they are set as expected:

==> Fetching downloads for: qsv
✔︎ Formula qsv (6.0.1)
[:super_setup_build_environment, nil]
mv /private/tmp/homebrew-unpack-20250811-70667-37hs31/qsv-6.0.1 /private/tmp/qsv-20250811-70667-iq624n/qsv-6.0.1
[:append_to_rustflags, "-C target-cpu=apple-m1"]
==> cargo install --jobs 10 --locked --root=/opt/homebrew/Cellar/qsv/6.0.1 --path=.

If I add:

diff --git i/Library/Homebrew/shims/super/rustc_wrapper w/Library/Homebrew/shims/super/rustc_wrapper
index ad2c97c7a1d..35d1fc2698d 100755
--- i/Library/Homebrew/shims/super/rustc_wrapper
+++ w/Library/Homebrew/shims/super/rustc_wrapper
@@ -12,4 +12,5 @@ shift
 # Prepend HOMEBREW_RUSTFLAGS to the arguments if set.
 # HOMEBREW_RUSTFLAGS is set in extend/ENV/{std,super}.rb
 # shellcheck disable=SC2086,SC2154
-exec "${RUSTC}" ${HOMEBREW_RUSTFLAGS} "$@"
+echo "RUSTC_WRAPPER: ${HOMEBREW_RUSTFLAGS}"
+exec "${RUSTC}" "${HOMEBREW_RUSTFLAGS}" "$@"

You can see they are also being passed to rustc_wrapper too:

[:super_setup_build_environment, nil]
mv /private/tmp/homebrew-unpack-20250811-72294-tsqc1z/qsv-6.0.1 /private/tmp/qsv-20250811-72294-1kg25q/qsv-6.0.1
[:append_to_rustflags, "-C target-cpu=apple-m1"]
==> cargo install --jobs 10 --locked --root=/opt/homebrew/Cellar/qsv/6.0.1 --path=. --features apply,lens,luau,feature_capable
  Installing qsv v6.0.1 (/private/tmp/qsv-20250811-72294-1kg25q/qsv-6.0.1)
    Updating crates.io index
warning: package `curve25519-dalek v4.2.0` in Cargo.lock is yanked in registry `crates-io`, consider running without --locked
error: failed to compile `qsv v6.0.1 (/private/tmp/qsv-20250811-72294-1kg25q/qsv-6.0.1)`, intermediate artifacts can be found at `/private/tmp/qsv-20250811-72294-1kg25q/qsv-6.0.1/target`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

Caused by:
  failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `/opt/homebrew/Library/Homebrew/shims/super/rustc_wrapper rustc - --crate-name ___ --print=file-names -C 'link-args=-Wl,-rpath,@loader_path' -C target-cpu=native --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg -Wwarnings` (exit status: 1)
  --- stdout
  RUSTC_WRAPPER: -C target-cpu=apple-m1

  --- stderr
  error: unknown codegen option: ` target-cpu`

CC @Bo98 @carlocab @cho-m in case you have any ideas

@carlocab
Copy link
Member

I think I have a fix. PR up shortly. I don't have time to test until tomorrow, so feel free to try it out and merge if ready.

carlocab added a commit to Homebrew/brew that referenced this pull request Aug 11, 2025
If we pass it first, it can be overridden by other arguments passed on
the command line. We don't want that.

See discussion at Homebrew/homebrew-core#232566.
Copy link
Contributor

@carlocab bottle request for aptos failed.

carlocab added a commit that referenced this pull request Aug 12, 2025
Let's see if we can recover the bottles lost from #232566.
daeho-ro pushed a commit that referenced this pull request Aug 20, 2025
Let's see if we can recover the bottles lost from #232566.
daeho-ro pushed a commit that referenced this pull request Aug 20, 2025
Let's see if we can recover the bottles lost from #232566.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. CI-published-bottle-commits The commits for the built bottles have been pushed to the PR branch. long build Set a long timeout for formula testing rust Rust use is a significant feature of the PR or issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants