-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[release-0.4, RFC]: Remove 0-size and variable size array members from public headers. #14829
Conversation
LGTM except the API breakage. What's the error with GCC 6.0? Can it be work around with proper |
The exact error is:
I agree that only changing a flag would be ideal, but I haven't found one. Since this goes against the C standard, I'm not certain this error can be disabled. |
Is the error still there if you replace
|
Doesn't seem to make any difference: (At least, assuming that the last of
AFAIK C99 allows variable-length arrays, but only at the end of a non-empty struct. |
gnu99 maybe? I think C11 made optional a few of the gcc extensions from c99. Surprising to see gcc break their own extensions. Adjusting the headers like this is risky for a backport. I'd like embedders to test this before merging. |
Unfortunately, same result: But I've not found any reference about what happens when
Right. |
The error is in C++ so the standard for C shouldn't make a difference... Have you tried to reproduce it locally? (and run the failing command directly to make sure you only provide one To make this PR less risky, you can probably try to only change the |
I haven't, since I don't have the same gcc version on my distro release. But it does seem that the option takes effect, as passing
Sure. But what's the smallest independent set of changes I can retain? Just those affecting |
Does this help? The removal of |
Looks like it does, but I still get the |
For reference, I've filed a bug at https://bugzilla.redhat.com/show_bug.cgi?id=1302825. The joys of the bleeding edge... |
OK, now it works in Fedora. So looks like @yuyichao's patch is a cleaner solution than my patch. |
Oh, and skipping the part of the patch about |
@nalimilan Is it possible to backport the non-breaking part of my patch to the 0.4 branch (replace |
I'm fine with keeping the patch downstream and only backporting non-breaking changes. But I fear there's no good solution if we decide to support GCC6 at some point... |
Master should be fine already and I was just hoping that we can release 0.5 before GCC 6.1 is widely used in distributions. Another option is to only introduce the breaking change on GCC 6, should be as simple as conditionally not defining |
I've updated my branch to do that. Can you check if it works? The only breakage would be on gcc 6.0+ in c++ code, in which case there's nothing better we can do, and it shouldn't break any existing working setup. |
I actually had the same idea. Users of GCC 6 during the lifetime of Julia 0.4 will likely be a small minority, so only breaking the API there is a good solution. But your last patch isn't correct: you got the condition on the GCC version backward :-). Also, no need to check for That said, that behavior change in GCC isn't great, so I've filed a bug. If they close it, I guess we should merge your (fixed) patch: |
No, it's not valid in any C mode, and if you tried to compile it with a C compiler it would have failed years ago. But the issue is about C++ code not C, and previously G++ was not checking flexible array members properly. Now it is compatible with the C semantics (because flexible array members are not standard in C++, so the C rules are the sensible ones to follow). So previously it was rejected by |
I don't think so. It was accepted by both gcc and g++. |
No, the C compiler always rejected it long before GCC 6. http://ideone.com/YnOrru (I don't know what version of GCC that uses) http://melpon.org/wandbox/permlink/gsgofr0VzgxsF5Fw (GCC 4.8.2, with -std=gnu99) |
That code is not really what we have here. (Note that I'm not trying to argue it should be accepted, only it was accepted by GCC and G++ before 6.0) what we have is typedef struct mytype {
struct mytype *fieldptr0[0];
struct mytype *fieldptr[];
} mytype; which I believe is accepted by GCC and G++ < 6.0. Note that the first member is the 0-length array extension and not the C99 standard flexible array member. |
Then the GCC bug report that asks for the error to be relaxed should probably use the real code, so that we don't adjust the diagnostic to allow some other invalid piece of code that doesn't actually help you! |
I see that there's a typo in the code attached to the gcc bug report. Sorry about that. You can see what we have as |
Sorry for the confusion, I must say I don't quite get how the combination of these two tricky features works. Glad you replaced them with something less hacky. :-) |
On the GCC bug tracker, somebody noted:
What do you think of that solution? |
See keno's comment in my original pr. It was exactly the solution I tried first but it doesnt work since it causes a out of bound runtime error on osx. |
Too bad. Could you reply on the GCC bug tracker then? I wouldn't be able to explain the problem. |
Yeah, I'm going to do that. |
I meant, special-casing GCC without breaking the API, i.e. simply by using a zero-sized array instead of a flexible array. But if the problem is with the libc, we can't do that (except if we don't expect people to ue GCC 6 on Mac for some time). |
Homebrew usually updates pretty quickly so people on mac will likely be using gcc 6 soon after it gets released. |
@nalimilan @yuyichao what's the status here? Is this in a state that we can go ask some embedders to test against this branch and make sure this actually doesn't change anything relative to 0.4.3? |
The problem is, I think this will inevitably break this API for embedders. The only thing we can check is whether they use it or not. We could also ask gcc developers whether they think they are going to do something about this, even if they don't seem super enthusiastic. |
cc @waTeim would it be hard for you to test node-julia against this branch? |
@tkelman sure can, do I simply check out a branch and compile-install? BTW, as far as OS/X goes for embedding, it's always going to be what is provided by Xcode; clang or if explicitly g++ then only g++ as emulated by clang, so if this were a problem of g++ not flagging an error, wouldn't clang-g++ catch it anyway? And aren't new gcc features/fixes going to lag until they get incorporated by clang? |
@waTeim You should try the yyc/no-empty-struct-0.4 branch, which should be much less breaking then this one. (It'll only make a difference with GCC6 though, so you may want to remove the gcc version check to test it on a older gcc). |
@yuyichao Ok, so I'm kinda catching up on this. Are there 3 things do do then?
Do this on both Linux and OS/X if possible (don't think 3 on OS/X is possible for me). I do have access to Ubuntu 15 though, is that where gcc 6 is landing or is this still all speculative at this point? |
I'd say 1 and 2 (or even 2 only, since 1 should be non-breaking on non-gcc 6) should be good enough. It's clear that gcc 6 might be breaking something (like this case) but if it breaks node-julia other than the case we fix in our header, there's little we can do about it (Of course, you may want to make sure that node-julia will work on gcc 6 (i.e. do 3) but that's orthogonal to this PR). |
So I'm encountering this problem on step 1
is this a matter of having an old vers of gfortran?
|
That usually sounds like an |
not recently, no, it's been 5 months. But I think here's the thing.
It's gfortran that compiles openblas, is it not? Thus I need to update gfortran via homebrew? |
gcc developers just confirmed they won't allow to disable the error. So I think we should merge the fix conditional on GCC 6 to limit possible breakage. Anyway it can't be worse than a build failure. |
That's unfortunate. This is in julia.h so getting used in both C and C++, so is the "rejected in C mode" statement right? Which branch has your proposed conditional version? |
This commit is apparently the less breaking one: 2d9f368 |
Is there any reason to keep the contents of this PR's branch around? If not, we could force push that commit here and do it that way. I'm a little concerned about what happens if we upgrade the buildbots to use gcc 6 for creating nightlies, does that mean the binaries will get built in a way that does not match how embedding clients will then need to use them? |
There shouldn't be any ABI changes. |
No reason to keep this PR, but we've been using it as a tracker for this issue. Close once you'll have backported the other fix. |
May as well have the tracker for the issue also directly associated with the resolution of the issue? |
By removing flexible sized array in empty struct.
I've rebased the commit and pushed it to this branch. |
[release-0.4, RFC]: Remove 0-size and variable size array members from public headers.
Thanks! |
Backport of 63f3edf to release-0.4. This allows building with GCC 6.0.
GCC 6.0 has just entered Fedora rawhide, and it seems smart enough to detect empty structs with variable-size arrays despite of the tricks used in the code. This is a manual backport, but I'm not actually sure this doesn't introduce any ABI breakage. At #13945 (comment), @yuyichao said it didn't, but I'd like him to confirm this.
There's still the API break, though, so that's not ideal for embedding. A simpler work-around would be a better solution, if at all possible.