@@ -77,6 +77,13 @@ impl LinkerInfo {
7777 as Box < dyn Linker >
7878 }
7979
80+ LinkerFlavor :: L4Bender => {
81+ Box :: new ( L4Bender {
82+ cmd,
83+ sess,
84+ hinted_static : false ,
85+ } ) as Box < Linker >
86+ } ,
8087 LinkerFlavor :: Lld ( LldFlavor :: Wasm ) => {
8188 Box :: new ( WasmLd :: new ( cmd, sess, self ) ) as Box < dyn Linker >
8289 }
@@ -1284,6 +1291,127 @@ impl<'a> Linker for WasmLd<'a> {
12841291 }
12851292}
12861293
1294+ /// Linker shepherd script for L4Re (Fiasco)
1295+ pub struct L4Bender < ' a > {
1296+ cmd : Command ,
1297+ sess : & ' a Session ,
1298+ hinted_static : bool ,
1299+ }
1300+
1301+ impl < ' a > Linker for L4Bender < ' a > {
1302+ fn link_dylib ( & mut self , lib : & str ) {
1303+ self . link_staticlib ( lib) ; // do not support dynamic linking for now
1304+ }
1305+ fn link_staticlib ( & mut self , lib : & str ) {
1306+ self . hint_static ( ) ;
1307+ self . cmd . arg ( format ! ( "-PC{}" , lib) ) ;
1308+ }
1309+ fn link_rlib ( & mut self , lib : & Path ) {
1310+ self . hint_static ( ) ;
1311+ self . cmd . arg ( lib) ;
1312+ }
1313+ fn include_path ( & mut self , path : & Path ) {
1314+ self . cmd . arg ( "-L" ) . arg ( path) ;
1315+ }
1316+ fn framework_path ( & mut self , _: & Path ) {
1317+ bug ! ( "Frameworks are not supported on L4Re!" ) ;
1318+ }
1319+ fn output_filename ( & mut self , path : & Path ) { self . cmd . arg ( "-o" ) . arg ( path) ; }
1320+ fn add_object ( & mut self , path : & Path ) { self . cmd . arg ( path) ; }
1321+ // not sure about pie on L4Re
1322+ fn position_independent_executable ( & mut self ) { }
1323+ fn no_position_independent_executable ( & mut self ) { }
1324+ fn full_relro ( & mut self ) { self . cmd . arg ( "-z,relro,-z,now" ) ; }
1325+ fn partial_relro ( & mut self ) { self . cmd . arg ( "-z,relro" ) ; }
1326+ fn no_relro ( & mut self ) { self . cmd . arg ( "-z,norelro" ) ; }
1327+ fn build_static_executable ( & mut self ) { self . cmd . arg ( "-static" ) ; }
1328+ fn args ( & mut self , args : & [ String ] ) { self . cmd . args ( args) ; }
1329+
1330+ fn link_rust_dylib ( & mut self , lib : & str , _path : & Path ) { self . link_dylib ( lib) ; }
1331+
1332+ fn link_framework ( & mut self , _: & str ) {
1333+ bug ! ( "Frameworks not supported on L4Re." ) ;
1334+ }
1335+
1336+ // Here we explicitly ask that the entire archive is included into the
1337+ // result artifact. For more details see #15460, but the gist is that
1338+ // the linker will strip away any unused objects in the archive if we
1339+ // don't otherwise explicitly reference them. This can occur for
1340+ // libraries which are just providing bindings, libraries with generic
1341+ // functions, etc.
1342+ fn link_whole_staticlib ( & mut self , lib : & str , _: & [ PathBuf ] ) {
1343+ self . hint_static ( ) ;
1344+ self . cmd . arg ( "--whole-archive" ) ;
1345+ self . cmd . arg ( "-l" ) . arg ( lib) ;
1346+ self . cmd . arg ( "--no-whole-archive" ) ;
1347+ }
1348+
1349+ fn link_whole_rlib ( & mut self , lib : & Path ) {
1350+ self . hint_static ( ) ;
1351+ self . cmd . arg ( "--whole-archive" ) . arg ( lib) . arg ( "--no-whole-archive" ) ;
1352+ }
1353+
1354+ fn gc_sections ( & mut self , keep_metadata : bool ) {
1355+ if !keep_metadata {
1356+ self . cmd . arg ( "--gc-sections" ) ;
1357+ }
1358+ }
1359+
1360+ fn optimize ( & mut self ) {
1361+ self . cmd . arg ( "-O2" ) ;
1362+ }
1363+
1364+ fn pgo_gen ( & mut self ) { }
1365+
1366+ fn debuginfo ( & mut self ) {
1367+ // for documentation, see GccLinker.debuginfo()
1368+ match self . sess . opts . debuginfo {
1369+ DebugInfoLevel :: NoDebugInfo => {
1370+ match self . sess . opts . debugging_opts . strip_debuginfo_if_disabled {
1371+ Some ( true ) => { self . cmd . arg ( "-S" ) ; } ,
1372+ _ => { } ,
1373+ }
1374+ } ,
1375+ _ => { } ,
1376+ } ;
1377+ }
1378+
1379+ fn no_default_libraries ( & mut self ) {
1380+ self . cmd . arg ( "-nostdlib" ) ;
1381+ }
1382+
1383+ fn build_dylib ( & mut self , _: & Path ) {
1384+ bug ! ( "not implemented" ) ;
1385+ }
1386+
1387+ fn export_symbols ( & mut self , _: & Path , _: CrateType ) {
1388+ bug ! ( "Not implemented" ) ;
1389+ }
1390+
1391+ fn subsystem ( & mut self , subsystem : & str ) {
1392+ self . cmd . arg ( & format ! ( "--subsystem,{}" , subsystem) ) ;
1393+ }
1394+
1395+ fn finalize ( & mut self ) -> Command {
1396+ self . hint_static ( ) ; // Reset to default before returning the composed command line.
1397+ let mut cmd = Command :: new ( "" ) ;
1398+ :: std:: mem:: swap ( & mut cmd, & mut self . cmd ) ;
1399+ cmd
1400+ }
1401+
1402+ fn group_start ( & mut self ) { self . cmd . arg ( "--start-group" ) ; }
1403+ fn group_end ( & mut self ) { self . cmd . arg ( "--end-group" ) ; }
1404+ }
1405+
1406+ impl < ' a > L4Bender < ' a > {
1407+ fn hint_static ( & mut self ) {
1408+ if !self . hinted_static {
1409+ self . cmd . arg ( "-static" ) ;
1410+ self . hinted_static = true ;
1411+ }
1412+ }
1413+ }
1414+
12871415fn exported_symbols ( tcx : TyCtxt < ' _ > , crate_type : CrateType ) -> Vec < String > {
12881416 if let Some ( ref exports) = tcx. sess . target . override_export_symbols {
12891417 return exports. clone ( ) ;
0 commit comments