New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segmentation fault when using stdlibc++ from gcc 13.1 in combination with clang-16 #6
Comments
For completeness sake. I also started an issue on the GCC Bugzilla. But this might take some more time to get fixed. So we could already patch GCC 13.1 eventually. |
An easy and working fix would be to include this as a patch until GCC 13.2 comes out with a fixed version. What do you think?
|
Thanks to @jwakely for the fix. If would go for the easy fix as proposed above. @jwakely Do you think it would make sense to patch the current version in brew? If yes should I prepare a patch for it? I would go for a hotfix as proposed in the Bugzilla issue. Afterwards a new brew package would need to be built. |
For brew the |
Of course home-brew is free to choose independently ;) |
I would suggest that I will create a PR for gcc on brew. At the end we only need to patch a header file which might also be doable as post install step. Then I would close this issue here. Do you agree? |
Does HB intend to pull from 13.1 again (or just make a local fix)? I'd assume 13.2 would be a new version pulled from the (to be finalised) arm64 darwin 13.2 branch [this is WIP at the moment - but I will do a preview and let you and FX know where to look]
Sure - we have an upstream bug for it (which is fine because it affects an upstream target too) so we won't forget :) |
Both would be possible. I am not sure how many are using this gcc-13-branch directly. A local fix might be an easier path to follow. |
.. but people do build cross-compilers from Darwin to other platforms, perhaps not so much on homebrew (but I'm not sure it's 0 there). So, in general, I expect to be able to build a cross to xxxx-linux-gnu or x86_64-mingw-w64 etc. using these branches (and I usually test a few cases). However, that's just a general comment - in this specific case I doubt it makes any difference. |
I did not a lot of cross-compiles. But would |
no, it would not - but if the general (non-apple-specific) fix is needed for some other platform then we would want it on the Darwin branch too. [this is hypothetical in this case, we are all agreed that it is not a likely scenario] .. .. however, in general I will resist Darwin-only hacks (except for short-term band-aid) on the branches because that just makes upstreaming harder. |
Fully understand now. Thanks. I will close this and try to create a updated PR for brew. Thanks for both of you. |
Defining the variable in You could just remove the preprocessor directives and asm statement and leave the variable there unconditionally, that's what gcc 12 had. |
@jwakely Was easier to use your first band-aid idea with the inreplace method in Homebrew. I've added a safeguard such that the fix will be removed in GCC 13.2. |
GCC has changed the way how the global iostream objects are created since gcc 13.1. This can be found on the official page.
More details can also be found here:
https://developers.redhat.com/articles/2023/04/03/leaner-libstdc-gcc-13
On macOS
SUPPORTS_INIT_PRIORITY
within gcc is set to0
. This means that the global iostream object is not initialized and the fallback will be taken (i.e. static initialization of the iostream object).The problem is that when the iostream include is used, the expression
__has_attribute(__init_priority__)
istrue
since clang-16 supports__init_priority__
and the static initialization as before is not done. See here:https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/std/iostream#L78
This leads to a segmentation fault with a simple sample application when using clang-16 in combination with stdlibc++.
Sample application:
Execute test -> segfault.
I would suggest to add and document a patch for this. Basically we would need to include another #elif statement oder change this #if statement to include Darwin.
The text was updated successfully, but these errors were encountered: