-
Notifications
You must be signed in to change notification settings - Fork 229
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
Support older versions of GCC #123
Comments
Looks like this is a follow-up to #111. Couple things:
|
Hi @ligfx! Re Re each of Re C++11 atomic restriction: You can't just assume that because you're using a C++ compiler, that C++11 atomics are available. Visual Studio didn't have them until 11.0 (VS2012). Re Re Re Re pull requests: You don't think patches are easier to read? That's the pure change, boiled down. Testing locally, ehh... applying a patch versus cloning/checking out the appropriate commit... bit of a wash, seems like... |
Here is my revised patch: libsoundio-older-gcc-v2.patch.txt This also addresses a couple of wrinkles found in testing: The math functions sometimes (but not always) require By the way, on a related note... is |
Simpler and more semantic to use the compiler's built-in type-checking: struct SoundIoAtomicBool {
bool x;
};
__attribute__((always_inline))
inline bool SOUNDIO_ATOMIC_EXCHANGE(SoundIoAtomicBool a, bool value) {
return __sync_val_compare_and_swap(&a.x, !value, value);
}
According to the type signatures of the other implementations:
The new patch is still effectively removing build features while making it more complicated. Now, only Clang|GNU|Intel compilers get the chance to benefit from certain flags, while other logic is duplicated between "Clang|GNU|Intel" and others. My point above was that, since you're checking whether the flags work anyways, you don't and shouldn't check the compiler IDs. You've replaced a simple, albeit not-always-true, knowledge check ("all non-MSVC compilers support these flags"), with a redundant combination of a knowledge check ("compilers with these IDs might support these flags") and an empirical test ("does the current compiler support these flags?"). All other things equal, it's better to rely on empirical testing, which will always work, than on knowledge checks, which can become outdated or be too general. (Main overriding concerns I've seen include 1) testing for MSVC specifically, since it's so different, and 2) simple knowledge checks, as the current state of the code, where simplicity and getting started are more important than working everywhere).
I'm thinking of a case with either a current uncommon compiler, or a future compiler, where certain flags don't work but others do. Not sure how likely that is. I'm still a fan of separating flags out, since I think it's easier to keep a handle on mentally, and can be done in a very semantic, declarative way ("We want these flags, if possible").
Okay, this isn't related to "Support older versions of GCC," and should go in a separate patch.
Right, CMake checks that a header is 1) includable and 2) compilable.
100% Pull Requests are easier to deal with than patches. They're integrated with the rest of GitHub, so you can comment inline on specific changes, see the context in the rest of the code, see the difference between revisions, and link them to from elsewhere. It comes down to consistency: when everything else is using Pull Requests, it's a break in workflow to download and look at a patch. This involves more time and effort, making it less likely for your patch to get reviewed. |
Yep, all that's covered.
What you know is that compilers with these IDs can take options that look like It's quite risky to test a set of flags against a compiler without knowing anything about it, because sometimes the results play out unpredictably. Here's a tidbit from one of my other projects where I had to deal with this (note the bit about
It's a lot harder than you're giving it credit for. (And my work on AX_PTHREAD has been hampered by no longer having access to some of the systems it supports for testing.)
You can thank Microsoft for that ^_^ (Besides, as I understand, the C++ implementation was added primarily for the benefit of Windows builds)
Once your project specifies a set of compiler flags that augments/overrides the user's, you've left the path of simplicity. In normal practice, you're supposed to use whatever flags the user specifies, and if those aren't good enough, then complain appropriately.
Well, there's many other compilers besides Clang/GNU/Intel. That's why I added a third clause to the big flag-conditional, the one that only sets -D flags. It's a sign of code-amateurism when you try to build a project on (say) AIX and
Yes, that is a good approach, though you still have to limit the set of flags by compiler category (Clang, GNU) or system (non-Clang/GCC on AIX, Solaris, etc.). I'd do (and have done) that kind of thing. But here, it's not really worth the candle. What's the benefit? All that matters is that the build doesn't break.
That's one of the nice things about patches: A maintainer can break them out however s/he likes across multiple commits, rather than me having to guess what level of granularity is desired.
Don't forget the bit in Sure, that approach would work. But then you have to touch three files instead of one, and the conditional no longer changes when you switch between
What happens when there are changes in someone else's tree that you want, but you want them in a different form? Maybe you want to structure the commits differently, maybe the code is indented a little sloppily in places. Accepting a pull request means that whatever the developer is submitting is going into your repo as-is. |
Either you fix the issues in a post merge commit or ask the submitter to fix the issues and to squash unneeded commits and restructuring the pull request. |
Then why the
It wouldn't, because
The issue title should be renamed "Support older versions of GCC and other compilers," then. Generally it's nice to make the maintainer do as little work as possible... Instead of complaining, why not just split the patch out? I've found that code gets accepted much faster when I do what people ask in good faith, rather than argue technicalities.
On macOS, |
A merge won't restructure the commits. Unneeded commits is one possibility; not enough separate commits (or even separate pulls) is another. Asking a submitter to restructure their submission... it's like... it's not enough that they're giving you fifty quid, but they have to give you exactly three tens and four fives? Completely apart from the content of the change, which is what matters at the end of the day. I mean, I've done pull requests before, but it wears down the patience of both the maintainer and the submitter when you have issues not related to the actual changes getting in the way. From my perspective, patches lower the stakes. It's "just gimme the goods, screw the formalities."
The braced-groups are needed for the EXCHANGE and STORE operations, to group together the multiple statements into one. For FETCH_ADD and TEST_AND_SET, they are not strictly necessary, but quash some (Was that what you were looking for? I'm not quite sure what you were asking...)
Unless compiler FooCC interprets that as The only flags that are generally safe across the board are the bog-standard ones:
That's not an ad hominem; that's an ad codinum ^_^ More seriously, of course people don't do this because there's something wrong with them. People do it because, when all they've ever used is Clang/GCC, and those do everything they need to do, why seek out anything beyond? It's not a problem as long as they're willing to allow support for farther-flung systems when the point arises. Remember, too: "Amateur" is not an insult. (Unless applied to a professional software developer...)
Negative; the Incidentally, there are some 3rd-party libraries out there that provide cross-platform atomic operations (Concurrency Kit and libatomic-ops), but even I don't care enough to bother with them.
I'll do that if a maintainer asks. But it's not necessarily the case that splitting out a patch makes less work for him/her; we're just guessing. What I often do, for example, is dump a bunch of changes into my tree, test them out, and then put together one or more commits just the way I want them by firing up
Well, facilely, some non-GNU/Clang compiler that is C11 compliant but takes a different flag to enable that mode. But even then, it's a lot to assume that a C11 header will work correctly if you're not in C11 mode. |
Oh, I see. The Did you see my earlier comment about type-checking the EXCHANGE operation?
We're getting off-topic. It's highly unlikely this project will ever be compiled by a FooCC with pathological command-line behaviour.
I meant that since this also affects the C++ implementation, and changes the behavior of CFLAGS, then "Support older versions of GCC" no longer accurately describes the entire patch. |
I wasn't trying to imitate
Ah, missed that. Yes, an inline function would work handily there :-)
Until it is. If libsoundio becomes popular---and I'm certainly hoping to see that---the probability will approach 1.
Ensuring correct feature-test conditional behavior and proper compiler and compatible-flags identification are part and parcel of this work. What different title would you suggest? |
libsoundio-older-gcc.patch.txt
This patch against the Git v2 branch contains the following:
SOUNDIO_ATOMIC_*
based on GCC's__sync_*()
builtinsatomics.h
to select the appropriate implementation ofSOUNDIO_ATOMIC_*
-std=c11
, as well as some warning flags that older GCC versions don't know aboutThe text was updated successfully, but these errors were encountered: