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

[macos] Missing cmath.h definitions #2274

Closed
2 of 7 tasks
csparker247 opened this issue Dec 15, 2020 · 4 comments
Closed
2 of 7 tasks

[macos] Missing cmath.h definitions #2274

csparker247 opened this issue Dec 15, 2020 · 4 comments
Assignees
Labels
Area: Apple investigate Collect additional information, like space on disk, other tool incompatibilities etc. OS: macOS

Comments

@csparker247
Copy link

Description
I've recently been getting build errors on a C++ project in the macos-10.15 image. A compiler error is thrown because multiple things from cmath.h aren't found, like ::signbit, ::isless, and ::isgreater. These are compiler errors from deep inside a dependency, in this case ITK, and not my code.

In file included from /Users/runner/work/cpp-build-action/cpp-build-action/main.cpp:1:
In file included from /usr/local/include/ITK-5.1/itkMesh.h:32:
In file included from /usr/local/include/ITK-5.1/itkPointSet.h:32:
In file included from /usr/local/include/ITK-5.1/itkDefaultStaticMeshTraits.h:21:
In file included from /usr/local/include/ITK-5.1/itkCellInterface.h:24:
In file included from /usr/local/include/ITK-5.1/itkArray.h:24:
In file included from /usr/local/include/ITK-5.1/vnl/vnl_vector.h:23:
In file included from /usr/local/include/ITK-5.1/vnl/vnl_c_vector.h:24:
/Applications/Xcode_12.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:317:9: error: no member named 'signbit' in the global namespace
using ::signbit;

I've seen this before on my personal machine, and it's almost always caused by something weird in the SDK configuration. My solution in those cases has been to make sure Xcode.app is uninstalled and only rely on the Command Line Tools. I first noticed this in Github Actions on 12/2/20 when a job failed for a commit, but then another job succeeded on a tagged version of the same commit. Prior to this, the job ran successfully. The timing implies that this has something to do with the change to a default Xcode 12.2.

I've setup a minimal project to explore the issue here. Thus far, I have observed the problem in both macos-10.15 and macos-11.0 when using the default Xcode. I do not have the problem on macos-11.0 when I use:

sudo xcode-select -s "/Library/Developer/CommandLineTools/"

but this does not work on macos-10.15. On that environment, I've tried using Xcode_12.app, Xcode_12.1.1.app, and /Library/Developer/CommandLineTools/, none of which work. I've also tried doing export SDKROOT=[full SDK path] along with xcode-select, since CMake pulls from that variable when determining the SDK to use.

I have already referred to #2056, #2211 (comment), and #2218 for possible solutions.

Area for Triage:

Apple, C/C++

Question, Bug, or Feature?:
Bug

Virtual environments affected

  • Ubuntu 16.04
  • Ubuntu 18.04
  • Ubuntu 20.04
  • macOS 10.15
  • macOS 11.0
  • Windows Server 2016 R2
  • Windows Server 2019

Expected behavior
Project builds successfully.

Actual behavior
Compiler error due to missing definitions.

Repro steps
I've setup a minimal example project here. It contains one action which performs all of the requisite steps. In brief, those steps are:

  1. (optional) Set the Xcode version and/or SDKROOT
  2. Run brew install itk
  3. Setup a CMake executable project that includes itkMesh.h and links against ITKCommon
  4. Try to compile.
@csparker247 csparker247 changed the title [macos] Missing cmath.h definitions on 10.15 [macos] Missing cmath.h definitions Dec 15, 2020
@andy-mishechkin andy-mishechkin added OS: macOS investigate Collect additional information, like space on disk, other tool incompatibilities etc. and removed needs triage labels Dec 16, 2020
@MaksimZhukov MaksimZhukov self-assigned this Dec 17, 2020
@MaksimZhukov
Copy link
Contributor

Hello @csparker247 !

We've reproduced this issue, but unfortunately we have not found the root cause yet. As a temporary solution you can define the CPLUS_INCLUDE_PATH environment variable for your entire workflow:

env:
  CPLUS_INCLUDE_PATH: /usr/local/opt/llvm/include/c++/v1:/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include

We will continue to investigate the issue, I will keep you posted.

@MaksimZhukov
Copy link
Contributor

