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
gcc: fix iostream init for Clang on Darwin #135530
Conversation
elsif OS.mac? | ||
# libstdc++: Fix iostream init for Clang on Darwin | ||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110432#c7 | ||
# https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=fe2651affa8c15624188bfd062fb894648743431 | ||
if version >= "13.2.0" | ||
odie "Review if the fix is still required." | ||
else | ||
inreplace "/usr/local/opt/gcc@13/include/c++/13/iostream", | ||
/^(#if !__has_attribute\(__init_priority__\))$/, '\1 || defined __APPLE__' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not do this in post_install
, please. Particularly since we are calling odie
, this should happen as early in the install process as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably this could also be done differently without odie
. I just wanted to assure that this fix gets removed for the GCC 13.2 release, since this should be fixed then.
Not sure why post_install
is not good since this will have no side effect for GCC itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the bottles needed to be recreated if we put it in install
? This is definitely not needed for the fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carlocab To avoid the odie
I could also change the if condition to `if version >= "13.1.0" && version < "13.2.0"
if version >= "13.1.0" && version < "13.2.0
inreplace "/usr/local/opt/gcc@13/include/c++/13/iostream",
/^(#if !__has_attribute\(__init_priority__\))$/, '\1 || defined __APPLE__'
end
Would this be better then? I thought to add the odie
that this part gets detected more easily and then can be removed. The odie
should never happen to a normal user. Only (probably) when a maintainer updates to the GCC >= 13.2.
if version >= "13.2.0" | ||
odie "Review if the fix is still required." | ||
else | ||
inreplace "/usr/local/opt/gcc@13/include/c++/13/iostream", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't hardcode /usr/local
here, as that isn't the only prefix that we support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#{HOMEBREW_PREFIX}
would be the correct replacement for it?
Thanks for the PR. I have a few comments, but we'll need approval from @fxcoudert before merging anything. |
The fix is fine, but we should:
|
I had communicated with the developers of the corresponding branch which is referenced in this recipe and both the maintainer of this branch and a developer of libstdc++ found the approach ok. I don't know if it is worth to solve this "cleanly" for GCC 13.1. It will not make any difference. iains/gcc-13-branch#6 (comment) @fxcoudert Would you or someone else take over? |
From the linked issue:
So is Homebrew. We prefer to ship the patch itself. Could you amend your PR to do that? |
@fxcoudert Not sure if I will find enough time for it. What would you expect. A separate patch which will be applied after: Line 15 in ce44ea3
If not please communicate exactly how to realize it and if the |
The upstream commit might apply directly: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=fe2651affa8c15624188bfd062fb894648743431;hp=d083c8c808cae2c7acb46117374bb047b4c3afce If not, a patch to formula-patches, ping me on the PR.
|
@fxcoudert : So, I would copy the patch content to a file and then apply it after the line 16 in a separate patch command if possible? Correct? Line 16 in ce44ea3
As far as I've seen it would be patcheable, but I will have to review the diffs. I just want get exact instructions not to do it twice. Thanks. |
Something like this may work: diff --git a/Formula/gcc.rb b/Formula/gcc.rb
index 87840c02dcb..04ccc7cc9e4 100644
--- a/Formula/gcc.rb
+++ b/Formula/gcc.rb
@@ -15,6 +15,12 @@ class Gcc < Formula
url "https://raw.githubusercontent.com/Homebrew/formula-patches/5c206c47/gcc/gcc-13.1.0.diff"
sha256 "cb4e8a89387f748a744da0273025d0dc2e3c76780cc390b18ada704676afea11"
end
+
+ # Brief comment here explaining what this patch is for and when it can likely be removed.
+ patch do
+ url "https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=fe2651affa8c15624188bfd062fb894648743431;hp=d083c8c808cae2c7acb46117374bb047b4c3afce"
+ sha256 "353ccd8e2c53277f208ad5015e64d4031a6c08eefe5ae0ddbbad22a52a64e100"
+ end
end
livecheck do |
The patch is not applicable from the existing diff file. This diff in the acinclude.m4 is ignored. @fxcoudert How to proceed? |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Since I've not received any further feedback I will not invest more time into it. The fix will implicitly be included in the 13.2 release of gcc. |
brew install --build-from-source <formula>
, where<formula>
is the name of the formula you're submitting?brew test <formula>
, where<formula>
is the name of the formula you're submitting?brew audit --strict <formula>
(after doingbrew install --build-from-source <formula>
)? If this is a new formula, does it passbrew audit --new <formula>
?This is a fix for gcc. Otherwise this will lead to an immediate segfault when including in when using Clang in combination with libstdc++ 13.1. I've added a guard that the fix needs to be revisited when GCC 13.2 is released.
More details can be found here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110432#c7
Here the fix which will be hopefully be included in GCC 13.2:
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=fe2651affa8c15624188bfd062fb894648743431
There is no need to recreate the bundles. Therefore I suppose that the version number does not need to be increased.