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

Fix macOS Clang and GCC build on macOS #1589

Merged
merged 1 commit into from
Apr 10, 2019
Merged

Fix macOS Clang and GCC build on macOS #1589

merged 1 commit into from
Apr 10, 2019

Conversation

torfinnberset
Copy link
Contributor

Description

Catch2 was not able to compile with GCC or Clang on macOS.

This is done by forcing isDebuggerActive() to false when building Catch2 on macOS with Clang or GCC. When building with AppleClang, isDebuggerActive() will function as before.

GitHub Issues

Closes #1588

@codecov
Copy link

codecov bot commented Apr 5, 2019

Codecov Report

Merging #1589 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #1589   +/-   ##
=======================================
  Coverage   80.72%   80.72%           
=======================================
  Files         121      121           
  Lines        3423     3423           
=======================================
  Hits         2763     2763           
  Misses        660      660

@horenmar
Copy link
Member

horenmar commented Apr 5, 2019

That does not look quite right. Going by the error in #1588, the problem is that the headers end up transitively including <stdatomic.h>, which GCC is known to fail on. However, by most accounts, Clang should support the _Atomic keyword in C++ mode as well (it is a language extension, but useful one).

This leads me to ask, are you sure that the compilation fails with Clang as well?

See also

@torfinnberset
Copy link
Contributor Author

torfinnberset commented Apr 8, 2019

@horenmar I'm pretty certain the Clang 8.0 compiler bundled with homebrew fails for this. The CMake output shows the expected detected name and version number etc:

-- The CXX compiler identification is Clang 8.0.0
-- The C compiler identification is Clang 8.0.0
-- The ASM compiler identification is Clang
-- Found assembler: /usr/local/Cellar/llvm/8.0.0/bin/clang
-- Check for working CXX compiler: /usr/local/Cellar/llvm/8.0.0/bin/clang++
-- Check for working CXX compiler: /usr/local/Cellar/llvm/8.0.0/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/local/Cellar/llvm/8.0.0/bin/clang
-- Check for working C compiler: /usr/local/Cellar/llvm/8.0.0/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done

But, to be more defensive, maybe we can change the guard to this: #if defined(__apple_build_version__) || __has_feature(c_atomic) ? Then it should still use this function if c_atomics are available for that compiler. Maybe it also has something with the stdlib that clang uses (might be using the gcc one?)

@horenmar
Copy link
Member

On further thought, I am going to merge it as is, and if someone has a use case for C-atomics enabled non-Apple clang, they can open up another PR to fix it.

Thanks.

@horenmar horenmar merged commit 5ce355a into catchorg:master Apr 10, 2019
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.

2 participants