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

Missing C++ Standard Library Headers When Building Wheels On Mac #409

Open
pb-dod opened this issue Apr 9, 2024 · 4 comments · May be fixed by #580
Open

Missing C++ Standard Library Headers When Building Wheels On Mac #409

pb-dod opened this issue Apr 9, 2024 · 4 comments · May be fixed by #580
Assignees
Labels
Area: Report Upload Issues with pre-ingest report uploading bug Something isn't working Low Low Priority Issues (to be fixed or re-evaluated in 12 months

Comments

@pb-dod
Copy link

pb-dod commented Apr 9, 2024

Description

I've encountered a build failure on MacOS when attempting to pip install codecov-cli, which compiles these C++ components due to the lack of a pre-built wheel: https://github.com/codecov/codecov-cli/blob/v0.5.0/setup.py#L34-L54

The specific error indicates that the <vector> header file from the C++ Standard Library cannot be found, along with other C++ specific dependencies.

Error Details

The error message received during the wheel build process is as follows:

fatal error: 'vector' file not found
#include <vector>
         ^~~~~~~~

This suggests that the build environment is not correctly configured to locate the C++ standard library headers required for compilation.

Environment

OS: MacOS

This setup seems to work:

 $ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: arm64-apple-darwin21.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Here's an example of a broken setup (no mention of c++):

 $ gcc --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Steps to Reproduce

  1. pip install codecov-cli from a machine without a version of CommandLineTools that includes the required C++ dependencies .
  2. Observe the failure during the wheel-building step with the error message indicating the missing <vector> header.

Resolution Steps

I performed the following steps to resolve the issue:

  1. Completely removed the existing Command Line Tools using the command:

    sudo rm -rf /Library/Developer/CommandLineTools
  2. Reinstalled the Command Line Tools by invoking:

    xcode-select --install

The fresh installation of the Command Line Tools seems to include the necessary C++ compiler and standard library headers.

Question

Is there any easier way to prevent this issue without requiring a reinstall of xcode Command Line Tools?

Do I need to start enforcing a minimum version of xcode on developer machines? Or is there work in progress to get a working wheel file?

In setup.py, should the language='c++' be set for the Extension to explicitly require a working C++ compiler?

@thomasrockhu-codecov thomasrockhu-codecov added the bug Something isn't working label Apr 16, 2024
@thomasrockhu-codecov
Copy link
Contributor

Hi @pb-dod, apologies this took so long. We've made a lot of improvements to the CLI since this issue was opened. Is this still an issue?

@thomasrockhu-codecov thomasrockhu-codecov self-assigned this Oct 10, 2024
@thomasrockhu-codecov thomasrockhu-codecov added Low Low Priority Issues (to be fixed or re-evaluated in 12 months Area: Report Upload Issues with pre-ingest report uploading labels Oct 10, 2024
@pb-dod
Copy link
Author

pb-dod commented Dec 18, 2024

@thomasrockhu-codecov yes, we're still having issues with this and we've learned that clang 16.0.0 is a hard requirement if it needs to build from source on MacOS:

clang --version
Apple clang version 16.0.0 (clang-1600.0.26.6)

Have also learned sometimes there's an additional step to updating the xcode CLI tools (sometimes it's pointing to the wrong path of the old version still and that needs to be reset):

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

# additional step \/
sudo xcode-select --reset

Maybe there needs to be a note about this here?: https://github.com/codecov/codecov-cli?tab=readme-ov-file#dependencies

@thomasrockhu-codecov
Copy link
Contributor

@pb-dod thanks for the reply back! I'll take a look into adding this in, thanks for finding that

@pb-dod pb-dod linked a pull request Dec 18, 2024 that will close this issue
2 tasks
@pb-dod
Copy link
Author

pb-dod commented Dec 19, 2024

we've learned that clang 16.0.0 is a hard requirement

Actually clang version isn't all you need to know, because it also matters which CommandLineTools SDK version you're using. 15.2 seems to work for sure, but 14.5 does not and will throw errors while compiling.

You can check this with:

$ xcrun --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

And by seeing which SDK that's symlinked to here (15.2 in this case):

$ ls -l /Library/Developer/CommandLineTools/SDKs/

total 0
lrwxr-xr-x  1 root  wheel   14 Dec 12 18:54 MacOSX.sdk -> MacOSX15.2.sdk
drwxr-xr-x  7 root  wheel  224 Nov 19  2021 MacOSX12.1.sdk
drwxr-xr-x  7 root  wheel  224 May 12  2023 MacOSX13.3.sdk
lrwxr-xr-x  1 root  wheel   14 Dec 12 18:51 MacOSX13.sdk -> MacOSX13.3.sdk
drwxr-xr-x  7 root  wheel  224 Feb 19  2024 MacOSX14.4.sdk
drwxr-xr-x  7 root  wheel  224 Apr 30  2024 MacOSX14.5.sdk
lrwxr-xr-x  1 root  wheel   14 Dec 12 18:53 MacOSX14.sdk -> MacOSX14.5.sdk
drwxr-xr-x  7 root  wheel  224 Nov 21 02:05 MacOSX15.2.sdk
lrwxr-xr-x  1 root  wheel   14 Dec 12 18:52 MacOSX15.sdk -> MacOSX15.2.sdk

We had one dev who had an app called "xcodes" for switching xcode versions and it made xcrun --show-sdk-path show:

/Library/Developer/CommandLineTools/SDKs/MacOSX14.5.sdk

And he had to change the xcode version in xcodes to get it to use the more recent SDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Report Upload Issues with pre-ingest report uploading bug Something isn't working Low Low Priority Issues (to be fixed or re-evaluated in 12 months
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants