Skip to content

Build simplification making sanitizer builds work on android - #3688

Merged
bjacob merged 1 commit into
iree-org:mainfrom
bjacob:more-asan
Nov 2, 2020
Merged

bjacob merged 1 commit into
iree-org:mainfrom
bjacob:more-asan

Conversation

@bjacob

@bjacob bjacob commented Nov 2, 2020

Copy link
Copy Markdown
Collaborator
  1. Don't add IREE_DEFAULT_COPTS to CMake's global compiler flags.
    This was apparently a recent change not fitting with the
    intended purpose of IREE_DEFAULT_COPTS, which is to populate
    the default copts of iree_cc_* bazel-ish rules.

In effect, this means that IREE_DEFAULT_COPTS only affects
IREE code and not e.g. third_party code.

I needed to change
this now because when building with ASan, this caused
third_party/llvm-project to build with -fsanitize=address,
however on Android we also need to pass a linker flag for
that to work, and that wan't being passed to the LLVM
build, making it fail.

  1. Don't check for compiler support for -fsanitize= flags.
    If the user explicitly enables a sanitizer, just use it.
    This only makes a difference to the error message, should
    not make any change to what succeeds/fails.

Again, I needed to make that change now because of the
need to pass a linker flag on Android, which there was
no way to pass to this CMake compiler-support-check macro.

1. Don't add IREE_DEFAULT_COPTS to CMake's global compiler flags.
  This was apparently a recent change not fitting with the
  intended purpose of IREE_DEFAULT_COPTS, which is to populate
  the default copts of iree_cc_* bazel-ish rules.

  In effect, this means that IREE_DEFAULT_COPTS only affects
  IREE code and not e.g. third_party code.

  I needed to change
  this now because when building with ASan, this caused
  third_party/llvm-project to build with -fsanitize=address,
  however on Android we also need to pass a linker flag for
  that to work, and that wan't being passed to the LLVM
  build, making it fail.

2. Don't check for compiler support for -fsanitize= flags.
  If the user explicitly enables a sanitizer, just use it.
  This only makes a difference to the error message, should
  not make any change to what succeeds/fails.

  Again, I needed to make that change now because of the
  need to pass a linker flag on Android, which there was
  no way to pass to this CMake compiler-support-check macro.
@bjacob
bjacob requested a review from antiagainst November 2, 2020 20:19
@google-cla google-cla Bot added the cla: yes label Nov 2, 2020
@bjacob
bjacob requested review from ScottTodd and benvanik November 2, 2020 20:19
@ScottTodd ScottTodd added the cmake label Nov 2, 2020
Comment on lines -152 to -153
message(FATAL_ERROR "The compiler does not support address sanitizer "
"or is missing configuration for address sanitizer")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't check for compiler support for -fsanitize= flags.
If the user explicitly enables a sanitizer, just use it.
This only makes a difference to the error message, should
not make any change to what succeeds/fails.

Part of this error check was meant to give a more useful message on MSVC where different flags might be used: #2832 (comment). However, from another look at https://devblogs.microsoft.com/cppblog/addresssanitizer-asan-for-windows-with-msvc/ and https://devblogs.microsoft.com/cppblog/asan-for-windows-x64-and-debug-build-support/, it looks like the same flag is used.

@bjacob
bjacob merged commit 1901a9f into iree-org:main Nov 2, 2020
@hanhanW hanhanW mentioned this pull request Nov 3, 2020
@GMNGeoffrey GMNGeoffrey added the infrastructure Relating to build systems, CI, or testing label May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infrastructure Relating to build systems, CI, or testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants