# Undefined symbols in embedded Swift - are they ok to ignore?

**URL:** <https://forums.swift.org/t/undefined-symbols-in-embedded-swift-are-they-ok-to-ignore/75634>\
**Category:** Embedded\
**Created:** [October 26, 2024, 11:45am UTC](https://forums.swift.org/t/undefined-symbols-in-embedded-swift-are-they-ok-to-ignore/75634 "2024-10-26T11:45:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![iCMDdev](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/icmddev/32/32393_2.png) [@iCMDdev](https://forums.swift.org/u/iCMDdev)\
**Post date:** [October 26, 2024, 11:45am UTC](https://forums.swift.org/t/undefined-symbols-in-embedded-swift-are-they-ok-to-ignore/75634/1 "2024-10-26T11:45:19Z")

</div>

Hi,  
I am porting Swift Embedded to a new device, and found that, when linking with `ld.lld`, I get a few (the stack canary functions, putchar ).

Are these safe to ignore using the `--unresolved-symbols=ignore-in-object-files` argument?

```swift
ld.lld: error: undefined symbol: __stack_chk_guard
>>> referenced by HelloEmbedded.o
>>> HelloEmbedded.o:($ss17swift_allocObject8metadata12requiredSize0E13AlignmentMaskSpys04HeapC0VGSpys13ClassMetadataVG_S2itF)
>>> referenced by HelloEmbedded.o
>>> HelloEmbedded.o:($ss17swift_allocObject8metadata12requiredSize0E13AlignmentMaskSpys04HeapC0VGSpys13ClassMetadataVG_S2itF)
>>> referenced by HelloEmbedded.o
>>> HelloEmbedded.o:($ss17swift_allocObject8metadata12requiredSize0E13AlignmentMaskSpys04HeapC0VGSpys13ClassMetadataVG_S2itF)
>>> referenced 9 more times

ld.lld: error: undefined symbol: posix_memalign
>>> referenced by HelloEmbedded.o
>>> HelloEmbedded.o:($ss17swift_allocObject8metadata12requiredSize0E13AlignmentMaskSpys04HeapC0VGSpys13ClassMetadataVG_S2itF)
>>> referenced by HelloEmbedded.o
>>> HelloEmbedded.o:($ss15swift_slowAllocySvSgSi_SitF)

ld.lld: error: undefined symbol: __stack_chk_fail
>>> referenced by HelloEmbedded.o
>>> HelloEmbedded.o:($ss17swift_allocObject8metadata12requiredSize0E13AlignmentMaskSpys04HeapC0VGSpys13ClassMetadataVG_S2itF)
>>> referenced by HelloEmbedded.o
>>> HelloEmbedded.o:($sSzsE13writeToStdoutyyFSu_Tg5)
>>> referenced by HelloEmbedded.o
>>> HelloEmbedded.o:($ss15swift_slowAllocySvSgSi_SitF)

ld.lld: error: undefined symbol: putchar
>>> referenced by HelloEmbedded.o
>>> HelloEmbedded.o:($ss5print_10terminatorys12StaticStringV_ADtF)
>>> referenced by HelloEmbedded.o
>>> HelloEmbedded.o:($ss5print_10terminatorys12StaticStringV_ADtF)
>>> referenced by HelloEmbedded.o
>>> HelloEmbedded.o:($ss15printCharactersyySWF)

ld.lld: error: undefined symbol: memmove
>>> referenced by HelloEmbedded.o
>>> HelloEmbedded.o:($sSv10copyMemory4from9byteCountySV_SitF)

ld.lld: error: undefined symbol: free
>>> referenced by HelloEmbedded.o
>>> HelloEmbedded.o:($ss19swift_deallocObject6object13allocatedSize0E9AlignMaskyBp_S2itF)
>>> referenced by HelloEmbedded.o
>>> HelloEmbedded.o:($ss26swift_deallocClassInstance6object13allocatedSize0F9AlignMaskyBp_S2itF)
>>> referenced by HelloEmbedded.o
>>> HelloEmbedded.o:($ss17swift_slowDeallocyySv_S2itF)

```

---

<div class="post-metadata">

**Author:** ![ebariaux](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ebariaux/32/36731_2.png) [@ebariaux](https://forums.swift.org/u/ebariaux)\
**Post date:** [October 26, 2024, 1:23pm UTC](https://forums.swift.org/t/undefined-symbols-in-embedded-swift-are-they-ok-to-ignore/75634/2 "2024-10-26T13:23:42Z")

</div>

It depends what your code will do.  
Take a look at [swift/docs/EmbeddedSwift/UserManual.md at main · swiftlang/swift](https://github.com/swiftlang/swift/blob/main/docs/EmbeddedSwift/UserManual.md#external-dependencies) for some explanations on external dependencies.

For instance, if you'll be allocating memory, you'll need to provide an implementation for posix\_memalign and free.

---

<div class="post-metadata">

**Author:** ![iCMDdev](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/icmddev/32/32393_2.png) [@iCMDdev](https://forums.swift.org/u/iCMDdev)\
**Post date:** [October 26, 2024, 1:40pm UTC](https://forums.swift.org/t/undefined-symbols-in-embedded-swift-are-they-ok-to-ignore/75634/3 "2024-10-26T13:40:46Z")

</div>

That's exactly what I was looking for but couldn't find it. Thanks a lot!

> For instance, if you'll be allocating memory, you'll need to provide an implementation for posix\_memalign and free.

Yeah, makes sense. That's why I was afraid of these warnings, the stack protectors and putchar were pretty self-explanatory compared to the allocation stuff.
