Hi, I'm pretty new to the swift open-source community, today I've been trying to compile swift using the readme from github, I cloned the repo via SSH and ran update-checkout --clone-with-ssh and I have Xcode 12 beta 3 installed on macOS 10.15. I would like to use xcode to view/edit code, however when I run the utils/build-script --release-debuginfo --xcode I get this error:
[swift/utils/build-script] NOTE: Using toolchain default
+ /usr/libexec/PlistBuddy -c 'Print :SupportedTargets:macosx:Archs' /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/SDKSettings.plist
+ mkdir -p /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert
Building the standard library for: swift-test-stdlib-macosx-x86_64
+ mkdir -p /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64
+ mkdir -p /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/.cmake/api/v1/query
+ touch /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/.cmake/api/v1/query/codemodel-v2 /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/.cmake/api/v1/query/cache-v2
+ pushd /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64
~/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64 ~/swift-source
+ env /usr/local/bin/cmake -G Xcode -DCMAKE_C_COMPILER:PATH=/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -DCMAKE_CXX_COMPILER:PATH=/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -DCMAKE_LIBTOOL:PATH=/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool '-DCMAKE_CONFIGURATION_TYPES=Debug;Release;MinSizeRel;RelWithDebInfo' -DLLVM_VERSION_MAJOR:STRING=10 -DLLVM_VERSION_MINOR:STRING=0 -DLLVM_VERSION_PATCH:STRING=0 -DCLANG_VERSION_MAJOR:STRING=10 -DCLANG_VERSION_MINOR:STRING=0 -DCLANG_VERSION_PATCH:STRING=0 -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo '-DCMAKE_C_FLAGS= -Wno-unknown-warning-option -Werror=unguarded-availability-new -arch x86_64 -fno-stack-protector' '-DCMAKE_CXX_FLAGS= -Wno-unknown-warning-option -Werror=unguarded-availability-new -arch x86_64 -fno-stack-protector' -DCMAKE_OSX_SYSROOT:PATH=/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 '-DCMAKE_IGNORE_PATH=/usr/lib;/usr/local/lib;/lib' /Users/suneettipirneni/swift-source/cmark
-- The C compiler identification is AppleClang 12.0.0.12000026
-- The CXX compiler identification is AppleClang 12.0.0.12000026
-- Check for working C compiler: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-- Check for working C compiler: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -- broken
CMake Error at /usr/local/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/xcodebuild -project CMAKE_TRY_COMPILE.xcodeproj build -target cmTC_8df4d -configuration Debug -hideShellScriptEnvironment && Command line invocation:
/Applications/Xcode-beta.app/Contents/Developer/usr/bin/xcodebuild -project CMAKE_TRY_COMPILE.xcodeproj build -target cmTC_8df4d -configuration Debug -hideShellScriptEnvironment
User defaults from command line:
HideShellScriptEnvironment = YES
Build settings from command line:
TOOLCHAINS = default
Prepare build
note: The Legacy Build System will be removed in a future release. You can configure the selected build system and this deprecation message in File > Project Settings.
=== BUILD TARGET cmTC_8df4d OF PROJECT CMAKE_TRY_COMPILE WITH CONFIGURATION Debug ===
Check dependencies
Write auxiliary files
/bin/mkdir -p /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_8df4d.build/Objects-normal/arm64
write-file /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_8df4d.build/Objects-normal/arm64/cmTC_8df4d.LinkFileList
CompileC CMAKE_TRY_COMPILE.build/Debug/cmTC_8df4d.build/Objects-normal/arm64/testCCompiler.o testCCompiler.c normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -target arm64-apple-macos10.9 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wno-shorten-64-to-32 -Wpointer-sign -Wno-newline-eof -DCMAKE_INTDIR=\"Debug\" -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk -fstrict-aliasing -Wdeprecated-declarations -g -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-semicolon-before-method-body -I/Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/Debug/include -I/Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_8df4d.build/DerivedSources-normal/arm64 -I/Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_8df4d.build/DerivedSources/arm64 -I/Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_8df4d.build/DerivedSources -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -F/Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/Debug -Wno-unknown-warning-option -Werror=unguarded-availability-new -arch x86_64 -fno-stack-protector -MMD -MT dependencies -MF /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_8df4d.build/Objects-normal/arm64/testCCompiler.d --serialize-diagnostics /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_8df4d.build/Objects-normal/arm64/testCCompiler.dia -c /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/testCCompiler.c -o /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_8df4d.build/Objects-normal/arm64/testCCompiler.o
Ld Debug/cmTC_8df4d normal arm64
cd /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target arm64-apple-macos10.9 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk -L/Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/Debug -F/Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/Debug -filelist /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_8df4d.build/Objects-normal/arm64/cmTC_8df4d.LinkFileList -Xlinker -object_path_lto -Xlinker /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_8df4d.build/Objects-normal/arm64/cmTC_8df4d_lto.o -Xlinker -no_deduplicate -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Xlinker -dependency_info -Xlinker /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_8df4d.build/Objects-normal/arm64/cmTC_8df4d_dependency_info.dat -o /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/Debug/cmTC_8df4d
ld: warning: ignoring file /Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_8df4d.build/Objects-normal/arm64/testCCompiler.o, building for macOS-arm64 but attempting to link with file built for unknown-x86_64
Undefined symbols for architecture arm64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
** BUILD FAILED **
The following build commands failed:
Ld Debug/cmTC_8df4d normal arm64
(1 failure)
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "/Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeOutput.log".
See also "/Users/suneettipirneni/swift-source/build/Xcode-RelWithDebInfoAssert/cmark-macosx-x86_64/CMakeFiles/CMakeError.log".
ERROR: command terminated with a non-zero exit status 1, aborting
Can someone guide me in the right direction with this error? Help would be greatly appreciated, thanks!
You might need to:
I haven't used the --xcode option recently. Instead, I created an empty xcworkspace (File → New → Workspace) inside the "swift-source" directory, and added a folder reference (File → Add Files…) for each project of interest (currently just the "swift" directory).
To build and test, I use the command line:
utils/build-script --reconfigure --release-debuginfo --test
If there are errors, due to changing CMake or Xcode versions, try adding the --clean option.
Thank you, I ended up using the xcode workspaces like you stated.
I've just built with Xcode 12 beta 3 (and CMake 3.17.0, on macOS 10.15.6) so there's no need to downgrade to beta 1.
1 Like
When trying to build with Xcode 12b3, it tries to build for arm64 for some reason. I've found this issue in Cmake - Xcode 12 Universal Beta default architecture selection (#20893) · Issues · CMake / CMake · GitLab and added --extra-cmake-options="-DCMAKE_OSX_ARCHITECTURES=x86_64". This worked for Cmark and LLVM, but Swift itself still builds for arm64 and fails when linking with LLVM.
1 Like
Same thing here, I had to downgrade to Xcode 12 beta 2 when building with Ninja.
CMake 3.18.1 is now available for download. It includes a fix for the above issue, where an architecture was selected arbitrarily.
1 Like