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

Add IS_CXX option to sanitizer cmake module #1135

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sfod
Copy link
Contributor

@sfod sfod commented Jul 15, 2024

Issue #, if available:

aws_check_sanitizer checks for the sanitizer flags using check_c_compiler_flag. However, for C++ projects C language could be not enabled, which leads to the following error:

CMake Error at /usr/share/cmake3/Modules/CheckCSourceCompiles.cmake:109 (try_compile):
  Unknown extension ".c" for file
    aws-iot-device-sdk-cpp-v2/samples/mqtt5/mqtt5_pubsub/cmake-build-tsan/CMakeFiles/CMakeTmp/src.c
  try_compile() works only for enabled languages.  Currently these are:
    CXX
  See project() command to enable other languages.

A possible solution could be to add enable_language(C) before calling check_c_compiler_flag. But I'm not sure that C++ and C compilers have the same set of the sanitizer options. And even if they do currently, this might change.

So, using check_cxx_compiler_flag for C++ project looks like a more correct approach.

Description of changes:

Add IS_CXX option to aws_check_sanitizer and aws_add_sanitizers CMake functions.
This change does not break or change the existing usages of these functions.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-commenter
Copy link

codecov-commenter commented Jul 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.44%. Comparing base (852f8ce) to head (440b05a).
Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1135   +/-   ##
=======================================
  Coverage   83.44%   83.44%           
=======================================
  Files          57       57           
  Lines        5985     5985           
=======================================
  Hits         4994     4994           
  Misses        991      991           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants