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 compilation on macOS with GCC. #1603

Merged
merged 1 commit into from
Mar 20, 2025

Conversation

Jhuighuy
Copy link
Contributor

@Jhuighuy Jhuighuy commented Jan 14, 2025

Description

This PR fixes compilation on macOS with GCC (broken in 2022.0, worked fine in 2021.13). What's changed:

  • GCC toolchain code assumed that the assembler is always GAS. This may not always be the case, for example, on macOS GCC uses LLVM assembler.
  • Changed __TBB_WAITPKG_INTRINSICS_PRESENT: it is now always defined to true on macOS and GCC (always fresh LLVM assembler, so the intrinsic is always present).
  • Changed a workaround for -Wdeprecated-declarations in co_context.h: the warning was disabled with a Clang-specific pragma, replaced with Clang-compatible GCC version.

With this changes it is possible to compile and run all tests:

$ mkdir build
$ cd build
$ CXX=g++-14 cmake .. -DBUILD_SHARED_LIBS=NO
$ make
$ make test

Compilation with BUILD_SHARED_LIBS=YES still fails: the linker cannot find a vtable for detail::r1::unsafe_wait. This should be fixed separately.

Fixes #1556

Type of change

  • bug fix - change that fixes an issue
  • new feature - change that adds functionality
  • tests - change in tests
  • infrastructure - change in infrastructure and CI
  • documentation - documentation update

Tests

  • added - required for new features and some bug fixes
  • not needed

Documentation

  • updated in # - add PR number
  • needs to be updated
  • not needed

Breaks backward compatibility

  • Yes
  • No
  • Unknown

Notify the following users

Other information

@Jhuighuy Jhuighuy force-pushed the fix-gcc-without-gas branch from c7476ac to a245e48 Compare January 15, 2025 00:38
@Jhuighuy
Copy link
Contributor Author

Updated copyright years.

@saschasc
Copy link

What is the status? Currently, I am blocked updating to 2022.0 on macOS.

@dnmokhov
Copy link
Contributor

I am blocked updating to 2022.0 on macOS.

@saschasc, feel free to use -DTBB_STRICT=OFF (cmake/README.md).

@dnmokhov dnmokhov requested a review from isaevil March 19, 2025 14:38
@dnmokhov
Copy link
Contributor

Sorry. I realized there is more to this than disabling the warnings. We will review this pull request,

Comment on lines +46 to +48
#elif __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is __GNUC__ macro really predefined when using Apple Clang? Shouldn't we still have "elif __clang__"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, __GNUC__ is defined.

$ /usr/bin/clang --version
Apple clang version 16.0.0 (clang-1600.0.26.6)
Target: arm64-apple-darwin24.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ cat ./a.cpp
#ifdef __GNUC__
#error __GNUC__ is defined.
#endif
$ /usr/bin/clang ./a.cpp
./a.cpp:2:2: error: __GNUC__ is defined.
    2 | #error __GNUC__ is defined.
      |  ^
1 error generated.

Copy link
Contributor Author

@Jhuighuy Jhuighuy Mar 19, 2025

Choose a reason for hiding this comment

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

I've checked the CI, it is using Apple Clang.

@saschasc
Copy link

saschasc commented Mar 19, 2025

I am blocked updating to 2022.0 on macOS.

@saschasc, feel free to use -DTBB_STRICT=OFF (cmake/README.md).

I am using the Conan version and right now switching back to the older one. Happy if this gets fixed for the next version. Thank you!

Copy link
Contributor

@isaevil isaevil left a comment

Choose a reason for hiding this comment

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

LGTM

@isaevil isaevil merged commit 34e7495 into uxlfoundation:master Mar 20, 2025
25 checks passed
@Jhuighuy Jhuighuy deleted the fix-gcc-without-gas branch March 20, 2025 14:03
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.

Cannot configure on macOS with GCC.
4 participants