Merge pull request #20380 from Homebrew/rustc_wrapper
Add rustc wrapper shim to fix RUSTFLAGS conflicts
This commit is contained in:
commit
2bc10f6a52
@ -113,6 +113,11 @@ module SharedEnvExtension
|
|||||||
self[key] = PATH.new(self[key]).append(path)
|
self[key] = PATH.new(self[key]).append(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(rustflags: String).void }
|
||||||
|
def append_to_rustflags(rustflags)
|
||||||
|
append("HOMEBREW_RUSTFLAGS", rustflags)
|
||||||
|
end
|
||||||
|
|
||||||
# Prepends a directory to `PATH`.
|
# Prepends a directory to `PATH`.
|
||||||
# Is the formula struggling to find the pkgconfig file? Point it to it.
|
# Is the formula struggling to find the pkgconfig file? Point it to it.
|
||||||
# This is done automatically for keg-only formulae.
|
# This is done automatically for keg-only formulae.
|
||||||
|
@ -34,7 +34,8 @@ module Stdenv
|
|||||||
self["PKG_CONFIG_LIBDIR"] = determine_pkg_config_libdir
|
self["PKG_CONFIG_LIBDIR"] = determine_pkg_config_libdir
|
||||||
|
|
||||||
self["MAKEFLAGS"] = "-j#{make_jobs}"
|
self["MAKEFLAGS"] = "-j#{make_jobs}"
|
||||||
self["RUSTFLAGS"] = Hardware.rustflags_target_cpu(effective_arch)
|
self["RUSTC_WRAPPER"] = "#{HOMEBREW_SHIMS_PATH}/super/rustc_wrapper"
|
||||||
|
self["HOMEBREW_RUSTFLAGS"] = Hardware.rustflags_target_cpu(effective_arch)
|
||||||
|
|
||||||
if HOMEBREW_PREFIX.to_s != "/usr/local"
|
if HOMEBREW_PREFIX.to_s != "/usr/local"
|
||||||
# /usr/local is already an -isystem and -L directory so we skip it
|
# /usr/local is already an -isystem and -L directory so we skip it
|
||||||
|
@ -62,7 +62,8 @@ module Superenv
|
|||||||
|
|
||||||
self["HOMEBREW_ENV"] = "super"
|
self["HOMEBREW_ENV"] = "super"
|
||||||
self["MAKEFLAGS"] ||= "-j#{determine_make_jobs}"
|
self["MAKEFLAGS"] ||= "-j#{determine_make_jobs}"
|
||||||
self["RUSTFLAGS"] = Hardware.rustflags_target_cpu(effective_arch)
|
self["RUSTC_WRAPPER"] = "#{HOMEBREW_SHIMS_PATH}/super/rustc_wrapper"
|
||||||
|
self["HOMEBREW_RUSTFLAGS"] = Hardware.rustflags_target_cpu(effective_arch)
|
||||||
self["PATH"] = determine_path
|
self["PATH"] = determine_path
|
||||||
self["PKG_CONFIG_PATH"] = determine_pkg_config_path
|
self["PKG_CONFIG_PATH"] = determine_pkg_config_path
|
||||||
self["PKG_CONFIG_LIBDIR"] = determine_pkg_config_libdir || ""
|
self["PKG_CONFIG_LIBDIR"] = determine_pkg_config_libdir || ""
|
||||||
|
15
Library/Homebrew/shims/super/rustc_wrapper
Executable file
15
Library/Homebrew/shims/super/rustc_wrapper
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Prepend HOMEBREW_RUSTFLAGS to rustc arguments if set.
|
||||||
|
# This allows Homebrew to pass optimization flags while still respecting
|
||||||
|
# .cargo/config.toml (which sets RUSTFLAGS).
|
||||||
|
|
||||||
|
# rustc is passed as the first argument to RUSTC_WRAPPER
|
||||||
|
# https://doc.rust-lang.org/cargo/reference/environment-variables.html
|
||||||
|
RUSTC="${1}"
|
||||||
|
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} "$@"
|
Loading…
x
Reference in New Issue
Block a user