@@ -123,6 +123,8 @@ pub enum LinkerFlavor {
123123 Bpf ,
124124 /// Linker tool for Nvidia PTX.
125125 Ptx ,
126+ /// LLVM bitcode linker that can be used as a `self-contained` linker
127+ Llbc ,
126128}
127129
128130/// Linker flavors available externally through command line (`-Clinker-flavor`)
@@ -141,6 +143,7 @@ pub enum LinkerFlavorCli {
141143 EmCc ,
142144 Bpf ,
143145 Ptx ,
146+ Llbc ,
144147
145148 // Legacy stable values
146149 Gcc ,
@@ -160,6 +163,7 @@ impl LinkerFlavorCli {
160163 | LinkerFlavorCli :: Msvc ( Lld :: Yes )
161164 | LinkerFlavorCli :: EmCc
162165 | LinkerFlavorCli :: Bpf
166+ | LinkerFlavorCli :: Llbc
163167 | LinkerFlavorCli :: Ptx => true ,
164168 LinkerFlavorCli :: Gcc
165169 | LinkerFlavorCli :: Ld
@@ -219,6 +223,7 @@ impl LinkerFlavor {
219223 LinkerFlavorCli :: Msvc ( lld) => LinkerFlavor :: Msvc ( lld) ,
220224 LinkerFlavorCli :: EmCc => LinkerFlavor :: EmCc ,
221225 LinkerFlavorCli :: Bpf => LinkerFlavor :: Bpf ,
226+ LinkerFlavorCli :: Llbc => LinkerFlavor :: Llbc ,
222227 LinkerFlavorCli :: Ptx => LinkerFlavor :: Ptx ,
223228
224229 // Below: legacy stable values
@@ -258,6 +263,7 @@ impl LinkerFlavor {
258263 LinkerFlavor :: Msvc ( ..) => LinkerFlavorCli :: Msvc ( Lld :: No ) ,
259264 LinkerFlavor :: EmCc => LinkerFlavorCli :: Em ,
260265 LinkerFlavor :: Bpf => LinkerFlavorCli :: Bpf ,
266+ LinkerFlavor :: Llbc => LinkerFlavorCli :: Llbc ,
261267 LinkerFlavor :: Ptx => LinkerFlavorCli :: Ptx ,
262268 }
263269 }
@@ -272,6 +278,7 @@ impl LinkerFlavor {
272278 LinkerFlavor :: Msvc ( lld) => LinkerFlavorCli :: Msvc ( lld) ,
273279 LinkerFlavor :: EmCc => LinkerFlavorCli :: EmCc ,
274280 LinkerFlavor :: Bpf => LinkerFlavorCli :: Bpf ,
281+ LinkerFlavor :: Llbc => LinkerFlavorCli :: Llbc ,
275282 LinkerFlavor :: Ptx => LinkerFlavorCli :: Ptx ,
276283 }
277284 }
@@ -286,6 +293,7 @@ impl LinkerFlavor {
286293 LinkerFlavorCli :: Msvc ( lld) => ( Some ( Cc :: No ) , Some ( lld) ) ,
287294 LinkerFlavorCli :: EmCc => ( Some ( Cc :: Yes ) , Some ( Lld :: Yes ) ) ,
288295 LinkerFlavorCli :: Bpf | LinkerFlavorCli :: Ptx => ( None , None ) ,
296+ LinkerFlavorCli :: Llbc => ( None , None ) ,
289297
290298 // Below: legacy stable values
291299 LinkerFlavorCli :: Gcc => ( Some ( Cc :: Yes ) , None ) ,
@@ -340,7 +348,7 @@ impl LinkerFlavor {
340348 LinkerFlavor :: WasmLld ( cc) => LinkerFlavor :: WasmLld ( cc_hint. unwrap_or ( cc) ) ,
341349 LinkerFlavor :: Unix ( cc) => LinkerFlavor :: Unix ( cc_hint. unwrap_or ( cc) ) ,
342350 LinkerFlavor :: Msvc ( lld) => LinkerFlavor :: Msvc ( lld_hint. unwrap_or ( lld) ) ,
343- LinkerFlavor :: EmCc | LinkerFlavor :: Bpf | LinkerFlavor :: Ptx => self ,
351+ LinkerFlavor :: EmCc | LinkerFlavor :: Bpf | LinkerFlavor :: Llbc | LinkerFlavor :: Ptx => self ,
344352 }
345353 }
346354
@@ -355,20 +363,23 @@ impl LinkerFlavor {
355363 pub fn check_compatibility ( self , cli : LinkerFlavorCli ) -> Option < String > {
356364 let compatible = |cli| {
357365 // The CLI flavor should be compatible with the target if:
358- // 1. they are counterparts: they have the same principal flavor.
359366 match ( self , cli) {
367+ // 1. they are counterparts: they have the same principal flavor.
360368 ( LinkerFlavor :: Gnu ( ..) , LinkerFlavorCli :: Gnu ( ..) )
361369 | ( LinkerFlavor :: Darwin ( ..) , LinkerFlavorCli :: Darwin ( ..) )
362370 | ( LinkerFlavor :: WasmLld ( ..) , LinkerFlavorCli :: WasmLld ( ..) )
363371 | ( LinkerFlavor :: Unix ( ..) , LinkerFlavorCli :: Unix ( ..) )
364372 | ( LinkerFlavor :: Msvc ( ..) , LinkerFlavorCli :: Msvc ( ..) )
365373 | ( LinkerFlavor :: EmCc , LinkerFlavorCli :: EmCc )
366374 | ( LinkerFlavor :: Bpf , LinkerFlavorCli :: Bpf )
375+ | ( LinkerFlavor :: Llbc , LinkerFlavorCli :: Llbc )
367376 | ( LinkerFlavor :: Ptx , LinkerFlavorCli :: Ptx ) => return true ,
377+ // 2. The linker flavor is independent of target and compatible
378+ ( LinkerFlavor :: Ptx , LinkerFlavorCli :: Llbc ) => return true ,
368379 _ => { }
369380 }
370381
371- // 2 . or, the flavor is legacy and survives this roundtrip.
382+ // 3 . or, the flavor is legacy and survives this roundtrip.
372383 cli == self . with_cli_hints ( cli) . to_cli ( )
373384 } ;
374385 ( !compatible ( cli) ) . then ( || {
@@ -387,6 +398,7 @@ impl LinkerFlavor {
387398 | LinkerFlavor :: Unix ( ..)
388399 | LinkerFlavor :: EmCc
389400 | LinkerFlavor :: Bpf
401+ | LinkerFlavor :: Llbc
390402 | LinkerFlavor :: Ptx => LldFlavor :: Ld ,
391403 LinkerFlavor :: Darwin ( ..) => LldFlavor :: Ld64 ,
392404 LinkerFlavor :: WasmLld ( ..) => LldFlavor :: Wasm ,
@@ -412,6 +424,7 @@ impl LinkerFlavor {
412424 | LinkerFlavor :: Msvc ( _)
413425 | LinkerFlavor :: Unix ( _)
414426 | LinkerFlavor :: Bpf
427+ | LinkerFlavor :: Llbc
415428 | LinkerFlavor :: Ptx => false ,
416429 }
417430 }
@@ -431,6 +444,7 @@ impl LinkerFlavor {
431444 | LinkerFlavor :: Msvc ( _)
432445 | LinkerFlavor :: Unix ( _)
433446 | LinkerFlavor :: Bpf
447+ | LinkerFlavor :: Llbc
434448 | LinkerFlavor :: Ptx => false ,
435449 }
436450 }
@@ -480,6 +494,7 @@ linker_flavor_cli_impls! {
480494 ( LinkerFlavorCli :: Msvc ( Lld :: No ) ) "msvc"
481495 ( LinkerFlavorCli :: EmCc ) "em-cc"
482496 ( LinkerFlavorCli :: Bpf ) "bpf"
497+ ( LinkerFlavorCli :: Llbc ) "llbc"
483498 ( LinkerFlavorCli :: Ptx ) "ptx"
484499
485500 // Legacy stable flavors
@@ -2205,6 +2220,7 @@ fn add_link_args_iter(
22052220 | LinkerFlavor :: Unix ( ..)
22062221 | LinkerFlavor :: EmCc
22072222 | LinkerFlavor :: Bpf
2223+ | LinkerFlavor :: Llbc
22082224 | LinkerFlavor :: Ptx => { }
22092225 }
22102226}
0 commit comments