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-9884] -sanitize-coverage option cannot be used without a -sanitizer enabled #52290

Open
swift-ci opened this issue Feb 7, 2019 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Feb 7, 2019

Previous ID SR-9884
Radar None
Original Reporter loic (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: ea11db8a811c0ec5228af1bd74dfc0a7

Issue Description:

Currently, it is not possible to instrument Swift code with `-sanitize-coverage` without attaching one of the sanitizer runtime (`address`, `fuzzer`, etc.). This prevents writing Swift programs that make use of that instrumentation, such as code coverage analysis tools or fuzzing engines.

It seems like the reason for this limitation is to make the command line `swiftc` tool more user-friendly. From the source code at `lib/Options/SanitizerOptions.cpp`, line 112:

 // Running the sanitizer coverage pass will add undefined symbols to
  // functions in compiler-rt's "sanitizer_common". "sanitizer_common" isn't
  // shipped as a separate library we can link with. However those are defined
  // in the various sanitizer runtime libraries so we require that we are
  // doing a sanitized build so we pick up the required functions during
  // linking.
  if (opts.CoverageType != llvm::SanitizerCoverageOptions::SCK_None &&
      !sanitizers) {
    Diags.diagnose(SourceLoc(), diag::error_option_requires_sanitizer,
                   A->getSpelling());
    return llvm::SanitizerCoverageOptions();
  }

It would be great if that check could be removed, or be replaced with a warning instead of an error.

@belkadan
Copy link
Contributor

belkadan commented Feb 8, 2019

cc @devincoughlin

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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
Projects
None yet
Development

No branches or pull requests

2 participants