swiftlang / swift-testing

A modern, expressive testing package for Swift
Apache License 2.0
1.79k stars 77 forks source link

Stop calling runtime-internal function to enumerate tests on ELF platforms #735

Open grynspan opened 1 month ago

grynspan commented 1 month ago

Currently, on ELF only, we need to call an internal runtime function swift_enumerateAllMetadataSections() in order to find sections that contain our metadata. That's because ELF binaries generally don't preserve section header information. I'd love for our platform-specific implementation to look like:

template <typename SectionEnumerator>
static void enumerateTypeMetadataSections(const SectionEnumerator& body) {
  dl_iterate_phdr([] (struct dl_phdr_info *info, size_t size, void *context) -> int {
    const SectionEnumerator& body = *reinterpret_cast<SectionEnumerator *>(context);

    bool stop = false;
    if (auto sb = /* ??? */(info)) {
      body(sb, &stop);
    }
    return stop;
  }, const_cast<SectionEnumerator *>(&body));
}
grynspan commented 1 month ago

Potentially addressed by https://github.com/swiftlang/swift/issues/76698.

grynspan commented 4 weeks ago

Tracked internally as rdar://136789701.