@@ -1739,6 +1739,7 @@ static StringRef getOutputFilename(Compilation &C,
1739
1739
const JobAction *JA,
1740
1740
const OutputInfo &OI,
1741
1741
const TypeToPathMap *OutputMap,
1742
+ const llvm::Triple &Triple,
1742
1743
const llvm::opt::DerivedArgList &Args,
1743
1744
bool AtTopLevel,
1744
1745
StringRef BaseInput,
@@ -1827,10 +1828,17 @@ static StringRef getOutputFilename(Compilation &C,
1827
1828
BaseName = llvm::sys::path::stem (BaseInput);
1828
1829
if (auto link = dyn_cast<LinkJobAction>(JA)) {
1829
1830
if (link->getKind () == LinkKind::DynamicLibrary) {
1830
- // FIXME: This should be target-specific.
1831
- Buffer = " lib" ;
1831
+ if (Triple.isOSWindows ())
1832
+ Buffer = " " ;
1833
+ else
1834
+ Buffer = " lib" ;
1832
1835
Buffer.append (BaseName);
1833
- Buffer.append (LTDL_SHLIB_EXT);
1836
+ if (Triple.isOSDarwin ())
1837
+ Buffer.append (" .dylib" );
1838
+ else if (Triple.isOSWindows ())
1839
+ Buffer.append (" .dll" );
1840
+ else
1841
+ Buffer.append (" .so" );
1834
1842
return Buffer.str ();
1835
1843
}
1836
1844
}
@@ -2043,9 +2051,9 @@ Job *Driver::buildJobsForAction(Compilation &C, const JobAction *JA,
2043
2051
const TypeToPathMap *OMForInput = nullptr ;
2044
2052
if (OFM)
2045
2053
OMForInput = OFM->getOutputMapForInput (Input);
2046
-
2047
- OutputFile = getOutputFilename (C, JA, OI, OMForInput, C. getArgs (),
2048
- AtTopLevel, Input, InputJobs,
2054
+
2055
+ OutputFile = getOutputFilename (C, JA, OI, OMForInput, TC. getTriple (),
2056
+ C. getArgs (), AtTopLevel, Input, InputJobs,
2049
2057
Diags, Buf);
2050
2058
Output->addPrimaryOutput (OutputFile, Input);
2051
2059
};
@@ -2061,9 +2069,9 @@ Job *Driver::buildJobsForAction(Compilation &C, const JobAction *JA,
2061
2069
}
2062
2070
} else {
2063
2071
// The common case: there is a single output file.
2064
- OutputFile = getOutputFilename (C, JA, OI, OutputMap, C. getArgs (),
2065
- AtTopLevel, BaseInput, InputJobs ,
2066
- Diags, Buf);
2072
+ OutputFile = getOutputFilename (C, JA, OI, OutputMap, TC. getTriple (),
2073
+ C. getArgs (), AtTopLevel, BaseInput ,
2074
+ InputJobs, Diags, Buf);
2067
2075
Output->addPrimaryOutput (OutputFile, BaseInput);
2068
2076
}
2069
2077
0 commit comments