MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / cargo

Function cargo

misc/python/materialize/xcompile.py:88–171  ·  view source on GitHub ↗

Construct a Cargo invocation for cross compiling. Args: arch: The CPU architecture to build for. subcommand: The Cargo subcommand to invoke. rustflags: Override the flags passed to the Rust compiler. If the list is empty, the default flags are used. c

(
    arch: Arch,
    subcommand: str,
    rustflags: list[str],
    channel: str | None = None,
    extra_env: dict[str, str] = {},
)

Source from the content-addressed store, hash-verified

86
87
88def cargo(
89 arch: Arch,
90 subcommand: str,
91 rustflags: list[str],
92 channel: str | None = None,
93 extra_env: dict[str, str] = {},
94) -> list[str]:
95 """Construct a Cargo invocation for cross compiling.
96
97 Args:
98 arch: The CPU architecture to build for.
99 subcommand: The Cargo subcommand to invoke.
100 rustflags: Override the flags passed to the Rust compiler. If the list
101 is empty, the default flags are used.
102 channel: The Rust toolchain channel to use. Either None/"stable" or "nightly".
103
104 Returns:
105 A list of arguments specifying the beginning of the command to invoke.
106 """
107 _target = target(arch)
108 _target_env = _target.upper().replace("-", "_")
109 _target_cpu = target_cpu(arch)
110 _target_features = ",".join(target_features(arch))
111
112 env = {
113 **extra_env,
114 }
115
116 rustflags += [
117 "-Clink-arg=-Wl,--compress-debug-sections=zstd",
118 "-Clink-arg=-Wl,-O3",
119 "-Csymbol-mangling-version=v0",
120 f"-Ctarget-cpu={_target_cpu}",
121 f"-Ctarget-feature={_target_features}",
122 "--cfg=tokio_unstable",
123 ]
124
125 if sys.platform == "darwin":
126 _bootstrap_darwin(arch)
127 lld_prefix = spawn.capture(["brew", "--prefix", "lld"]).strip()
128 libfdb_c_prefix = spawn.capture(
129 ["brew", "--prefix", f"libfdb-c-{target(arch)}"]
130 ).strip()
131 sysroot = spawn.capture([f"{_target}-cc", "-print-sysroot"]).strip()
132 rustflags += [
133 f"-L{sysroot}/lib",
134 f"-L{libfdb_c_prefix}/lib",
135 "-Clink-arg=-fuse-ld=lld",
136 f"-Clink-arg=-B{lld_prefix}/bin",
137 ]
138 env.update(
139 {
140 "CMAKE_SYSTEM_NAME": "Linux",
141 f"CARGO_TARGET_{_target_env}_LINKER": f"{_target}-cc",
142 "CARGO_TARGET_DIR": str(MZ_ROOT / "target-xcompile"),
143 "TARGET_AR": f"{_target}-ar",
144 "TARGET_CPP": f"{_target}-cpp",
145 "TARGET_CC": f"{_target}-cc",

Callers

nothing calls this directly

Calls 11

targetFunction · 0.85
target_cpuFunction · 0.85
target_featuresFunction · 0.85
_bootstrap_darwinFunction · 0.85
_enter_builderFunction · 0.85
captureMethod · 0.80
replaceMethod · 0.45
upperMethod · 0.45
joinMethod · 0.45
updateMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected