Skip to content

[ClangImporter] Don't pass API notes options when compiling bitcode. #10425

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,23 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
"-Xclang", "-fmodule-format=obj",
});
}

// Enable API notes alongside headers/in frameworks.
invocationArgStrs.push_back("-fapinotes-modules");

// Add API notes paths.
for (const auto &searchPath : searchPathOpts.ImportSearchPaths) {
invocationArgStrs.push_back("-iapinotes-modules");
invocationArgStrs.push_back(searchPath);
}
invocationArgStrs.push_back("-iapinotes-modules");
invocationArgStrs.push_back(searchPathOpts.RuntimeLibraryImportPath);

// Map the Swift major version into the API notes version for Swift. This
// has the effect of allowing API notes to effect changes only on Swift
// major versions, not minor versions.
invocationArgStrs.push_back("-fapinotes-swift-version=" +
llvm::itostr(languageVersion[0]));
}

static void
Expand Down Expand Up @@ -691,23 +708,6 @@ addCommonInvocationArguments(std::vector<std::string> &invocationArgStrs,
for (auto extraArg : importerOpts.ExtraArgs) {
invocationArgStrs.push_back(extraArg);
}

// Enable API notes alongside headers/in frameworks.
invocationArgStrs.push_back("-fapinotes-modules");

// Add API notes paths.
for (const auto &searchPath : searchPathOpts.ImportSearchPaths) {
invocationArgStrs.push_back("-iapinotes-modules");
invocationArgStrs.push_back(searchPath);
}
invocationArgStrs.push_back("-iapinotes-modules");
invocationArgStrs.push_back(searchPathOpts.RuntimeLibraryImportPath);

// Map the Swift major version into the API notes version for Swift. This
// has the effect of allowing API notes to effect changes only on Swift
// major versions, not minor versions.
invocationArgStrs.push_back("-fapinotes-swift-version=" +
llvm::itostr(ctx.LangOpts.EffectiveLanguageVersion[0]));
}

bool ClangImporter::canReadPCH(StringRef PCHFilename) {
Expand Down
1 change: 1 addition & 0 deletions test/Frontend/embed-bitcode.ll
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
; CHECK-IMPORTER: clang
; CHECK-IMPORTER: -fembed-bitcode
; CHECK-IMPORTER: -target
; CHECK-IMPORTER-NOT: argument unused

define i32 @f0() nounwind ssp {
ret i32 0
Expand Down