swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
66.69k stars 10.28k forks source link

Swift toolchain fails to build with Xcode 15.1 (regression from Xcode 15.0?) #70641

Open MaxDesiatov opened 6 months ago

MaxDesiatov commented 6 months ago

Description

After updating to Xcode 15.1 the toolchain fails to build with ./utils/build-script --preset=buildbot_osx_package,no_test, which is the exactly same preset used by @swift-ci build toolchain. Here's the exact build step in swift-cmark and error output:

+ env /opt/homebrew/bin/cmake --build /Users/maxd/Documents/swift-project/build/buildbot_osx/cmark-macosx-arm64 --config RelWithDebInfo -- -j8 all
[75/80][ 93%][1.775s] Linking C shared library extensions/libcmark-gfm-extensions.0.29.0.gfm.13.dylib
FAILED: extensions/libcmark-gfm-extensions.0.29.0.gfm.13.dylib
: && /Applications/Xcode-15.1.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang --target=arm64-apple-macosx10.13 -gline-tables-only -O2 -g -DNDEBUG -isysroot /Applications/Xcode-15.1.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -dynamiclib -Wl,-headerpad_max_install_names -compatibility_version 0.29.0 -current_version 0.29.0 -o extensions/libcmark-gfm-extensions.0.29.0.gfm.13.dylib -install_name @rpath/libcmark-gfm-extensions.0.29.0.gfm.13.dylib extensions/CMakeFiles/libcmark-gfm-extensions.dir/core-extensions.c.o extensions/CMakeFiles/libcmark-gfm-extensions.dir/table.c.o extensions/CMakeFiles/libcmark-gfm-extensions.dir/strikethrough.c.o extensions/CMakeFiles/libcmark-gfm-extensions.dir/autolink.c.o extensions/CMakeFiles/libcmark-gfm-extensions.dir/tagfilter.c.o extensions/CMakeFiles/libcmark-gfm-extensions.dir/ext_scanners.c.o extensions/CMakeFiles/libcmark-gfm-extensions.dir/tasklist.c.o  -Wl,-rpath,/Users/maxd/Documents/swift-project/build/buildbot_osx/cmark-macosx-arm64/src  src/libcmark-gfm.0.29.0.gfm.13.dylib && :
ld: Undefined symbols:
  _cmark_utf8proc_is_punctuation, referenced from:
      _match in autolink.c.o
      _match in autolink.c.o
      _match in autolink.c.o
      _check_domain in autolink.c.o
  _cmark_utf8proc_is_space, referenced from:
      _match in autolink.c.o
      _match in autolink.c.o
      _match in autolink.c.o
      _check_domain in autolink.c.o
  _cmark_utf8proc_iterate, referenced from:
      _match in autolink.c.o
      _match in autolink.c.o
      _match in autolink.c.o
      _check_domain in autolink.c.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Reproduction

  1. Make sure you have Xcode 15.1 installed and selected as the default with xcode-select -p.

  2. Navigate to the directory that hosts your Swift project checkouts.

  3. Build the toolchain with these arguments (adjust to correct paths as needed):

./swift/utils/build-script --preset=buildbot_osx_package,no_test \
  --cmake-c-launcher /usr/local/bin/sccache \
  --cmake-cxx-launcher /usr/local/bin/sccache \
  "install_destdir=$(pwd)/swift-nightly-install" \
  "installable_package=$(pwd)/swift-PR-70629-993-osx.tar.gz" \
  install_toolchain_dir=/Library/Developer/Toolchains/swift-PR-70629-993.xctoolchain \
  "install_symroot=$(pwd)/swift-nightly-symroot" \
  "symbols_package=$(pwd)/swift-PR-70629-993-osx-symbols.tar.gz" \
  darwin_toolchain_bundle_identifier=org.swift.pr.70629.993 \
  'darwin_toolchain_display_name=Swift PR - 70629 (993)' \
  'darwin_toolchain_display_name_short=Swift PR - 70629 (993)' \
  darwin_toolchain_xctoolchain_name=swift-PR-70629-993 \
  darwin_toolchain_version=70629.993.0 \
  darwin_toolchain_alias=PR70629

Expected behavior

The toolchain builds successfully, just as it did with Xcode 15.0.1.

Environment

MacBook Air M1, macOS Sonoma 14.2.1 (23C71)

Additional information

https://forums.swift.org/t/build-fails-at-cmark/69176

stephencelis commented 6 months ago

I saw this issue in 15.1, changed to 15.0.1 and got things building again, but after a few builds, and deleting the build directory, I encountered the same issue in 15.0.1.

Pogosito commented 5 months ago

Same problem, I tried to build a project (commit: a9bf17e562aeb6ac5860e3e4782a28a4cfe563d) with

utils/build-script --skip-build-benchmarks \ --skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \ --sccache --release-debuginfo --swift-disable-dead-stripping

MacBook Pro M3 Pro, macOS Sonoma 14.1 (23B2073) Xcode Version 15.0.1 (15A507)

vanvoorden commented 5 months ago

https://gist.github.com/vanvoorden/ec1725c211ac3356eb50f7c307a32efa

FAILED: extensions/libcmark-gfm-extensions.0.29.0.gfm.13.dylib 

I'm seeing the same kind of error from ece521c12b600e681b46b9218021fbd7d8780fa4. Building locally on M2 MBP and Xcode 15.2 (15C500b) on macOS 14.3 (23D56)

AnthonyLatsis commented 5 months ago

FYI @Pogosito managed to work around this by switching to Xcode 14.3 command line tools.

vanvoorden commented 5 months ago

Xcode 14.3 command line tools

2024-01-23 @AnthonyLatsis Ahh… I'm blocked on installing the legacy tools… womp womp…

AnthonyLatsis commented 5 months ago

You could also try 15.0.

vanvoorden commented 5 months ago

You could also try 15.0.

@AnthonyLatsis Xcode 15.0 worked for me!

stephencelis commented 5 months ago

FWIW 15 worked for me but only temporarily. When I cleaned the build folder after a successful build, I got stuck in the build failure cycle of this issue.

MaxDesiatov commented 4 months ago

Hi @stephencelis, is this still reproducible for you with Xcode 15.3 RC?