# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr@gmail.com>
# Date 1678122149 -3600
#      Mon Mar 06 18:02:29 2023 +0100
# Branch stable
# Node ID 8c0474a25ff0c788b147ce6381ffbb2435c1c4c2
# Parent  c499b1c999728ea3d078dee36b83508bbebe003d
# EXP-Topic patches
setup_py

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -1109,7 +1109,9 @@ class RustCompilationError(CCompilerErro
 class RustExtension(Extension):
     """Base classes for concrete Rust Extension classes."""
 
-    rusttargetdir = os.path.join('rust', 'target', 'release')
+    rusttargetdir = os.path.join(
+        'rust', 'target', os.getenv('CARGO_BUILD_TARGET', '.'), 'release'
+    )
 
     def __init__(self, mpath, sources, rustlibname, subcrate, **kw):
         Extension.__init__(self, mpath, sources, **kw)
@@ -1170,7 +1172,7 @@ class RustExtension(Extension):
         env['PYTHON'] = sys.executable
         env['PYO3_PYTHON'] = sys.executable
 
-        cargocmd = ['cargo', 'rustc', '--release']
+        cargocmd = ['cargo', 'rustc', '--release', '--frozen', '-j', '@BUILD_JOBS@']
 
         rust_features = env.get("HG_RUST_FEATURES")
         if rust_features:
