-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embedded: pass -nostdlib
for Embedded Wasm
#1534
base: main
Are you sure you want to change the base?
Conversation
Currently when linking with `swiftc` for `-unknown-none-` triples, it attempts to link `swiftrt.o` runtime file, which is currently not needed and is not present for these triples. We should avoid linking it in these cases.
Embedded Wasm binaries don't have compatible compiler-rt or C stdlib available, turn it off by default.
@kubamracek @rauhul it's unclear to me if we want to pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes some sense to make -nostdlib
as default for Embedded + WebAssembly targets.
But the problems here are:
- Embedded feature and
-nostdlib
are orthogonal concepts and Embedded application are not prohibited from linking libc and compiler-rt. - There is no way to tell clang linker driver to re-enable stdlib link.
So at least, we should have an option not to add -nostdlib
even with Embedded + WebAssemby targets. Or given that Embedded is for expert feature, we can ask developers to add -Xclang-linker -nostdlib
for their driver invocations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the correct file you intended to modify is Sources/SwiftDriver/Jobs/WebAssemblyToolchain+LinkerSupport.swift
. GenericUnixToolchain
is not used for wasm targets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WebAssemblyToolchain
is not used for Embedded Swift targets either, it's currently only picked up for WASI. I'm inclined to rename that one to WASIToolchain
maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I was wrong. A bit off-topic, but I think we might need to use WebAssemblyToolchain
for all platforms using wasm-ld including Embedded WebAssembly targets because wasm-ld has quite different options set than other unix linkers. (e.g. wasm-ld doesn't have --start-group
, all wasm targets needs --global-base
, etc)
@swift-ci test |
Embedded targets may need `-nostdlib` passed to `clang` linker driver in certain situations, see #1534 for more details. Currently, `swiftc` doesn't recognize `-nostdlib` at all, while `-Xlinker -nostdlib` passed to a `swiftc` link job from the build system will be passed verbatim to the linker and not recognized by the linker driver. We should support this flag in `swiftc` to fix this.
Depends on #1533.
Embedded Wasm binaries don't have compatible compiler-rt or C stdlib available, turn it off by default. Otherwise this makes trivial Embedded Wasm projects fail at link time.