Xcode Command Line Tools (12.2) installed on the macOS-10.15 include both MacOSX10.15.sdk and MacOSX11.0.sdk. The MacOSX.sdk symlink points to the MacOSX11.0.sdk. Here is the output of the ls -la /Library/Developer/CommandLineTools/SDKs command:

total 0
drwxr-xr-x  5 root  wheel  160 Dec 12 21:15 .
drwxr-xr-x  5 root  wheel  160 Dec 12 21:14 ..
lrwxr-xr-x  1 root  wheel   14 Dec 12 21:15 MacOSX.sdk -> MacOSX11.0.sdk
drwxr-xr-x  8 root  wheel  256 Jul  9 16:33 MacOSX10.15.sdk
drwxr-xr-x  7 root  wheel  224 Oct 19 20:39 MacOSX11.0.sdk

To fix this issue you can override the MacOSX.sdk symlink and remove the MacOSX11.0.sdk from the CommandLineTools/SDKs:

- name: Override the MacOSX.sdk symLink
  run: |
    sudo rm /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
    sudo rm -rf /Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk
    sudo ln -sf MacOSX10.15.sdk /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk 

@csparker247
Copy link
Author

csparker247 commented Dec 18, 2020

Confirmed that this works on macos-10.15 using CLT. I assume something similar would need to be done for those on 10.15 using Xcode_12.app.

I am confused as to why it wouldn't work outright on macos-11.0 by default. Assumably MacOSX.sdk in Xcode_12.2.app is symlinked to MacOSX11.0.sdk.

Anyway, this hints to me that maybe there's something broken in CMake or ITK for resolving the correct SDK. If MacOSX.sdk is a moving target based on the tooling version, it seems like it should always try to find the SDK named MacOSX10.15.sdk if the target platform is 10.15.

@MaksimZhukov
Copy link
Contributor

In this case, I am going to close this issue, but feel free to contact us if you have any concerns!

bryanpkc added a commit to Huawei-CPLLab/classic-flang-llvm-project that referenced this issue Jul 16, 2022
1. Parameterize Ubuntu20Dockerfile with the branch name. Previously the
   Dockerfile was still creating container images from the hardcoded
   release_13x branch.

2. Update the workaround for MacOS X build failures according to
   actions/runner-images#2274.

3. Delete the repo-lockdown workflow to eliminate the job which is always
   a no-op for classic-flang-llvm-project.

4. For debugging purpose, add a -v option to build-llvm-project.sh to enable
   verbose output.
bryanpkc added a commit to Huawei-CPLLab/classic-flang-llvm-project that referenced this issue Jul 18, 2022
1. Parameterize Ubuntu20Dockerfile with the branch name. Previously the
   Dockerfile was still creating container images from the hardcoded
   release_13x branch.

2. Update the workaround for MacOS X build failures according to
   actions/runner-images#2274.

3. For debugging purpose, add a -v option to build-llvm-project.sh to enable
   verbose output. The option sets $VERBOSE to an non-empty string which
   forces the CMake-generated Makefile to print every command it runs.

4. Delete the repo-lockdown workflow to eliminate the job which is always
   a no-op for classic-flang-llvm-project.
bryanpkc added a commit to flang-compiler/classic-flang-llvm-project that referenced this issue Jul 21, 2022
1. Parameterize Ubuntu20Dockerfile with the branch name. Previously the
   Dockerfile was still creating container images from the hardcoded
   release_13x branch.

2. Update the workaround for MacOS X build failures according to
   actions/runner-images#2274.

3. For debugging purpose, add a -v option to build-llvm-project.sh to enable
   verbose output. The option sets $VERBOSE to an non-empty string which
   forces the CMake-generated Makefile to print every command it runs.

4. Delete the repo-lockdown workflow to eliminate the job which is always
   a no-op for classic-flang-llvm-project.
