Skip to content

Commit

Permalink
cargo config: filter -Clinker from rustflags
Browse files Browse the repository at this point in the history
linker pass through rustflags will fail to be resolved from build
script. So, we have to filter this flags out from rustflags and add
a dedicated specific target entry in config.toml.
  • Loading branch information
fvalette-ledger committed Dec 20, 2024
1 parent 9de1489 commit 459e3bc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/outpost/barbican/_internals/cargo_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ def run_cargo_config(rustargs: Path, target: Path, extra_args: str, outdir: Path
target = target.read_text().splitlines()[0]
rustargs = rustargs.read_text().splitlines()
rustargs.extend(extra_args.split(" "))
linkerargs = list(filter(lambda x: x.startswith("-Clinker"), rustargs))
linker = linkerargs[0].split("=")[1] if len(linkerargs) else "is not set"
rustargs = list(filter(lambda x: not x.startswith("-Clinker"), rustargs))

config = f"""
[build]
target = "{target}"
target-dir = "{str(outdir.resolve())}"
rustflags = {rustargs}
[target.{target}]
{"#" if not len(linkerargs) else ""}linker = "{linker}"
[env]
OUT_DIR = "{str(outdir.resolve())}"
"""
Expand Down

0 comments on commit 459e3bc

Please sign in to comment.