Hey all,
So I've been interested in building my Swift Embedded project in debug mode since building swift-mmio
in release mode is MUCH slower (even painfully slow), and I like to have the ability to generate a debug binary for testing and analysis.
However, if I try to build my project in debug mode, a bunch of fun issues start to happen. At first, I get this error:
blink-mmio$ make
compiling...
swift build \
--configuration debug \
--swift-sdks-path ../swift-sdks \
--swift-sdk stm32c0xx \
Building for debugging...
warning: ignoring '-enable-batch-mode' because '-whole-module-optimization' was also specified
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
<unknown>:0: error: index output filenames do not match input source files
make: *** [Makefile:24: build] Error 1
Fine. So if I add the --disable-index-store
flag to swift build
, then the next issue appears. Binaries are placed in the same directory as the make
command instead of in the expected .build/debug subdirectory, and the Swift linker cannot find the object files (naturally):
blink-mmio$ make
compiling...
swift build \
--configuration debug \
--swift-sdks-path ../swift-sdks \
--swift-sdk stm32c0xx --disable-index-store \
Building for debugging...
/home/xtremek/.local/share/swiftly/toolchains/6.0.1/usr/bin/llvm-ar: error: /home/xtremek/Programming/xtremekforever/swift-stm32c011-examples/blink-mmio/.build/armv6m-none-none-eabi/debug/Application.build/Application.swift.o: No such file or directory
[3/4] Archiving libApplication.a
make: *** [Makefile:24: build] Error 1
blink-mmio$ ls -l *
**-rw-rw-r-- 1 xtremek xtremek 1939976 Oct 27 20:52 Application.o**
**-rw-rw-r-- 1 xtremek xtremek 130752 Oct 27 20:52 CortexM.o**
-rw-rw-r-- 1 xtremek xtremek 1718 Oct 27 20:51 Makefile
**-rw-rw-r-- 1 xtremek xtremek 50020 Oct 27 20:52 MMIO.o**
-rw-rw-r-- 1 xtremek xtremek 1238 Oct 19 13:20 Package.resolved
-rw-rw-r-- 1 xtremek xtremek 740 Oct 19 13:20 Package.swift
Sources:
total 8
drwxrwxr-x 3 xtremek xtremek 4096 Oct 19 13:20 Application
drwxrwxr-x 3 xtremek xtremek 4096 Sep 29 06:40 Support
Any ideas why this sort of thing happens when using embedded mode? Here are the flags for Swift SDK that are being passed to the build for complete reference:
"swiftCompiler": {
"extraCLIOptions": [
"-Osize",
"-wmo",
"-enable-experimental-feature", "Embedded",
"-Xfrontend", "-disable-stack-protector",
"-Xfrontend", "-function-sections"
]
},