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

[SR-12726] Can't build apple/swift master on macOS with Command Line Tools installed #55171

Closed
MaxDesiatov opened this issue May 3, 2020 · 10 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@MaxDesiatov
Copy link
Member

MaxDesiatov commented May 3, 2020

Previous ID SR-12726
Radar rdar://problem/62895058
Original Reporter @MaxDesiatov
Type Bug
Environment

Catalina 10.15.4 or Mojave 10.14.6, both with Xcode 11.4.1, Command Line Tools version: 11.4.1.0.1.1586360307

Additional Detail from JIRA
Votes 1
Component/s Compiler, Project Infrastructure
Labels Bug
Assignee None
Priority Medium

md5: c3dfdb5d5a180b0991e4f335c6f6d5c1

duplicates:

Issue Description:

When building the compiler master branch (this is not reproducible with swift-5.2-branch scheme) on macOS with Command Line Tools installed, swift/lib/Immediate/Immediate.cpp fails to build with these errors:

/Applications/Xcode-11.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -DCMARK_STATIC_DEFINE -DGTEST_HAS_RTTI=0 -DHAVE_LIBEDIT -DSWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Immediate -I/Users/maxd/Documents/swift-source-test/swift/lib/Immediate -Iinclude -I/Users/maxd/Documents/swift-source-test/swift/include -I/Users/maxd/Documents/swift-source-test/llvm-project/llvm/include -I/Users/maxd/Documents/swift-source-test/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/include -I/Users/maxd/Documents/swift-source-test/llvm-project/clang/include -I/Users/maxd/Documents/swift-source-test/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/tools/clang/include -I/Users/maxd/Documents/swift-source-test/cmark/src -I/Users/maxd/Documents/swift-source-test/build/Ninja-RelWithDebInfoAssert/cmark-macosx-x86_64/src -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -Wno-unknown-warning-option -Werror=unguarded-availability-new -fno-stack-protector -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-class-memaccess -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -Werror=switch -Wdocumentation -Wimplicit-fallthrough -Wunreachable-code -Woverloaded-virtual -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -O2 -isysroot /Applications/Xcode-11.4.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -UNDEBUG -fno-exceptions -fno-rtti -Werror=gnu -target x86_64-apple-macosx10.9 -isysroot /Applications/Xcode-11.4.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -arch x86_64 -F/../../../Developer/Library/Frameworks -mmacosx-version-min=10.9 -O2 -g -UNDEBUG -std=c++14 -MD -MT lib/Immediate/CMakeFiles/swiftImmediate.dir/Immediate.cpp.o -MF lib/Immediate/CMakeFiles/swiftImmediate.dir/Immediate.cpp.o.d -o lib/Immediate/CMakeFiles/swiftImmediate.dir/Immediate.cpp.o -c /Users/maxd/Documents/swift-source-test/swift/lib/Immediate/Immediate.cpp
In file included from /Users/maxd/Documents/swift-source-test/swift/lib/Immediate/Immediate.cpp:19:
In file included from /Users/maxd/Documents/swift-source-test/swift/lib/Immediate/ImmediateImpl.h:16:
In file included from /Users/maxd/Documents/swift-source-test/swift/include/swift/AST/LinkLibrary.h:17:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/ADT/SmallString.h:16:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/ADT/SmallVector.h:19:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/Support/MathExtras.h:17:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/Support/SwapByteOrder.h:18:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/Support/DataTypes.h:16:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm-c/DataTypes.h:28:
/Applications/Xcode-11.4.1.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;
      ~~^
/Applications/Xcode-11.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:318:9: error: no member named 'fpclassify' in the global namespace
using ::fpclassify;
      ~~^
/Applications/Xcode-11.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:319:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
      ~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/math.h:749:12: note: 'finite' declared here
extern int finite(double)
           ^
In file included from /Users/maxd/Documents/swift-source-test/swift/lib/Immediate/Immediate.cpp:19:
In file included from /Users/maxd/Documents/swift-source-test/swift/lib/Immediate/ImmediateImpl.h:16:
In file included from /Users/maxd/Documents/swift-source-test/swift/include/swift/AST/LinkLibrary.h:17:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/ADT/SmallString.h:16:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/ADT/SmallVector.h:19:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/Support/MathExtras.h:17:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/Support/SwapByteOrder.h:18:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/Support/DataTypes.h:16:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm-c/DataTypes.h:28:
/Applications/Xcode-11.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:320:9: error: no member named 'isinf' in the global namespace
using ::isinf;
      ~~^
/Applications/Xcode-11.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:321:9: error: no member named 'isnan' in the global namespace
using ::isnan;
      ~~^
/Applications/Xcode-11.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:322:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
      ~~^
