[Bug 278551] lang/gcc: exceptions do not work in statically linked binaries
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 28 Apr 2024 03:49:54 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278551 --- Comment #21 from Mark Millard <marklmi26-fbsd@yahoo.com> --- (In reply to Mohammed Goder from comment #20) Niether With proper command line options the trivial test case variant below works just fine on FreeBSD. // File: lang-gcc-g++-exception-handling.cpp // On FreeBSD: // Works: g++13 -static -Wl,--eh-frame-hdr lang-gcc-g++-exception-handling.cpp -o lang-gcc-g++-exception-handling && ./lang-gcc-g++-exception-handling // FAILS: g++13 -static lang-gcc-g++-exception-handling.cpp -o lang-gcc-g++-exception-handling && ./lang-gcc-g++-exception-handling int main(int argc, char *argv[]) { try { throw (int)0; } catch (int i) { return 0; } return 1; } Such is also true with -static-libgcc -static-libstdc++ added to the command lines. I do not know if -Wl,--eh-frame-hdr should be implicit/automatic for FreeBSD. My test context was based on: # uname -apKU FreeBSD aarch64-main-pbase 15.0-CURRENT FreeBSD 15.0-CURRENT #5 main-n269589-9dcf39575efb-dirty: Sun Apr 21 01:42:00 PDT 2024 root@aarch64-main-pbase:/usr/obj/BUILDs/main-CA76-nodbg-clang/usr/main-src/arm64.aarch64/sys/GENERIC-NODBG-CA76 arm64 aarch64 1500018 1500018 # ~/fbsd-based-on-what-commit.sh -C /usr/ports 62a76b7dc95a (HEAD -> main, freebsd/main, freebsd/HEAD) graphics/mahotas: Update to 1.4.15 Author: Wen Heping <wen@FreeBSD.org> Commit: Wen Heping <wen@FreeBSD.org> CommitDate: 2024-04-22 00:04:50 +0000 branch: main merge-base: 62a76b7dc95aa8c2a74b06f92b0a8b752e3b1848 merge-base: CommitDate: 2024-04-22 00:04:50 +0000 n661234 (--first-parent --count for merge-base) I'll note that the same is true for: // File: lang-gcc-g++-exception-handling-with-threads.cpp // On FreeBSD: // Works: g++13 -static -Wl,--eh-frame-hdr -pthread lang-gcc-g++-exception-handling-with-threads.cpp -o lang-gcc-g++-exception-handling-with-threads && ./lang-gcc-g++-exception-handling-with-threads // FAILS: g++13 -static -pthread lang-gcc-g++-exception-handling-with-threads.cpp -o lang-gcc-g++-exception-handling-with-threads && ./lang-gcc-g++-exception-handling-with-threads #include "iostream" #include "cstdio" #include "pthread.h" #include "pthread_np.h" void* kernel(void* par) { printf("kernel\n"); return NULL; } int main(int argc, const char* const* args){ pthread_t thread; pthread_create( &thread, NULL, kernel, NULL ); pthread_join(thread, NULL); printf("FreeBSD doesn't reach here.\n"); return 0; } -- You are receiving this mail because: You are the assignee for the bug.