-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clang] Fix name conflict with sys/mac.h
on AIX
#88644
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
Conversation
Fixes clang-ppc64-aix bot failure after llvm#88559 (0a6f6df) https://lab.llvm.org/buildbot/#/builders/214/builds/11887
@llvm/pr-subscribers-clang Author: Vlad Serebrennikov (Endilll) ChangesFixes clang-ppc64-aix bot failure after #88559 (0a6f6df) https://lab.llvm.org/buildbot/#/builders/214/builds/11887 Full diff: https://github.com/llvm/llvm-project/pull/88644.diff 1 Files Affected:
diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h
index acc6bb6581d857..3908e10bc61061 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -50,6 +50,11 @@ const char *CudaVersionToString(CudaVersion V);
// Input is "Major.Minor"
CudaVersion CudaStringToVersion(const llvm::Twine &S);
+// We have a name conflict with sys/mac.h on AIX
+#ifdef _AIX
+#undef SM_32
+#endif
+
enum class CudaArch {
UNUSED,
UNKNOWN,
|
Co-authored-by: Joseph Huber <huberjn@outlook.com>
I can't really think of anything more clever here unfortunately and we should probably unbreak the bot. Maybe someone more familiar with PowerPC knows if it's possible to simply not include this header somewhere. |
Fixes clang-ppc64-aix bot failure after llvm#88559 (0a6f6df) https://lab.llvm.org/buildbot/#/builders/214/builds/11887 --------- Co-authored-by: Joseph Huber <huberjn@outlook.com>
// We have a name conflict with sys/mac.h on AIX | ||
#ifdef SM_32 | ||
#undef SM_32 | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh. What could possibly go wrong, if someone who needed the original definition of SM_32 ends up transitively including this header and losing the macro definition?
A better way to handle it as a workaround would be to push the macro definition, undef it, and then pop it back at the end of the header.
Even better would be to add prefixes to the macros and/or the enum here to disambiguate them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already do that, the problem is that CudaArch::SM_32
will still invoke the preprocessorr, see https://godbolt.org/z/84xKej5K9. We can't do this from a header level, we'd need to do it around every single use as far as I know, which might be doable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could always just make all of these lower case instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could always just make all of these lower case instead?
That would be odd. LLVM style wants them to be CamelCased.
This enum is rarely used, so renaming them to something more CUDA/NVPTXspecific would be best, IMO.
E.g NVSM_32
Or we could rename only SM_32
. The constant is rather inconsequential and is used in a few places only. Renaming it to _SM_32
with a comment that AIX headers have SM_32
defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, modern CUDA installations don't even allow you to build for anything older than sm_52
now. We could also just delete those enums entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just naming it like _SM_32
works for me, with a note that they'll get removed in the future. I can make the PR if you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_SM_32
is a reserved identifier so we should not use that as a name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, totally forgot that _<uppercase>
was reserved (Would've been nice if the AIX headers followed that rule).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM. Thank you for taking care of this issue.
On a side note, do we know if there's a way to file a bug for AIX? They should not be setting macros with names that could conceivably be defined by a user. In theory. I think normally they should be double-underscore-prefixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in #88779
Fixes clang-ppc64-aix bot failure after #88559 (0a6f6df) https://lab.llvm.org/buildbot/#/builders/214/builds/11887