[SOLVED] Debug build is optimised anyway

I'm building using the following options, but I cannot debug resulting swift-frontend - debug info is present, but code is compiled with optimisations and I cannot view variables:

"$(dirname $0)/swift/utils/build-script" --skip-build-benchmarks \
  --skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \
  --sccache --release-debuginfo --debug-swift --debug-swift-stdlib --swift-disable-dead-stripping \
  --force-optimized-typechecker --skip-early-swift-driver \
  --bootstrapping=off \
  --extra-cmake-options " -DSWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE=$(dirname $0)/swift-syntax"

Upon further investigation, I see that swift/lib/Sema/TypeCheckAttr.cpp is compiled with the following parameters:


So, looks like -O3 overrides -O0. Is this a bug in build-script or am I using it wrong?

Chances are you have -O0 in project settings and override it with -O3 in the per file compiler settings (Build Phases → Compile Sources).

Apparently it was just the --force-optimized-typechecker in action