@@ -1191,118 +1191,10 @@ bool tools::addOpenMPRuntime(const Compilation &C, ArgStringList &CmdArgs,
1191
1191
return true ;
1192
1192
}
1193
1193
1194
- // / Determines if --whole-archive is active in the list of arguments.
1195
- static bool isWholeArchivePresent (const ArgList &Args) {
1196
- bool WholeArchiveActive = false ;
1197
- for (auto *Arg : Args.filtered (options::OPT_Wl_COMMA)) {
1198
- if (Arg) {
1199
- for (StringRef ArgValue : Arg->getValues ()) {
1200
- if (ArgValue == " --whole-archive" )
1201
- WholeArchiveActive = true ;
1202
- if (ArgValue == " --no-whole-archive" )
1203
- WholeArchiveActive = false ;
1204
- }
1205
- }
1206
- }
1207
-
1208
- return WholeArchiveActive;
1209
- }
1210
-
1211
- // / Determine if driver is invoked to create a shared object library (-static)
1212
- static bool isSharedLinkage (const ArgList &Args) {
1213
- return Args.hasArg (options::OPT_shared);
1214
- }
1215
-
1216
- // / Determine if driver is invoked to create a static object library (-shared)
1217
- static bool isStaticLinkage (const ArgList &Args) {
1218
- return Args.hasArg (options::OPT_static);
1219
- }
1220
-
1221
- // / Add Fortran runtime libs for MSVC
1222
- static void addFortranRuntimeLibsMSVC (const ArgList &Args,
1223
- llvm::opt::ArgStringList &CmdArgs) {
1224
- unsigned RTOptionID = options::OPT__SLASH_MT;
1225
- if (auto *rtl = Args.getLastArg (options::OPT_fms_runtime_lib_EQ)) {
1226
- RTOptionID = llvm::StringSwitch<unsigned >(rtl->getValue ())
1227
- .Case (" static" , options::OPT__SLASH_MT)
1228
- .Case (" static_dbg" , options::OPT__SLASH_MTd)
1229
- .Case (" dll" , options::OPT__SLASH_MD)
1230
- .Case (" dll_dbg" , options::OPT__SLASH_MDd)
1231
- .Default (options::OPT__SLASH_MT);
1232
- }
1233
- switch (RTOptionID) {
1234
- case options::OPT__SLASH_MT:
1235
- CmdArgs.push_back (" /WHOLEARCHIVE:Fortran_main.static.lib" );
1236
- break ;
1237
- case options::OPT__SLASH_MTd:
1238
- CmdArgs.push_back (" /WHOLEARCHIVE:Fortran_main.static_dbg.lib" );
1239
- break ;
1240
- case options::OPT__SLASH_MD:
1241
- CmdArgs.push_back (" /WHOLEARCHIVE:Fortran_main.dynamic.lib" );
1242
- break ;
1243
- case options::OPT__SLASH_MDd:
1244
- CmdArgs.push_back (" /WHOLEARCHIVE:Fortran_main.dynamic_dbg.lib" );
1245
- break ;
1246
- }
1247
- }
1248
-
1249
- // Add FortranMain runtime lib
1250
- static void addFortranMain (const ToolChain &TC, const ArgList &Args,
1251
- llvm::opt::ArgStringList &CmdArgs) {
1252
- // 0. Shared-library linkage
1253
- // If we are attempting to link a library, we should not add
1254
- // -lFortran_main.a to the link line, as the `main` symbol is not
1255
- // required for a library and should also be provided by one of
1256
- // the translation units of the code that this shared library
1257
- // will be linked against eventually.
1258
- if (isSharedLinkage (Args) || isStaticLinkage (Args)) {
1259
- return ;
1260
- }
1261
-
1262
- // 1. MSVC
1263
- if (TC.getTriple ().isKnownWindowsMSVCEnvironment ()) {
1264
- addFortranRuntimeLibsMSVC (Args, CmdArgs);
1265
- return ;
1266
- }
1267
-
1268
- // 2. GNU and similar
1269
- const Driver &D = TC.getDriver ();
1270
- const char *FortranMainLinkFlag = " -lFortran_main" ;
1271
-
1272
- // Warn if the user added `-lFortran_main` - this library is an implementation
1273
- // detail of Flang and should be handled automaticaly by the driver.
1274
- for (const char *arg : CmdArgs) {
1275
- if (strncmp (arg, FortranMainLinkFlag, strlen (FortranMainLinkFlag)) == 0 )
1276
- D.Diag (diag::warn_drv_deprecated_custom)
1277
- << FortranMainLinkFlag
1278
- << " see the Flang driver documentation for correct usage" ;
1279
- }
1280
-
1281
- // The --whole-archive option needs to be part of the link line to make
1282
- // sure that the main() function from Fortran_main.a is pulled in by the
1283
- // linker. However, it shouldn't be used if it's already active.
1284
- // TODO: Find an equivalent of `--whole-archive` for Darwin and AIX.
1285
- if (!isWholeArchivePresent (Args) && !TC.getTriple ().isMacOSX () &&
1286
- !TC.getTriple ().isOSAIX ()) {
1287
- CmdArgs.push_back (" --whole-archive" );
1288
- CmdArgs.push_back (FortranMainLinkFlag);
1289
- CmdArgs.push_back (" --no-whole-archive" );
1290
- return ;
1291
- }
1292
-
1293
- CmdArgs.push_back (FortranMainLinkFlag);
1294
- }
1295
-
1296
1194
// / Add Fortran runtime libs
1297
1195
void tools::addFortranRuntimeLibs (const ToolChain &TC, const ArgList &Args,
1298
1196
llvm::opt::ArgStringList &CmdArgs) {
1299
- // 1. Link FortranMain
1300
- // FortranMain depends on FortranRuntime, so needs to be listed first. If
1301
- // -fno-fortran-main has been passed, skip linking Fortran_main.a
1302
- if (!Args.hasArg (options::OPT_no_fortran_main))
1303
- addFortranMain (TC, Args, CmdArgs);
1304
-
1305
- // 2. Link FortranRuntime and FortranDecimal
1197
+ // Link FortranRuntime and FortranDecimal
1306
1198
// These are handled earlier on Windows by telling the frontend driver to
1307
1199
// add the correct libraries to link against as dependents in the object
1308
1200
// file.
0 commit comments