April 14, 2023
https://issues.dlang.org/show_bug.cgi?id=23839

          Issue ID: 23839
           Summary: Bogus unresolved ".eh" symbol error on macOS
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: sludwig@outerproduct.org

Created attachment 1870
  --> https://issues.dlang.org/attachment.cgi?id=1870&action=edit
Reproduction case, run ./test.sh

The full error message when running the attached ./test.sh on DMD 2.103.0 is the following:

---
Undefined symbols for architecture x86_64:
  "_c.ImageBuffer.copySubImage.eh", referenced from:
      __D1c11ImageBuffer6__ctorMFZCQBaQBb in lib.a(c_210_43d.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: linker exited with status 1
---

This appears to be a low-level bug involing a wrong index into a symbol table or a wrong binary offset of some kind, as adding or removing symbols in one place leads to different methods being affected. The original code base had multiple unresolved ".eh" symbols and multiple places that allegedly referenced those.

I tried to reduce the code further for quite a long time (coming from a large code base), but couldn't really do it, changing almost anything will now make the error go away, removing the "import std;" in particular was not possible. Changing the length of string constants or symbol names will also shift the error to different methods.

Compiling the same code in the same manner with LDC works without issues.

--