bryanpkc added a commit to Huawei-CPLLab/classic-flang-llvm-project that referenced this issue Sep 7, 2022
This commit squashes the following commits from the release_14x branch:

    commit 84ed34d
    Author: Bryan Chan <bryan.chan@huawei.com>
    Date:   Sun Apr 24 19:13:25 2022 -0400

        [workflows] support GitHub actions for release_14x branch

    commit dd852a6
    Author: Bryan Chan <bryanpkc@gmail.com>
    Date:   Fri Jul 15 21:50:21 2022 -0400

        [workflows] Fix CI for release_14x

        1. Parameterize Ubuntu20Dockerfile with the branch name. Previously the
           Dockerfile was still creating container images from the hardcoded
           release_13x branch.

        2. Update the workaround for MacOS X build failures according to
           actions/runner-images#2274.

        3. For debugging purpose, add a -v option to build-llvm-project.sh to enable
           verbose output. The option sets $VERBOSE to an non-empty string which
           forces the CMake-generated Makefile to print every command it runs.

        4. Delete the repo-lockdown workflow to eliminate the job which is always
           a no-op for classic-flang-llvm-project.
bryanpkc added a commit to Huawei-CPLLab/classic-flang-llvm-project that referenced this issue Sep 7, 2022
This commit squashes the following commits from the release_14x branch:

    commit 84ed34d
    Author: Bryan Chan <bryan.chan@huawei.com>
    Date:   Sun Apr 24 19:13:25 2022 -0400

        [workflows] support GitHub actions for release_14x branch

    commit dd852a6
    Author: Bryan Chan <bryanpkc@gmail.com>
    Date:   Fri Jul 15 21:50:21 2022 -0400

        [workflows] Fix CI for release_14x

        1. Parameterize Ubuntu20Dockerfile with the branch name. Previously the
           Dockerfile was still creating container images from the hardcoded
           release_13x branch.

        2. Update the workaround for MacOS X build failures according to
           actions/runner-images#2274.

        3. For debugging purpose, add a -v option to build-llvm-project.sh to enable
           verbose output. The option sets $VERBOSE to an non-empty string which
           forces the CMake-generated Makefile to print every command it runs.

        4. Delete the repo-lockdown workflow to eliminate the job which is always
           a no-op for classic-flang-llvm-project.
bryanpkc added a commit to Huawei-CPLLab/classic-flang-llvm-project that referenced this issue Oct 15, 2022
This commit squashes the following commits from the release_14x branch:

    commit 84ed34d
    Author: Bryan Chan <bryan.chan@huawei.com>
    Date:   Sun Apr 24 19:13:25 2022 -0400

        [workflows] support GitHub actions for release_14x branch

    commit dd852a6
    Author: Bryan Chan <bryanpkc@gmail.com>
    Date:   Fri Jul 15 21:50:21 2022 -0400

        [workflows] Fix CI for release_14x

        1. Parameterize Ubuntu20Dockerfile with the branch name. Previously the
           Dockerfile was still creating container images from the hardcoded
           release_13x branch.

        2. Update the workaround for MacOS X build failures according to
           actions/runner-images#2274.

        3. For debugging purpose, add a -v option to build-llvm-project.sh to enable
           verbose output. The option sets $VERBOSE to an non-empty string which
           forces the CMake-generated Makefile to print every command it runs.

        4. Delete the repo-lockdown workflow to eliminate the job which is always
           a no-op for classic-flang-llvm-project.
bryanpkc added a commit to Huawei-CPLLab/classic-flang-llvm-project that referenced this issue Nov 5, 2022
Cherry-pick the following commit from release_14x, dropping stuff that do not
apply:

  commit dd852a6
  Author: Bryan Chan <bryanpkc@gmail.com>
  Date:   Fri Jul 15 21:50:21 2022 -0400

    [workflows] Fix CI for release_14x

    1. Parameterize Ubuntu20Dockerfile with the branch name. Previously the
       Dockerfile was still creating container images from the hardcoded
       release_13x branch.

    2. Update the workaround for MacOS X build failures according to
       actions/runner-images#2274.

    3. For debugging purpose, add a -v option to build-llvm-project.sh to enable
       verbose output. The option sets $VERBOSE to an non-empty string which
       forces the CMake-generated Makefile to print every command it runs.

    4. Delete the repo-lockdown workflow to eliminate the job which is always
       a no-op for classic-flang-llvm-project.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Apple investigate Collect additional information, like space on disk, other tool incompatibilities etc. OS: macOS
Projects
None yet
Development

No branches or pull requests

3 participants