Skip to content

fix: pass RUSTFLAGS #462

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions setuptools_rust/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,16 @@ def build_extension(
*rustc_args,
]

if rustflags:
existing_rustflags = env.get("RUSTFLAGS")
if existing_rustflags is not None:
rustflags.append(existing_rustflags)
new_rustflags = " ".join(rustflags)
env["RUSTFLAGS"] = new_rustflags
# order is important
new_rustflags = list(filter(None, (rustflags, os.getenv("RUSTFLAGS"))))

if new_rustflags:
new_rustflags_str = " ".join(new_rustflags)
env["RUSTFLAGS"] = new_rustflags_str

# print RUSTFLAGS being added before the command
if not quiet:
print(f"[RUSTFLAGS={new_rustflags}]", end=" ", file=sys.stderr)
print(f"[RUSTFLAGS={new_rustflags_str}]", end=" ", file=sys.stderr)

if not quiet:
print(" ".join(command), file=sys.stderr)
Expand Down