[Issue 23061] Exceptions cannot be caught by catch statement in static build

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 24 13:41:37 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=23061

Tomoya Tanjo <ttanjo at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #3 from Tomoya Tanjo <ttanjo at gmail.com> ---
I close this issue because it is a matter of linker options rather than
druntime itself.
It only happens when using `gcc` on Alpine Linux.
It does not happen when using `clang`.

When we use `gcc` as a linker, it needs `-Xlinker --eh-frame-hdr`.
```console
$ dmd -c app.d
$ gcc app.o -o app -m64 -static -Xlinker --eh-frame-hdr -Xlinker
--export-dynamic -L/usr/lib/ -Xlinker -Bstatic -lphobos2 -lpthread -lm -lrt
-ldl -lunwind
$ echo $?
0
```

When we use `clang` as a linker, it works without `-Xlinker --eh-frame-hdr`
because `clang` implicitly passes them to `ld`.
```console
$ dmd -c app.d
$ clang app.o -o app -m64 -static -Xlinker --export-dynamic -L/usr/lib/
-Xlinker -Bstatic -lphobos2 -lpthread -lm -lrt -ldl -lunwind
$ ./app
$ echo $?
0
```

--


More information about the Digitalmars-d-bugs mailing list