Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-3352] Warn on and ignore -embed-bitcode when not generating object files #45940

Closed
belkadan opened this issue Dec 6, 2016 · 3 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself good first issue Good for newcomers legacy driver Area → compiler: the integrated C++ legacy driver. Succeeded by the swift-driver project

Comments

@belkadan
Copy link
Contributor

belkadan commented Dec 6, 2016

Previous ID SR-3352
Radar None
Original Reporter @belkadan
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Driver, StarterBug
Assignee @keith
Priority Medium

md5: 9140b720d1107baec125ae5ce3d322bb

Issue Description:

Certain commands to swiftc, like -emit-sil and (when on its own) -emit-module, don't actually emit any object files. In these cases, trying to use -embed-bitcode results in the driver getting very confused and trying to run a backend job to generate a module. We should instead ignore -embed-bitcode when no object files are being generated.

@modocache
Copy link
Mannequin

modocache mannequin commented Oct 4, 2017

Adding warning diagnostics for invalid or otherwise unsavory combinations of driver options, and modifying what the driver does when presented with those options, can be accomplished, I think, by modifying lib/Driver/Driver.cpp's validateArgs function, or by modifying the Driver::buildCompilation method, similar to how that method checks for invalid combinations of the -incremental option.

There's a lot of prior art in that file that new contributors could look at, so I think this can be marked as a "starter bug".

Note, however, that anyone who wishes to pick up this task should first check that swiftc still exhibits this behavior. I presume this can be done by running swiftc -emit-sil -embed-bitcode foo.swift, or something.

@modocache
Copy link
Mannequin

modocache mannequin commented Oct 4, 2017

Ah, actually, I believe this is already done:

swift/lib/Driver/Driver.cpp

Lines 494 to 502 in c1a4bb4

// warn if -embed-bitcode is set and the output type is not an object
static void validateEmbedBitcode(DerivedArgList &Args, OutputInfo &OI,
DiagnosticEngine &Diags) {
if (Args.hasArg(options::OPT_embed_bitcode) &&
OI.CompilerOutputType != types::TY_Object) {
Diags.diagnose(SourceLoc(), diag::warn_ignore_embed_bitcode);
Args.eraseArg(options::OPT_embed_bitcode);
}
}

Someone should double-check the issue doesn't reproduce, or check whether there's a test, and close this issue.

@keith
Copy link
Collaborator

keith commented Jul 27, 2018

Confirmed that this does warn now:

% ./bin/swiftc -emit-sil -embed-bitcode /tmp/foo.swift
<unknown>:0: warning: ignoring -embed-bitcode since no object file is being generated

But this did not have the same behavior with `-embed-bitcode-marker`. I've submitted a PR adding that here: #18304

Now the behavior is:

% ./bin/swiftc -emit-sil -embed-bitcode-marker /tmp/foo.swift
<unknown>:0: warning: ignoring -embed-bitcode-marker since no object file is being generated

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself good first issue Good for newcomers legacy driver Area → compiler: the integrated C++ legacy driver. Succeeded by the swift-driver project
Projects
None yet
Development

No branches or pull requests

2 participants