-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add -fno-merge-constants to default flags? #63
Comments
@conda-forge/ctng-compiler-activation Any thoughts? |
cc @conda-forge/core @isuruf I have no relevant expertise or opinions here myself. |
This seems reasonable and necessary. Conda assumes it can rewrite variables, but c is using them in a way that makes this impossible. If you use conda's strategy of rewriting strings in code, you just tell the compiler not to reuse them. As this is enabled at -O1 we should likely set this conda wide. |
For the uninitiated
|
Copying from gitter to try and explain exactly how this can go wrong:
I've only seen it happen on ppc64le, though I think it could happen for any software compiled with GCC (clang appears to not support this optimisation). |
Thank you for copying that, hard to copy from a phone. I'm not too familiar with this recipe but is the following file the best place to suggest an addition? It seems that some templating is being used to replace |
Yes the flags go in there afaik. |
I don't think this is a good idea in general. Some packages might be relying on this behaviour to do quick string comparisons and we'll be breaking them. |
Can you think of any packages where this is actually the case? Unless it's widespread I think it's more important to avoid subtly broken packages which are hard to debug. I even could imagine this causing security issues if we get unlucky. Even if someone has a package which is performing poorly when built for conda-forge, the compilation flags are an obvious place to check so hopefully it wouldn't be too hard to identify. |
I don't know of any package at the moment. I'm wary of adding flags that affect code generation and we've been trying to go the other way by removing default flags. (flags like -std=c++17 and -fopenmp are removed). This PR on the other hand goes the other way by adding a flag that affects code generation. |
In general I agree with you but the need for this flag is really specific to how conda works and hard to identify when it goes wrong. Unlike the other flags you mention, it’s only an optimisation so it can’t cause builds to behave differently (ignoring a potential performance impact). Ideally there would be a mechanism to prevent this optimisation for a specific string rather than all constants but I can’t find anything. If you want to be conservative we could consider only adding it for ppc64le as I’ve not yet seen an aarch64 or x86_64 build fail? |
It can behave differently. That was my point above about string pointer comparisons being unequal with this flag set. |
Sorry I struggle to see how code can rely on this as at There is also no guarantee that GCC will actually merge constants, even when passing |
Maybe @katietz knows more about the consequences of enabling |
I think I cannot completely follow the first sentence. |
I also asked a few nearby compiler experts and they all think that:
|
Isuru's message has a typo @wolfv. You are correct that we should add -fno-merge-constants. |
I've now had two different packages that broke when relocating due to
-fmerge-constants
being enabled by default (see the gitter link for an explanation of why this optimisation is problematic):@conda-forge/ctng-compiler-activation What do you think of adding
-fno-merge-constants
to the default flags?The text was updated successfully, but these errors were encountered: