Skip to content

Commit 181cdae

Browse files
authored
Merge pull request #1181 from swiftwasm/master
[pull] swiftwasm from master
2 parents a82aa74 + bded632 commit 181cdae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+342
-288
lines changed

cmake/modules/AddSwift.cmake

+4-8
Original file line numberDiff line numberDiff line change
@@ -453,20 +453,16 @@ function(add_swift_host_library name)
453453
LIBRARY_DIR ${SWIFT_LIBRARY_OUTPUT_INTDIR})
454454

455455
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
456-
set_target_properties(${name}
457-
PROPERTIES
456+
set_target_properties(${name} PROPERTIES
458457
INSTALL_NAME_DIR "@rpath")
459458
elseif(SWIFT_HOST_VARIANT_SDK STREQUAL LINUX)
460-
set_target_properties(${name}
461-
PROPERTIES
459+
set_target_properties(${name} PROPERTIES
462460
INSTALL_RPATH "$ORIGIN:/usr/lib/swift/linux")
463461
elseif(SWIFT_HOST_VARIANT_SDK STREQUAL CYGWIN)
464-
set_target_properties(${name}
465-
PROPERTIES
462+
set_target_properties(${name} PROPERTIES
466463
INSTALL_RPATH "$ORIGIN:/usr/lib/swift/cygwin")
467464
elseif(SWIFT_HOST_VARIANT_SDK STREQUAL "ANDROID")
468-
set_target_properties(${name}
469-
PROPERTIES
465+
set_target_properties(${name} PROPERTIES
470466
INSTALL_RPATH "$ORIGIN")
471467
endif()
472468

include/swift/AST/IRGenOptions.h

-9
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@ enum class IRGenDebugInfoFormat : unsigned {
6565
CodeView
6666
};
6767

68-
enum class IRGenLLVMLTOKind : unsigned {
69-
None,
70-
Thin,
71-
Full
72-
};
73-
7468
enum class IRGenEmbedMode : unsigned {
7569
None,
7670
EmbedMarker,
@@ -223,8 +217,6 @@ class IRGenOptions {
223217
/// Whether we should embed the bitcode file.
224218
IRGenEmbedMode EmbedMode : 2;
225219

226-
IRGenLLVMLTOKind LLVMLTOKind: 2;
227-
228220
/// Add names to LLVM values.
229221
unsigned HasValueNamesSetting : 1;
230222
unsigned ValueNames : 1;
@@ -326,7 +318,6 @@ class IRGenOptions {
326318
DisableSwiftSpecificLLVMOptzns(false), DisableLLVMSLPVectorizer(false),
327319
Playground(false), EmitStackPromotionChecks(false),
328320
FunctionSections(false), PrintInlineTree(false), EmbedMode(IRGenEmbedMode::None),
329-
LLVMLTOKind(IRGenLLVMLTOKind::None),
330321
HasValueNamesSetting(false), ValueNames(false),
331322
EnableReflectionMetadata(true), EnableReflectionNames(true),
332323
EnableAnonymousContextMangledNames(false), ForcePublicLinkage(false),

include/swift/Driver/Action.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -328,19 +328,16 @@ class GeneratePCHJobAction : public JobAction {
328328
class DynamicLinkJobAction : public JobAction {
329329
virtual void anchor();
330330
LinkKind Kind;
331-
bool LTO;
332331

333332
public:
334-
DynamicLinkJobAction(ArrayRef<const Action *> Inputs, LinkKind K, bool LTO)
333+
DynamicLinkJobAction(ArrayRef<const Action *> Inputs, LinkKind K)
335334
: JobAction(Action::Kind::DynamicLinkJob, Inputs, file_types::TY_Image),
336-
Kind(K), LTO(LTO) {
335+
Kind(K) {
337336
assert(Kind != LinkKind::None && Kind != LinkKind::StaticLibrary);
338337
}
339338

340339
LinkKind getKind() const { return Kind; }
341340

342-
bool PerformLTO() const { return LTO; }
343-
344341
static bool classof(const Action *A) {
345342
return A->getKind() == Action::Kind::DynamicLinkJob;
346343
}

include/swift/Driver/Driver.h

-8
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,6 @@ class OutputInfo {
101101
/// The output type which should be used for compile actions.
102102
file_types::ID CompilerOutputType = file_types::ID::TY_INVALID;
103103

104-
enum class LTOKind {
105-
None,
106-
LLVMThin,
107-
LLVMFull,
108-
};
109-
110-
LTOKind LTOVariant = LTOKind::None;
111-
112104
/// Describes if and how the output of compile actions should be
113105
/// linked together.
114106
LinkKind LinkAction = LinkKind::None;

include/swift/Option/Options.td

-4
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,6 @@ def disable_bridging_pch : Flag<["-"], "disable-bridging-pch">,
515515
Flags<[HelpHidden]>,
516516
HelpText<"Disable automatic generation of bridging PCH files">;
517517

518-
def lto : Joined<["-"], "lto=">,
519-
Flags<[FrontendOption, NoInteractiveOption]>,
520-
HelpText<"Specify the LTO type to either 'llvm' or 'llvm-full'">;
521-
522518
// Experimental feature options
523519

524520
// Note: this flag will be removed when JVP/differential generation in the

lib/Driver/DarwinToolChains.cpp

+2-26
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,12 @@ toolchains::Darwin::addLinkerInputArgs(InvocationInfo &II,
238238
Arguments.push_back("-filelist");
239239
Arguments.push_back(context.getTemporaryFilePath("inputs", "LinkFileList"));
240240
II.FilelistInfos.push_back(
241-
{Arguments.back(), context.OI.CompilerOutputType,
241+
{Arguments.back(), file_types::TY_Object,
242242
FilelistInfo::WhichFiles::InputJobsAndSourceInputActions});
243243
} else {
244244
addPrimaryInputsOfType(Arguments, context.Inputs, context.Args,
245245
file_types::TY_Object);
246-
addPrimaryInputsOfType(Arguments, context.Inputs, context.Args,
247-
file_types::TY_LLVM_BC);
248246
addInputsOfType(Arguments, context.InputActions, file_types::TY_Object);
249-
addInputsOfType(Arguments, context.InputActions, file_types::TY_LLVM_BC);
250247
}
251248

252249

@@ -309,20 +306,6 @@ toolchains::Darwin::addArgsToLinkARCLite(ArgStringList &Arguments,
309306
}
310307
}
311308

312-
void
313-
toolchains::Darwin::addLTOLibArgs(ArgStringList &Arguments,
314-
const JobContext &context) const {
315-
llvm::SmallString<128> LTOLibPath;
316-
if (findXcodeClangPath(LTOLibPath)) {
317-
llvm::sys::path::remove_filename(LTOLibPath); // 'clang'
318-
llvm::sys::path::remove_filename(LTOLibPath); // 'bin'
319-
llvm::sys::path::append(LTOLibPath, "lib", "libLTO.dylib");
320-
321-
Arguments.push_back("-lto_library");
322-
Arguments.push_back(context.Args.MakeArgString(LTOLibPath));
323-
}
324-
}
325-
326309
void
327310
toolchains::Darwin::addSanitizerArgs(ArgStringList &Arguments,
328311
const DynamicLinkJobAction &job,
@@ -740,10 +723,6 @@ toolchains::Darwin::constructInvocation(const DynamicLinkJobAction &job,
740723

741724
addArgsToLinkARCLite(Arguments, context);
742725

743-
if (job.PerformLTO()) {
744-
addLTOLibArgs(Arguments, context);
745-
}
746-
747726
for (const Arg *arg :
748727
context.Args.filtered(options::OPT_F, options::OPT_Fsystem)) {
749728
Arguments.push_back("-F");
@@ -811,17 +790,14 @@ toolchains::Darwin::constructInvocation(const StaticLinkJobAction &job,
811790
if (context.shouldUseInputFileList()) {
812791
Arguments.push_back("-filelist");
813792
Arguments.push_back(context.getTemporaryFilePath("inputs", "LinkFileList"));
814-
II.FilelistInfos.push_back({Arguments.back(), context.OI.CompilerOutputType,
793+
II.FilelistInfos.push_back({Arguments.back(), file_types::TY_Object,
815794
FilelistInfo::WhichFiles::InputJobs});
816795
} else {
817796
addPrimaryInputsOfType(Arguments, context.Inputs, context.Args,
818797
file_types::TY_Object);
819-
addPrimaryInputsOfType(Arguments, context.Inputs, context.Args,
820-
file_types::TY_LLVM_BC);
821798
}
822799

823800
addInputsOfType(Arguments, context.InputActions, file_types::TY_Object);
824-
addInputsOfType(Arguments, context.InputActions, file_types::TY_LLVM_BC);
825801

826802
Arguments.push_back("-o");
827803

lib/Driver/Driver.cpp

+7-24
Original file line numberDiff line numberDiff line change
@@ -1413,15 +1413,12 @@ static bool isSDKTooOld(StringRef sdkPath, const llvm::Triple &target) {
14131413
void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,
14141414
const bool BatchMode, const InputFileList &Inputs,
14151415
OutputInfo &OI) const {
1416-
auto LinkerInputType = Args.hasArg(options::OPT_lto)
1417-
? file_types::TY_LLVM_BC
1418-
: file_types::TY_Object;
14191416
// By default, the driver does not link its output; this will be updated
14201417
// appropriately below if linking is required.
14211418

14221419
OI.CompilerOutputType = driverKind == DriverKind::Interactive
14231420
? file_types::TY_Nothing
1424-
: LinkerInputType;
1421+
: file_types::TY_Object;
14251422

14261423
if (const Arg *A = Args.getLastArg(options::OPT_num_threads)) {
14271424
if (BatchMode) {
@@ -1451,14 +1448,14 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,
14511448
diag::error_static_emit_executable_disallowed);
14521449

14531450
OI.LinkAction = LinkKind::Executable;
1454-
OI.CompilerOutputType = LinkerInputType;
1451+
OI.CompilerOutputType = file_types::TY_Object;
14551452
break;
14561453

14571454
case options::OPT_emit_library:
14581455
OI.LinkAction = Args.hasArg(options::OPT_static) ?
14591456
LinkKind::StaticLibrary :
14601457
LinkKind::DynamicLibrary;
1461-
OI.CompilerOutputType = LinkerInputType;
1458+
OI.CompilerOutputType = file_types::TY_Object;
14621459
break;
14631460

14641461
case options::OPT_static:
@@ -1768,18 +1765,6 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,
17681765

17691766
}
17701767

1771-
if (const Arg *A = Args.getLastArg(options::OPT_lto)) {
1772-
auto LTOVariant = llvm::StringSwitch<Optional<OutputInfo::LTOKind>>(A->getValue())
1773-
.Case("llvm", OutputInfo::LTOKind::LLVMThin)
1774-
.Case("llvm-full", OutputInfo::LTOKind::LLVMFull)
1775-
.Default(llvm::None);
1776-
if (LTOVariant)
1777-
OI.LTOVariant = LTOVariant.getValue();
1778-
else
1779-
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
1780-
A->getAsString(Args), A->getValue());
1781-
}
1782-
17831768
if (TC.getTriple().isOSWindows()) {
17841769
if (const Arg *A = Args.getLastArg(options::OPT_libc)) {
17851770
OI.RuntimeVariant =
@@ -2114,17 +2099,15 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
21142099
MergeModuleAction = C.createAction<MergeModuleJobAction>(AllModuleInputs);
21152100
}
21162101

2117-
auto PerformLTO = Args.hasArg(options::OPT_lto);
21182102
if (OI.shouldLink() && !AllLinkerInputs.empty()) {
21192103
JobAction *LinkAction = nullptr;
21202104

21212105
if (OI.LinkAction == LinkKind::StaticLibrary) {
21222106
LinkAction = C.createAction<StaticLinkJobAction>(AllLinkerInputs,
2123-
OI.LinkAction);
2107+
OI.LinkAction);
21242108
} else {
21252109
LinkAction = C.createAction<DynamicLinkJobAction>(AllLinkerInputs,
2126-
OI.LinkAction,
2127-
PerformLTO);
2110+
OI.LinkAction);
21282111
}
21292112

21302113
// On ELF platforms there's no built in autolinking mechanism, so we
@@ -2133,7 +2116,7 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
21332116
const auto &Triple = TC.getTriple();
21342117
SmallVector<const Action *, 2> AutolinkExtractInputs;
21352118
for (const Action *A : AllLinkerInputs)
2136-
if (A->getType() == OI.CompilerOutputType) {
2119+
if (A->getType() == file_types::TY_Object) {
21372120
// Shared objects on ELF platforms don't have a swift1_autolink_entries
21382121
// section in them because the section in the .o files is marked as
21392122
// SHF_EXCLUDE.
@@ -2149,7 +2132,7 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
21492132
(Triple.getObjectFormat() == llvm::Triple::ELF && !Triple.isPS4()) ||
21502133
Triple.getObjectFormat() == llvm::Triple::Wasm ||
21512134
Triple.isOSCygMing();
2152-
if (!AutolinkExtractInputs.empty() && AutolinkExtractRequired && !PerformLTO) {
2135+
if (!AutolinkExtractInputs.empty() && AutolinkExtractRequired) {
21532136
auto *AutolinkExtractAction =
21542137
C.createAction<AutolinkExtractJobAction>(AutolinkExtractInputs);
21552138
// Takes the same inputs as the linker...

lib/Driver/ToolChains.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -518,11 +518,6 @@ ToolChain::constructInvocation(const CompileJobAction &job,
518518
Arguments.push_back("-track-system-dependencies");
519519
}
520520

521-
if (auto arg = context.Args.getLastArg(options::OPT_lto)) {
522-
Arguments.push_back(context.Args.MakeArgString(
523-
Twine("-lto=") + arg->getValue()));
524-
}
525-
526521
context.Args.AddLastArg(
527522
Arguments,
528523
options::

lib/Driver/ToolChains.h

-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public ToolChain {
4848
void addDeploymentTargetArgs(llvm::opt::ArgStringList &Arguments,
4949
const JobContext &context) const;
5050

51-
void addLTOLibArgs(llvm::opt::ArgStringList &Arguments,
52-
const JobContext &context) const;
53-
5451
void addCommonFrontendArgs(
5552
const OutputInfo &OI, const CommandOutput &output,
5653
const llvm::opt::ArgList &inputArgs,

lib/Driver/UnixToolChains.cpp

+1-25
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ ToolChain::InvocationInfo toolchains::GenericUnix::constructInvocation(
7272

7373
addPrimaryInputsOfType(Arguments, context.Inputs, context.Args,
7474
file_types::TY_Object);
75-
addPrimaryInputsOfType(Arguments, context.Inputs, context.Args,
76-
file_types::TY_LLVM_BC);
7775
addInputsOfType(Arguments, context.InputActions, file_types::TY_Object);
78-
addInputsOfType(Arguments, context.InputActions, file_types::TY_LLVM_BC);
7976

8077
Arguments.push_back("-o");
8178
Arguments.push_back(
@@ -170,9 +167,6 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,
170167
std::string Linker;
171168
if (const Arg *A = context.Args.getLastArg(options::OPT_use_ld)) {
172169
Linker = A->getValue();
173-
} else if (context.OI.LTOVariant != OutputInfo::LTOKind::None) {
174-
// Force to use lld for LTO
175-
Linker = "lld";
176170
} else {
177171
Linker = getDefaultLinker();
178172
}
@@ -224,16 +218,6 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,
224218
Arguments.push_back("-pie");
225219
}
226220

227-
switch (context.OI.LTOVariant) {
228-
case OutputInfo::LTOKind::LLVMThin:
229-
Arguments.push_back("-flto=thin");
230-
break;
231-
case OutputInfo::LTOKind::LLVMFull:
232-
Arguments.push_back("-flto=full");
233-
break;
234-
case OutputInfo::LTOKind::None: break;
235-
}
236-
237221
bool staticExecutable = false;
238222
bool staticStdlib = false;
239223

@@ -269,11 +253,7 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,
269253

270254
addPrimaryInputsOfType(Arguments, context.Inputs, context.Args,
271255
file_types::TY_Object);
272-
addPrimaryInputsOfType(Arguments, context.Inputs, context.Args,
273-
file_types::TY_LLVM_BC);
274256
addInputsOfType(Arguments, context.InputActions, file_types::TY_Object);
275-
addInputsOfType(Arguments, context.InputActions, file_types::TY_LLVM_BC);
276-
277257

278258
for (const Arg *arg :
279259
context.Args.filtered(options::OPT_F, options::OPT_Fsystem)) {
@@ -388,19 +368,15 @@ toolchains::GenericUnix::constructInvocation(const StaticLinkJobAction &job,
388368
ArgStringList Arguments;
389369

390370
// Configure the toolchain.
391-
const char *AR = "llvm-ar";
371+
const char *AR = "ar";
392372
Arguments.push_back("crs");
393373

394374
Arguments.push_back(
395375
context.Args.MakeArgString(context.Output.getPrimaryOutputFilename()));
396376

397377
addPrimaryInputsOfType(Arguments, context.Inputs, context.Args,
398378
file_types::TY_Object);
399-
addPrimaryInputsOfType(Arguments, context.Inputs, context.Args,
400-
file_types::TY_LLVM_BC);
401379
addInputsOfType(Arguments, context.InputActions, file_types::TY_Object);
402-
addInputsOfType(Arguments, context.InputActions, file_types::TY_LLVM_BC);
403-
404380

405381
InvocationInfo II{AR, Arguments};
406382

0 commit comments

Comments
 (0)