-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fixincludes problem with SDKs 16.0 #11
Comments
there are some fixes queued up - waiting for some time to do release tests - I have, however, pushed the ones under test to the gcc-14-2-darwin branch (but not yet made a release) - is that what you've tested? |
@fxcoudert - ISTR you had a fix for this ? (I guess that also needs back-porting) |
I think it is r15-1697-g1dc14318155057 - will look at doing the back port to 14. over the weekend |
No, mine was gcc-14.2-darwin-r1 [edit] I don’t recognise the "gcc-14.2-darwin-r1 branch"? [edit2] I meant to say "gcc-14.2-darwin branch" -- which I've now found, after a 'git fetch' |
Is that error from a fresh compilation against the new Xcode and CLT? Or is that using a compiler built against CLT 15 on a system with CLT 16? Also, what SDK version was it compiled against, and is it being run against? I have one fix related to |
The compiler was built against CLT 15.3 and was reported to me having being run on a system with macOS 14.7 and Xcode 16.0. I find the same behaviour with macOS 15.0.1 and CLT 16.0 (and also with GCC 13.2, built from gcc-13.2-darwin-r0 against CLT 14.2). |
That's the issue: the compiler should be used with the same SDK they were built against. We don't have a systematic way to support running against a different SDK than the build one. |
so should I do the noted back port or is it not needed (assuming the criterion above is applied)? |
Commit 1dc143181550573c9c902fb7a3b495e9b409d0b0 should be backported to all branches. But I don't think this bug is related. |
Homebrew's GCC 14.2 (installed just now) manages to run just fine on a Sonoma system with CLT 16.0 and also with CLT 15.3. It looks to me as though HB builds GCC using the FSF distribution + patches derived from Iain's distribution here, is that right? I just applied those patches of FSF GCC 14.2.0, built with CLT 15.3, but the result fails with CLT 16.0. My interest is in supporting Ada users, and I need to minimise the difficulty they encounter in the macOS environment. Since raising this issue, I've of course advised people not to allow their machines to update to SDK 16 -- which isn't ideal. |
The fact is that SDKs from different Xcode releases can contain incompatible changes. Since the process of building GCC (unfortunately) captures some information from the SDK into the build - we cannot (as things stand) guarantee that a build made with Xcode N will work with Xcode N-1 or N+1 (it might, but that's a matter of luck). To make things as simple as possible for your end-users, I guess you could provide builds against Xcode 15 and 16, then they have to update their GCC if they update their Xcode? Everything is fixable - if we had a team of folks working on GCC for macOS for their $dayjob, we could surely do better - - but that's a long way from reality at the moment ;) |
Not sure how to do that. Trying to use a GCC built against CLT 15 to build a compiler against CLT 16 fails very early on in configure .. unable to build a C executable. |
Do you have both the CLT installations available? |
IFF you have Xcode CLT 16 installed, but you built the XC 15 one using on your configure line Where NN is the relevant Darwin version for the bootstrap toolchain (i.e. the one built against the MacOS14 SDK in Xcode 15). |
The goal here is for the bootstrap toolchain to use the SDK it was built against - not to try and use the updated one installed in Under these circumstances it can be better to be specific about the SDK you are using. Yes, we want it to be easier - which is why there's been an effort to reduce the dependency on fixincludes - but we cannot, unfortunately, get that dependency to 0 as things stand. |
In /Library/Developer I have CommandLineTools-15.3 and CommandLineTools-16.0, and a symlink CommandLineTools selecting which one I want to use. It would be great if xcode-select --switch worked, but it doesn’t (it looks OK, but fails when you try to use it). I’ll try your suggestion tomorrow when rested! I suspect I may have to build an intermediate compiler that doesn’t have my adventurous specs fix, which I still haven’t posted a BZ about, sorry:
|
At the risk of being repetitive - this is known to be broken - in particular, w.r.t. fixincludes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7988 |
Is this documented somewhere when using the precompiled gcc versions from gcc? Currently, I am also struggling with compiling gRPC. I don't want and will hijack this thread ;-). But this detail would interest me if this is documented somewhere. |
This worked just fine.
You won't be surprised to learn that this compiler fails against CLT 15.3!
|
actually, that might be the one fixed by the pending backport - don't know if I'll get to it today - still doing the weekly rebases. |
I've now pushed that back port too - tested on macOS 12 only so far - so not making a release just yet - but if you want to test if the latest allows you some more flexibility ... |
where are we with this issue? AFAIK I have now applied the relevant back ports - and just pushed a fix for another GCC/clang incompatibility. |
fixed in gcc-14.2-darwin-r2 |
Hi Iain, @iains I did a new xPack GCC build with r2. The x64 binaries are fine (built on 10.14.6 with CLT 10.3 and MACOSX_DEPLOYMENT_TARGET=10.13, tested on macOS 12.7.6 with CLT 14.2), but unfortunately the arm64 binaries still fail when running in a newer environment (my build machine is macOS 11.7 with CLT 13.2, and the GitHub test machine is a 14.7.1 with Xcode 15.4). The error is the well known stdio.h mismatch:
I read your comments about the lack of resources for fixing this. Unfortunately, apart from testing, there is not much I can do to help you. If your final resolution is that there is nothing to do to fix the arm64 GCC such that builds performed on 11.7 (+CLT 13.2) to run on later environments, I'm afraid all I can do is to document it as unusable and move forward. :-( |
Can you not update your build machine to a newer OS ? macOS11 is a bit of an odd version to stick with, particularly on an ARM machine - the later OS versions improve arm support quite a bit... |
Unfortunately not :-( xPack GCC is one of the 20+ projects that I build, and all binaries are based on older OSes (Ubuntu 18 for Linux, macOS 10.13 for x64 and macOS 11.7 for arm64). I have only one M1 Mac Mini, and it'll stay on 11.7 for the foreseeable future. It is a pity that only macOS GCC has this problem, all other projects built on older machines run just fine on recent versions. |
My previous statement that the x64 GCC is functional is not true. I paid one month of GitHub Team to get access to all GitHub runners, and so I was able to run tests on more versions. It looks like there is no difference between x64 and arm64, both fail on macOS 14 and 15. To conclude, with gcc-14.2-darwin-r2:
The Xcode version was obtained with I'm a bit confused why on macOS 14.7.1 CLT is 16.1 and Xcode is 15.4. The two runs are:
I'm running out of ideas of what else I can do to help. :-( @iains, any conclusion to this? Any chance to find a solution, or building GCC on an older version of macOS is a lost struggle? |
I regularly build GCC [x86_64 and arm64] on macOS 11, 12, 13 and 14 (with the relevant Xcode CLT for each) As we have noted - there is no easy solution for the fix includes incompatibilities between CLT versions (sometimes). However a compiler version for (e.g.) macOS11 should still be able to build binaries that run on macOS 12..14 .. after all you do not expect your existing apps to stop working when you update the OS, do you? That is, I would expect you can build perfectly functional compilers on all the versions where an earlier version is capable of building binaries that will run on a later one - and a later one is able to use -mmacosx-version-min= as needed. What is not currently and without significant effort supported is a compiler built with one SDK using a different SDK. Again, I would expect you can build working compilers for each platform version - maybe that's a pain - but after all you cannot run Xcode for macOS N on some arbitrary earlier macOS .. there are some constraints even there. limited hardware means I don't have a setup for macOS15 yet.. ... because of WG21 commitments I will not be able to poke at this for the next couple of weeks, I'd be very happy to make this my $dayjob and then we could try these extra improvements .. but until then .. |
Well, I have such a program built on macOS 11, which runs perfectly fine on macOS 11, 12 & 13. After I upgraded to 14 & 15, it failed. This program is called...
My build machine is 11.7 and I use
Yes, this seems to be a big challenge for GCC. :-(
For now I'll update the documentation to mention that the binaries work up to macOS 13, and switch all my test to clang. If, before the next major GCC release, you'll find a solution to make a GCC built on macOS 11 run properly on macOS 14 & 15, I'll gladly adopt it, otherwise I have no choice but discontinue the GCC binaries for macOS. :-( |
That's not the full situation - IFF the SDKs did not contain headers that needed correction, we would not have this issue. Since we cannot change the SDKs .. we have no choice but to work around issues. Anyway, you are free to do whatever you wish - the compiler will work within its constraints. |
I know it is different, but didn't clang manage to work around these issues? |
It does not have to work around some of the issues - because the extensions it supports (either accidentally or intentionally) like (for ex) using C++ features in C code, are obviously compatible with the SDK headers. However - the following still fires on clang. cat t.c:
FAOD: I am not disputing that the use of these functions can lead to code vulnerabilities - however, the deprecation should be opt-in - not forced on the end-user. When code is built with WError, this becomes a build fail (sure, there are work-arounds - but that involves changing every project that uses the compiler ... ) So we patch the header to make the deprecation opt-in.
|
Ah, so the extra patches for GCC are needed only to avoid the clang extensions?
Good to know. I am probably lucky, in the xPack project I compiled from sources about 70 open source projects and I don't remember encountering this issue. |
@iains I thought this problem was fixed like a month ago, got gcc |
I do not know the status of Homebrew - I've been at WG21 last week so in the process of refreshing builds etc. What is the exact CLT version you are using? |
It's |
well, I tried the current 'trunk' (gcc-15) and the gcc-14.2-darwin branch with xc 16.1b2 on macOS14 and it behaves as I expect. Essentially, for the transition between the SDKs for macOS 14 and 15 you have to make sure that the compiler uses the SDK it was built with. what is your configure line? and what are you using for the bootstrap/build compiler? |
In other words, building compiler binaries that remain functional on new SDKs is not possible. :-( in my development environment, I have unit tests that run with GCC 11, 12, 13, 14, etc. The GCC binaries were built on an older macOS, and were functional on all macOSes and SDKs up to 15. What you basically say is that now I have to recompile all GCC 11, 12, 13, 14 using SDK 16, next year to recompile all again using SDK 17, etc, and so on. I'm afraid this is not reasonable. :-( |
@ilg-ul My trick is to keep the various CLT releases, each in their own directory, and use a symlink to pick the right one; in /Library/Developer I have
At the moment I’m linking to 15.3, because I had to use a compiler built against MacOS14.sdk. The only thing to be wary of is accepting a CLT update while the symlink is in place! Of course this trick won’t work if you’re developing compilers for distribution to users, where you don’t have control over what SDK they may be using. |
Only if Apple happens to make incompatible changes in the new SDK .. which we cannot predict.
Then what would you suggest? macOS is supported by one person part-time as a volunteer - building our own SDK or updating GCC to handle all the clang extensions is technically feasible - but not with those resources - it needs one or more people working on if full time - and even then it would be hard to keep up. I am open to suggestions or patches from other contributors. |
I would first document as clearly as possible the issue (for example in a GitHub wiki page), why binaries built on an old SDK fail when Apple makes changes to their SDKs. Then I would try to understand why the problem does not affect clang. Once the problem is understood and documented, I would suggest several solutions, and estimate how much effort does them require. I have no idea how GNU/FSF/etc are organised and how various projects are supported, but having some clear proposals might improve the chances of getting some help in finding resources. Personally I don't have the knowledge nor the time necessary to work full time on this, but I can help with testing, if necessary. The work on the xPack binary distributions is also the result of a one man show, and I don't expect any income from them. I hoped that I can use GCC for my unit tests, but if the binaries are not portable across multiple macOS SDKs, they are simply not usable (my project is called 'xPack - The Reproducible Build Framework', and currently the GCC behaviour is not reproducible). My only solution is to disable the GCC tests on macOS, and run the tests only via multiple versions of clang; I'll keep the GCC tests only on Linux/Windows. |
Please go ahead and do these things - the answers to those points are all in this Issue thread. |
Unfortunately I do not understand the problem well enough, and I am not able to suggest solutions. :-( |
By "behaves as I expect" do you mean that it works?
Sorry if I was unclear but I don't build GCC from sources, I'm using the one provided by brew and seems it doesn't have the fix. Here's an example of error message:
|
yes.
For homebrew-related questions, you'll need to ask them there - although we work closely, I do not know the details of their distribution. |
Hm, I decided to check what's in
? |
macOS 14 and and macOS 15.
Xcode CLT 16. |
Just for the reference, I ran this command |
For n = 14, 15, 16 CLT n includes SDKs for macOS n-1, n-2. I don’t know about earlier releases. |
Under those circumstances. Suppose that you have a GCC built with SDK n-1 and you want to run on macOS n. You can always invoke the compiler "xxxx-darwinMM-g?? --sysroot=/path/to/sdk-n-1" and it should work. This is also exactly what I do to bootstrap with n+1 CLT installed on n. |
Just for completeness, you can also set the environment variable SDKROOT to point to your preferred SDK, and GCC (as clang) will also respect this and use that. I personally have
in my shell profile so its set by default to point at the same SDK as I have configure Xcode to use as its default. |
XCode & CLT 16.0 were released with macOS 14.7, and now we get e.g.
What would help?
The text was updated successfully, but these errors were encountered: