Providing alternative location for Standard Library

Hi all

This question relates to swift as CLI interpreter, e.g. swift simple.swift, run from a freshly build-from-source swift compiler, from [buildFolder]/swift-macosx-x86_64/bin/swift.
If I have my swift.swiftmodule at [buildFolder]/swift-macosx-x86_64/lib/swift/macosx/x86_64 as expected, everything is fine, but I'd like to supply a different path. (I'm assuming CompilerInvocation::setMainExecutablePath is the one hard-coding this folder relation?)

I've tried all combinations of -L, -F, -Fsystem and -I with different levels of the relationship (myFolder, myFolder/lib ... etc.) but can't seem to get it to work - always getting error: unable to load standard library for target 'x86_64-apple-macosx10.13'.
Closest was -L=[someFolder]/lib/swift/macosx, which when dumped the command shows a DYLD_LIBRARY_PATH which seems like it will work, but doesn't.

Is it even possible? Any pointers will be much appreciated.

Can you try -resource-dir [someFolder]/lib/swift and see if that works?

It's not clear from your post whether you want just Swift.swiftmodule to be in a different location, or all of the standard libraries and overlays, but -resource-dir lets you specify a different location for the lib/swift directory as a whole.

1 Like