@@ -44,11 +44,6 @@ struct Archiver
4444 AcceptedArchiver type;
4545 string bin;
4646}
47- struct Linker
48- {
49- AcceptedLinker type;
50- string bin;
51- }
5247
5348AcceptedCompiler acceptedCompilerfromString (string str)
5449{
@@ -91,14 +86,6 @@ AcceptedArchiver acceptedArchiverFromString(string str)
9186 }
9287}
9388
94- private Linker acceptedLinker (JSONValue v)
95- {
96- JSONValue* acc = " defaultLinker" in v;
97- if (! acc)
98- return Linker (AcceptedLinker.unknown);
99- return Linker (acceptedLinkerfromString(acc.object[" type" ].str), acc.object[" bin" ].str);
100- }
101-
10289private Archiver acceptedArchiver (JSONValue v)
10390{
10491 JSONValue* acc = " defaultArchiver" in v;
@@ -141,7 +128,7 @@ struct Compiler
141128
142129 // /Currently unused. Was used before for checking whether --start-group should be emitted or not. Since it is emitted
143130 // /by default, only on webAssembly which is not, it lost its usage for now.
144- Linker linker = Linker( AcceptedLinker.unknown) ;
131+ AcceptedLinker linker = AcceptedLinker.unknown;
145132
146133
147134 string getCompilerString () const
@@ -298,7 +285,7 @@ Compiler getCompiler(string compilerOrPath = "dmd", string compilerAssumption =
298285 if (ret == Compiler.init)
299286 ret = inferCompiler(compilerOrPath, compilerAssumption, compilersInfo, isDefault, isGlobal);
300287
301- ret.linker = acceptedLinker (compilersInfo);
288+ ret.linker = acceptedLinkerfromString (compilersInfo[ " defaultLinker " ].str );
302289 ret.archiver = acceptedArchiver(compilersInfo);
303290
304291 // Checks for ldc.conf switches to see if it is using gnu linker by default
@@ -436,7 +423,7 @@ private Compiler getCompilerFromCache(JSONValue allCompilersInfo, string compile
436423 SemVer(arr[VERSION_ ].str),
437424 SemVer(arr[FRONTEND_VERSION ].str),
438425 arr[VERSION_STRING ].str,
439- key, acceptedArchiver (allCompilersInfo), false , acceptedLinker (allCompilersInfo)
426+ key, acceptedArchiver (allCompilersInfo), false , acceptedLinkerfromString (allCompilersInfo[ " defaultLinker " ].str )
440427 );
441428 }
442429 }
@@ -487,14 +474,8 @@ private void saveCompilerInfo(JSONValue allCompilersInfo, ref Compiler compiler,
487474 }
488475
489476 if (! (" defaultLinker" in allCompilersInfo))
490- {
491- JSONValue defaultLinker = JSONValue.emptyObject;
492- auto def = getDefaultLinker();
493- defaultLinker[" type" ] = def.type.to! string ;
494- defaultLinker[" bin" ] = def.bin;
495- allCompilersInfo[" defaultLinker" ] = defaultLinker;
496- }
497- compiler.linker = acceptedLinker(allCompilersInfo);
477+ allCompilersInfo[" defaultLinker" ] = getDefaultLinker.to! string ;
478+ compiler.linker = acceptedLinkerfromString(allCompilersInfo[" defaultLinker" ].str);
498479
499480 if (! (" compilers" in allCompilersInfo))
500481 allCompilersInfo[" compilers" ] = JSONValue.emptyObject;
@@ -548,7 +529,7 @@ private Compiler assumeCompiler(string compilerOrPath, string compilerAssumption
548529}
549530
550531
551- Linker getDefaultLinker ()
532+ AcceptedLinker getDefaultLinker ()
552533{
553534 with (AcceptedLinker)
554535 {
@@ -560,12 +541,12 @@ Linker getDefaultLinker()
560541 if (res.status == 0 )
561542 {
562543 if (res.output.startsWith(" GNU ld" ))
563- return Linker ( gnuld, " ld " ) ;
544+ return gnuld;
564545 else if (res.output.startsWith(" @(#)PROGRAM:ld" ))
565- return Linker ( ld64, " ld " ) ;
546+ return ld64;
566547 }
567548 }
568- return Linker ( unknown) ;
549+ return unknown;
569550 }
570551}
571552
0 commit comments