-
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
Issues with API_AVAILABLE macro (Error: attributes are not allowed on a function-definition) #12
Comments
I cannot really comment on the exact situation with HB - you would probably be better to ask a question there.
Yes, they do look related; but certainly the fixincludes for that were removed in b50a053 which corresponds to gcc-14.2-darwin-r1 (but I do not know the exact designation for HB)
|
OK, fair enough. I thought you would be in close contact with the Homebrew maintainers and/or even contributing directly there. Can I see somehow which CLT were used to create a specific gcc HB version if not compiled by myself?
In other words you would not expect such errors when using As far as I can see the changes from b50a053 are also applied to the HB version (https://raw.githubusercontent.com/Homebrew/formula-patches/d5dcb918a951b2dcf2d7702db75eb29ef144f614/gcc/gcc-14.2.0.diff). |
We are on close contact :) @fxcoudert is closely involved with the branches here - but what is done by the various "downstream" distributions is their call.
For any GCC you can see the configured sysroot with Unfortunately, if that is
Well .. I cannot be 100% certain without more checking - but what you showed looked pretty much like the same symptom - and, yes, I was under the impression that particular issue was resolved. You might double-check your CLT installation and make sure that all the symlinks point to somewhere expected? |
Regarding ...
It shows the
@iains Could you verify if this minimal as possible sample works on your side with the newest patches? CoreFoundation is included in several important projects (e.g. gRPC).
And the |
FWIW, I do not think that should be necessary - we ought to have compatibility within a major version ..
No. this fails for me too - because it's a genuine complaint :( In GCC, attributes are not allowed in that position on a function definition (IIRC, you can put them before the type - but no later). This is an incompatibility between what clang accepts and what GCC accepts (and TBH clang is supposed to be implementing compatible GNU attributes). As usual, we are between a rock and a hard place ..
At the moment, I have no work-around .... let me think some more. |
re...
NOTE: there are new patches on this branch that are under test (and we have not yet released 14.2-darwin-r2 because more testing is needed .. so it's quite likely that any patch after 14.2-darwin-r1 will not yet be in HB). |
I am testing an extension to allow us to accept attributes in this position |
Yes, Homebrew seems to be r1. As mentioned above I don't know how @fxcoudert creates the patch, therefore it's a little bit diffiult to verify 100%. |
Thank you for investigating and providing the explanations. At least I could reduce it to a minimal example! I understand the challenges we’re facing. My application supports multiple platforms, using LLVM Clang and GNU GCC on Linux and macOS, and it has many third-party dependencies. So sooner or later CoreFoundation is pulled in. It would be fantastic to find a solution. I’m also open to a macOS/Darwin-specific fix if that’s feasible. Just let me know if there’s anything you’d like me to test!
Thanks again for your support. Much appreciated! |
Well - the SDK has to be parsed by the compiler at compile-time - so both the cases need to be handled; |
This is to address Issue #12. It is very unlikely to be acceptable upstream, because the situation with how GNU attributes appertain is already very complex. This is strictly an extension to allow us to consume them in the same position as clang does. gcc/c-family/ChangeLog: * c.opt: gcc/c/ChangeLog: * c-parser.cc (c_parser_declaration_or_fndef): gcc/ChangeLog: * config/darwin.cc (darwin_override_options): gcc/cp/ChangeLog: * parser.cc (cp_parser_init_declarator): Signed-off-by: Iain Sandoe <iains@gcc.gnu.org>
i have just pushed a change that adds a new flag "-fallow-extended-attribute-placement" that is defaulted to 'on' for macOS/Darwin. To implement this means changes to both the C and C++ parsers - so that I think it should be tested as widely as possible (I have tested on i686-darwin17, x86_64-darwin17, x86_64-darwin23, aarch64-darwin21, 23 so far). Together the the other fixes and back ports, this would be what I propose to make gcc-14.2-darwin-r2... Please test in your environment. @fxcoudert - likewise, if possible. |
Wow, that sounds awesome! I'm currently a little limited in terms of hardware, as I'm on the road. I am happy to help with testing. Currently only with Intel CPU. I'll get back to you as soon as I've found the time. |
I've tested x86_64-darwin23 with CLT 15.3 (MacOSX14.4.sdk) and I have compiled a whole bunch of libraries like catch2, freeimage, freetype, grpc, gtest, libjpeg-turbo, libpng, libwebp, libzip, onetbb, openjpeg, openssl, protobuf, zlib, ... I was able to compile gRPC 1.65.0 now without any issues. Hooray 🎉! Also all other libraries compiled like a charm. libcurl 8.2.1 on the other hand made some issues. As referenced above they have implemented a workaroud in newer version. See here the build log. |
great!
I kinda wish folks would report the issue instead of hacking around it (unless there's no other option) - the problem with disabling functionality in one place is it breaks in another... |
OK so it looks like clang accepts GNU attributes in several places that GCC does not. I will need to find out where in the parser this is handled .. it could take a little while. |
It seems to be integrated into the Parser.cpp. At least there is mentioned [[attrib in one comment. It seems to be rather complex though. https://github.com/llvm/llvm-project/blob/main/clang/lib/Parse/Parser.cpp |
but... this does not actually seem to be the problem ... I cannot see a definition of . if I provide a perhaps the definition is supposed to be built from token concatenation.. I will have to look through the headers to figure that out. |
@fxcoudert do you have any reports about this? |
summary for the libcurl issue: with Fails to compile:
with Adding:
makes it succeed.... |
OK. I think I got to the bottom of this - two things interacting.
So clang (a) has attribute_availability_with_version_underscores and (b) advertises it. GCC has the feature, but does not currently advertise it which causes CFAvailability.h to expand a macro to a version that needs Perhaps the SDK was not checked with a compiler without the feature, anyway it seems that the fallback #define for Perhaps we should raise a Feedback for the missing #define .. but in the meantime I will arrange to advertise the features we support. |
This is a temporary workaround - we are going to advertise the availablility attribute as present for all targets - which it is not. For the Darwin branch it is a short-term band-aid. This addresses Issue #12 part 2. Signed-off-by: Iain Sandoe <iains@gcc.gnu.org>
I think that the two issues raised here should be resolved now - please test and report back - we can then go ahead with the R2 release... thanks. |
I tried the first time to compile it with XCLT 16.0, but there are new problems that seem to occur. I will create a new issue for this and retest with XCLT 15.x. |
It is always possible that we fix one case - and then that exposes the next...
thanks. (I am testing the current branch across OS versions - but not including XC16 or macOS 15 - however XC15 + macOS 14 are included) |
I think it is independent of the attributes issue. For more infos see issue #14 |
I will try to test it again with XCLT 15.3 and report back later. |
fixed in gcc-14.2-darwin-r2 |
I need to check again, but I think that the older libcurl version still has some problems. Since the main issue has been resolved I would create a new issue for it since only partially related to the original issue with the Thank you for the great support. Much appreciated! |
yes, please - it's good to keep issues separate |
In the meantime, I have been able to successfully test the project with Sonoma and CLT14 and Sequoia and CLT15. Since it has quite some dependencies in it, I just wanted to report it back. Everything works perfectly! Thanks again for the great support ❤️! The project also compiles on macOS with clang (19.x) and libstdc++ from gcc 14.2. I still have linker problems, but only on Apple Silicon with TLS despite using emulated-tls. But I'm still not sure what the problem is and if it is more related to clang or gcc/libstdc++ on Apple Silicon. If it is OK, I would open a new issue if I see that it could somehow be related to gcc. |
TLS on Arm64 is Issue #1 :) .. it's a question of having some time to implement it... |
I guess you mean this issue instead iains/gcc-darwin-arm64#1 |
I do - not sure why the auto-link failed there... |
Thanks for the link. Sure that this would also be related to emulated TLS? Still need to get things sorted and try to create a minimal example. |
Well you cannot expect to mix native and emulated TLS for the same variable (all TUs that use a given var have to agree on using one mechanism or the other). Otherwise, the two implementations should be independent. |
For completeness sake. This should have been the same issue: |
@iains This seems also to be the same issue. Not sure if this has been backported to other GCC versions as well. I let you answer this ;-). At least GCC 14.2 should resolve this issue as well. |
I am trying to upgrade gRPC on macOS (aarch64 and Intel). Currently, I am using Sonoma and the newest available gcc 14.2.0 version from Homebrew.
I am using the XCode Command Line Tools (CLT) 15.3. I read somewhere that it is crucial that the fixes have to match the CLT version which was used to build it which also makes sense since the fixes need to match. So I am not sure how to find out, if CLT 15.3 is the right one to take.
I also tried CLT 16.0 with the Homebrew version, but when reading other issues, I assume I would need to wait for an updated Homebrew version or compile one by myself. Looking forward for CLT 16.0 support. I appreciate all the work you invest to support gcc! ❤️
I read somewhere that the fixes for availability handling were removed. But now I am unsure what the issue could be and looking for support. At least for me the error messages look related.
Here an excerpt from the build log:
The text was updated successfully, but these errors were encountered: