[Bug 278551] lang/gcc: exceptions do not work in statically linked binaries

2024-04-27 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278551

--- Comment #23 from Mark Millard  ---
(In reply to Mark Millard from comment #21)

Another combination that works uses libc++ instead
(pthread example again):

g++13 -static -pthread -stdlib=libc++
lang-gcc-g++-exception-handling-with-threads.cpp -o
lang-gcc-g++-exception-handling-with-threads &&
/lang-gcc-g++-exception-handling-with-threads

-- 
You are receiving this mail because:
You are the assignee for the bug.


[Bug 278551] lang/gcc: exceptions do not work in statically linked binaries

2024-04-27 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278551

--- Comment #22 from Mark Millard  ---
(In reply to Mark Millard from comment #21)

Probably not obvious for my prior note: The final -Wl,--eh-frame-hdr case
does, in fact, also print the line:

FreeBSD doesn't reach here.

-- 
You are receiving this mail because:
You are the assignee for the bug.


[Bug 278551] lang/gcc: exceptions do not work in statically linked binaries

2024-04-27 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278551

--- Comment #21 from Mark Millard  ---
(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 -staticlang-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 
Commit: Wen Heping 
CommitDate: 2024-04-22 00:04:50 +
branch: main
merge-base: 62a76b7dc95aa8c2a74b06f92b0a8b752e3b1848
merge-base: CommitDate: 2024-04-22 00:04:50 +
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(
,
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.


[Bug 278551] lang/gcc: exceptions do not work in statically linked binaries

2024-04-27 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278551

--- Comment #20 from Mohammed Goder  ---
So should this be reported upstream? If so, am I supposed to do that or will
you guys be handling the rest of this?

-- 
You are receiving this mail because:
You are the assignee for the bug.