/Applications/Xcode-11.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:323:7: error: no member named 'isgreater' in the global namespace; did you mean '::std::greater'?
using ::isgreater;
      ^~
/Applications/Xcode-11.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:731:29: note: '::std::greater' declared here
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
                            ^
In file included from /Users/maxd/Documents/swift-source-test/swift/lib/Immediate/Immediate.cpp:19:
In file included from /Users/maxd/Documents/swift-source-test/swift/lib/Immediate/ImmediateImpl.h:16:
In file included from /Users/maxd/Documents/swift-source-test/swift/include/swift/AST/LinkLibrary.h:17:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/ADT/SmallString.h:16:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/ADT/SmallVector.h:19:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/Support/MathExtras.h:17:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/Support/SwapByteOrder.h:18:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/Support/DataTypes.h:16:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm-c/DataTypes.h:28:
/Applications/Xcode-11.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:324:7: error: no member named 'isgreaterequal' in the global namespace; did you mean '::std::greater_equal'?
using ::isgreaterequal;
      ^~
/Applications/Xcode-11.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:760:29: note: '::std::greater_equal' declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
                            ^
In file included from /Users/maxd/Documents/swift-source-test/swift/lib/Immediate/Immediate.cpp:19:
In file included from /Users/maxd/Documents/swift-source-test/swift/lib/Immediate/ImmediateImpl.h:16:
In file included from /Users/maxd/Documents/swift-source-test/swift/include/swift/AST/LinkLibrary.h:17:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/ADT/SmallString.h:16:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/ADT/SmallVector.h:19:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/Support/MathExtras.h:17:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/Support/SwapByteOrder.h:18:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm/Support/DataTypes.h:16:
In file included from /Users/maxd/Documents/swift-source-test/llvm-project/llvm/include/llvm-c/DataTypes.h:28:
/Applications/Xcode-11.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:325:9: error: no member named 'isless' in the global namespace
using ::isless;
      ~~^
/Applications/Xcode-11.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:326:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
      ~~^
/Applications/Xcode-11.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:327:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
      ~~^
/Applications/Xcode-11.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:328:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/Applications/Xcode-11.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:329:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
13 errors generated.

The culprit is this flag in build command -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include

The flag is only added when CommandLineTools are installed. Removing the flag from the invocation allows the build command to pass, but there's no known way to force the build system to not to add that flag breaking the build, other than deleting the /Library/Developer/CommandLineTools directory.

@beccadax
Copy link
Contributor

beccadax commented May 5, 2020

@swift-ci create

@MaxDesiatov
Copy link
Member Author

This is fixed for me with command line tools for Xcode 11.5.

@keith
Copy link
Collaborator

keith commented Jun 3, 2020

Even with the command line tools from 11.5 I still see this issue, I'm testing removing the command line tools directory to see if that solves it for me.

@keith
Copy link
Collaborator

keith commented Jun 3, 2020

Removing the 11.5 command line tools fixes this for me

@swift-ci
Copy link
Collaborator

Comment by Daniel Martín (JIRA)

That -isystem path is probably added by CMake after the evaluation of a pkg_check_modules command from any of the Find*.cmake files in cmake/modules. CMake relies on pkg-config to search for libraries and include paths in the target system. Adding -DCMAKE_FIND_DEBUG_MODE=1 to the build will probably output more useful information (requires CMake ~3.17).

Are you all using Homebrew? If so, the build failure may perfectly be caused by recent changes in Mac SDK handling and pkg-config. See, for example: Homebrew/brew#5068 (comment) which is a similar issue, but affecting SPM.

Removing the CLI package seems like a sensible workaround for now.

@MaxDesiatov
Copy link
Member Author

This is actually still reproducible for me with Xcode 11.5 and CLI Tools package for 11.5. Removing CLI Tools fixed the issue, but I don't think this is a good solution, especially as the reported error is very confusing and doesn't clearly point to the source of the problem.

@kastiglione
Copy link
Contributor

The work around I used was to uninstall pkg-config. Homebrew has a seriously broken pkg-config setup, there are hardcoded paths to CLT in their .pc files, and I haven't seen a convenient ways to override it. None of homebrew's package config .pc files are needed for building swift. Instead of uninstalling pkg-config, another option is to brew unlink it.

@kastiglione
Copy link
Contributor

I've opened a PR with a possible fix: #32436

@kastiglione
Copy link
Contributor

I believe this is now fixed and can be closed, apple/swift#32436 has been merged.

@swift-ci
Copy link
Collaborator

swift-ci commented Jan 9, 2022

Comment by Michael Filonenko (JIRA)

I’m experiencing the same issue after updating the XCode to the version 13.2.1.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

5 participants