Swift toolchains build failed, with error: header 'stdarg.h' not found

When I try to build the swift toolchain in branch release/5.4, it fail when building TSC, with error
it tell me that "stdarg.h" no found, I am using Xcode12.3 and big sur macOS, do anyone has ideas?

-- Build files have been written to: /Users/iosarchpro/jenkins/workspace/toolchain-build-llvm/llvm-infrastructure-tools/toolchain/swift-source/build/buildbot_osx/swiftpm-macosx-x86_64/x86_64-apple-macosx/tsc
[1/6][ 16%][0.022s] Building C object Sources/TSCclibc/CMakeFiles/TSCclibc.dir/process.c.o
[2/6][ 33%][0.023s] Building C object Sources/TSCclibc/CMakeFiles/TSCclibc.dir/libc.c.o
[3/6][ 50%][0.046s] Linking C static library lib/libTSCclibc.a
/Applications/Xcode-12.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: lib/libTSCclibc.a(process.c.o) has no symbols
/Applications/Xcode-12.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: lib/libTSCclibc.a(process.c.o) has no symbols
[4/6][ 66%][0.055s] Linking Swift shared library lib/libTSCLibc.dylib
FAILED: lib/libTSCLibc.dylib Sources/TSCLibc/CMakeFiles/TSCLibc.dir/libc.swift.o swift/TSCLibc.swiftmodule
: && /Users/iosarchpro/jenkins/workspace/toolchain-build-llvm/llvm-infrastructure-tools/toolchain/swift-source/toolchain-package/toolchain-20210223184048/swift-nightly-install/Library/Developer/Toolchains/swift-BD-2021-02-23-standard_swift-no_assertions-no_test.xctoolchain/usr/bin/swiftc -output-file-map Sources/TSCLibc/CMakeFiles/TSCLibc.dir/Debug/output-file-map.json -incremental -j 12 -emit-library -o lib/libTSCLibc.dylib -module-name TSCLibc -module-link-name TSCLibc -emit-module -emit-module-path swift/TSCLibc.swiftmodule -emit-dependencies -DTSCLibc_EXPORTS -sdk /Applications/Xcode-12.3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -module-cache-path "/Users/iosarchpro/jenkins/workspace/toolchain-build-llvm/llvm-infrastructure-tools/toolchain/swift-source/build/buildbot_osx/swiftpm-macosx-x86_64/x86_64-apple-macosx/tsc/module-cache" -g -swift-version 5 -sdk /Applications/Xcode-12.3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk /Users/iosarchpro/jenkins/workspace/toolchain-build-llvm/llvm-infrastructure-tools/toolchain/swift-source/swift-tools-support-core/Sources/TSCLibc/libc.swift -Xlinker -install_name -Xlinker @rpath/libTSCLibc.dylib && :
/Applications/Xcode-12.3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/module.modulemap:118:11: error: header 'stdarg.h' not found
header "stdarg.h" // note: supplied by the compiler
^
/Users/iosarchpro/jenkins/workspace/toolchain-build-llvm/llvm-infrastructure-tools/toolchain/swift-source/swift-tools-support-core/Sources/TSCLibc/libc.swift:17:19: error: could not build Objective-C module 'Darwin'
@_exported import Darwin.C
^
ninja: build stopped: subcommand failed.

after check, i found it's failed when try to build swiftPM which dependencies contains "swift-tool-core", I found a lots of modify in swiftPM, but do not know what happy

The error is giving you a hint, error: header 'stdarg.h' not found header "stdarg.h" // note: supplied by the compiler. It sounds like your newly built Swift toolchain was not set up properly in a prior step. I've never used Swift on a Mac, so I'll tell you how it works on other platforms and you can check if it's the same on the Mac.

On linux and some other platforms, a symbolic link or directory called clang/ is created in the Swift resource directory, usually usr/lib/swift in the Swift toolchain, and then the compiler at usr/bin/swiftc finds that header in there. You can check if the official dev snapshot builds of Swift 5.4 for the Mac do the same, then see if it's set up right for your freshly built toolchain.

Terms of Service

Privacy Policy

Cookie Policy