@@ -115,10 +115,16 @@ pub(crate) fn build_sysroot(
115
115
}
116
116
}
117
117
SysrootKind :: Clif => {
118
- build_clif_sysroot_for_triple ( channel, target_dir, target_triple ) ;
118
+ build_clif_sysroot_for_triple ( channel, target_dir, host_triple , None ) ;
119
119
120
120
if host_triple != target_triple {
121
- build_clif_sysroot_for_triple ( channel, target_dir, host_triple) ;
121
+ // When cross-compiling it is often necessary to manually pick the right linker
122
+ let linker = if target_triple == "aarch64-unknown-linux-gnu" {
123
+ Some ( "aarch64-linux-gnu-gcc" )
124
+ } else {
125
+ None
126
+ } ;
127
+ build_clif_sysroot_for_triple ( channel, target_dir, target_triple, linker) ;
122
128
}
123
129
124
130
// Copy std for the host to the lib dir. This is necessary for the jit mode to find
@@ -133,7 +139,12 @@ pub(crate) fn build_sysroot(
133
139
}
134
140
}
135
141
136
- fn build_clif_sysroot_for_triple ( channel : & str , target_dir : & Path , triple : & str ) {
142
+ fn build_clif_sysroot_for_triple (
143
+ channel : & str ,
144
+ target_dir : & Path ,
145
+ triple : & str ,
146
+ linker : Option < & str > ,
147
+ ) {
137
148
let build_dir = Path :: new ( "build_sysroot" ) . join ( "target" ) . join ( triple) . join ( channel) ;
138
149
139
150
let keep_sysroot =
@@ -155,6 +166,10 @@ fn build_clif_sysroot_for_triple(channel: &str, target_dir: &Path, triple: &str)
155
166
build_cmd. arg ( "--release" ) ;
156
167
rustflags. push_str ( " -Zmir-opt-level=3" ) ;
157
168
}
169
+ if let Some ( linker) = linker {
170
+ use std:: fmt:: Write ;
171
+ write ! ( rustflags, " -Clinker={}" , linker) . unwrap ( ) ;
172
+ }
158
173
build_cmd. env ( "RUSTFLAGS" , rustflags) ;
159
174
build_cmd. env (
160
175
"RUSTC" ,
0 commit comments