Getting started with tinkering with the standard library

A followup question: the preset with test runs the whole stdlib test suite fine, but the way I'd previously run individual tests does not work. For example,
$ llvm/utils/lit/lit.py --verbose --param swift_site_config=build/stdlib_DA_standalone/swift-macosx-x86_64/test-macosx-x86_64/lit.site.cfg swift/test/stdlib/UnsafePointer.swift.gyb
selects the default toolchain and fails to find the StdlibUnittest module. Pointers?

Could it be that these instructions are out of date? I can't get it to build unfortunately. I'm running into the following build errors:

swift/stdlib/public/core/ConcurrentValue.swift:15:1: error: unknown attribute '_marker'
@_marker public protocol ConcurrentValue { }
^
swift/stdlib/public/core/ConcurrentValue.swift:20:1: error: unknown attribute '_marker'
@_marker public protocol UnsafeConcurrentValue: ConcurrentValue { }
^
ninja: build stopped: subcommand failed.
ERROR: command terminated with a non-zero exit status 1, aborting

ERROR: command terminated with a non-zero exit status 1, aborting

Yes, the standalone stdlib preset is not tested on the CI and may have regressed. More likely, you may be doing something wrong, but we can't diagnose that unless you tell us exactly what command you ran.

I regularly cross-compile the standalone stdlib for Android and had no problem building the Feb . 2 trunk source snapshot, but that doesn't have the patches you're having problems with.

Here are the exact commands I ran :)

mkdir workspace
cd workspace
curl -O https://swift.org/builds/development/xcode/swift-DEVELOPMENT-SNAPSHOT-2021-02-02-a/swift-DEVELOPMENT-SNAPSHOT-2021-02-02-a-osx.pkg
mkdir toolchain
xar -C toolchain -x -f swift-DEVELOPMENT-SNAPSHOT-2021-02-02-a-osx.pkg
tar -C toolchain -xzf toolchain/swift-DEVELOPMENT-SNAPSHOT-2021-02-02-a-osx-package.pkg/Payload
TOOLCHAIN_BIN_DIR=$PWD/toolchain/usr/bin
git clone git@github.com:apple/swift.git
./swift/utils/update-checkout --clone --scheme master
./swift/utils/build-script --preset=stdlib_DA_standalone,build toolchain_path=$TOOLCHAIN_BIN_DIR

Well, for one, you're building with the prebuilt Feb. 2 toolchain but checking out the stdlib source from latest trunk, which if run today would be a week later. I had no problem when I checked out the stdlib source at the Feb. 2 snapshot tag too: I don't think you would either. I believe the compiler usually needs to be synced with the stdlib and such errors can crop up otherwise.

This makes so much sense... Thanks for pointing me in the right direction!

Found some more time to try again. Now I checkout the same snapshot tag on the github.com/apple.swift repo before running the update-checkout. I'm not sure which scheme to use for that utility though. I went over the defined schemes but they all seem to be defined for specific versions except for master/main. So I ran ./swift/utils/update-checkout --clone --scheme master again but now the swift repo was checking the correct tag.
However running the last line ./swift/utils/build-script --preset=stdlib_DA_standalone,build toolchain_path=$TOOLCHAIN_BIN_DIR Still results in errors for me.
I seem to be missing something. Full commands I ran:

mkdir workspace
cd workspace
curl -O https://swift.org/builds/development/xcode/swift-DEVELOPMENT-SNAPSHOT-2021-02-09-a/swift-DEVELOPMENT-SNAPSHOT-2021-02-09-a-osx.pkg
mkdir toolchain
xar -C toolchain -x -f swift-DEVELOPMENT-SNAPSHOT-2021-02-09-a-osx.pkg
tar -C toolchain -xzf toolchain/swift-DEVELOPMENT-SNAPSHOT-2021-02-09-a-osx-package.pkg/Payload
TOOLCHAIN_BIN_DIR=$PWD/toolchain/usr/bin
git clone git@github.com:apple/swift.git
cd swift
git checkout tags/swift-DEVELOPMENT-SNAPSHOT-2021-02-09-a
cd ..
./swift/utils/update-checkout --clone --scheme master
./swift/utils/build-script --preset=stdlib_DA_standalone,build toolchain_path=$TOOLCHAIN_BIN_DIR

You're still checking out latest HEAD in that penultimate step. Try running ./swift/utils/update-checkout --tag swift-DEVELOPMENT-SNAPSHOT-2021-02-09-a now and then rerun the last step.

1 Like