-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc] Move __LLVM_LIBC__ define to __llvm-libc-common.h #126877
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
Relying on features.h is problematic since codebases are free to have such a header on their search path, which breaks compilation. libc should instead provide a more standard way of getting __LLVM_LIBC__. Since __llvm-libc-common.h is included from all libc headers, defining __LLVM_LIBC__ there ensures that this define is available whenever any of the standard header is included.
@llvm/pr-subscribers-libc Author: Petr Hosek (petrhosek) ChangesRelying on features.h is problematic since codebases are free to have such a header on their search path, which breaks compilation. libc should instead provide a more standard way of getting LLVM_LIBC. Since __llvm-libc-common.h is included from all libc headers, defining LLVM_LIBC there ensures that this define is available whenever any of the standard header is included. Full diff: https://github.com/llvm/llvm-project/pull/126877.diff 2 Files Affected:
diff --git a/libc/include/__llvm-libc-common.h b/libc/include/__llvm-libc-common.h
index d3f8a4e63268a..a0fa506c01ab8 100644
--- a/libc/include/__llvm-libc-common.h
+++ b/libc/include/__llvm-libc-common.h
@@ -9,6 +9,8 @@
#ifndef LLVM_LIBC_COMMON_H
#define LLVM_LIBC_COMMON_H
+#define __LLVM_LIBC__ 1
+
#ifdef __cplusplus
#undef __BEGIN_C_DECLS
diff --git a/libc/include/llvm-libc-macros/features-macros.h b/libc/include/llvm-libc-macros/features-macros.h
index 5bc87a68fc0ba..f87ae4ad12408 100644
--- a/libc/include/llvm-libc-macros/features-macros.h
+++ b/libc/include/llvm-libc-macros/features-macros.h
@@ -9,6 +9,4 @@
#ifndef LLVM_LIBC_MACROS_FEATURES_MACROS_H
#define LLVM_LIBC_MACROS_FEATURES_MACROS_H
-#define __LLVM_LIBC__ 1
-
#endif // LLVM_LIBC_MACROS_FEATURES_MACROS_H
|
I'm okay with this, but including |
It will since |
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.
LGTM
/cherry-pick b0d7820 |
/pull-request #126960 |
Relying on features.h is problematic since codebases are free to have such a header on their search path, which breaks compilation. libc should instead provide a more standard way of getting __LLVM_LIBC__. Since __llvm-libc-common.h is included from all libc headers, defining __LLVM_LIBC__ there ensures that this define is available whenever any of the standard header is included.
@@ -9,6 +9,4 @@ | |||
#ifndef LLVM_LIBC_MACROS_FEATURES_MACROS_H | |||
#define LLVM_LIBC_MACROS_FEATURES_MACROS_H | |||
|
|||
#define __LLVM_LIBC__ 1 | |||
|
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.
perhaps we should have just deleted this file? It's literally only now empty header guards.
Relying on features.h is problematic since codebases are free to have such a header on their search path, which breaks compilation. libc should instead provide a more standard way of getting __LLVM_LIBC__. Since __llvm-libc-common.h is included from all libc headers, defining __LLVM_LIBC__ there ensures that this define is available whenever any of the standard header is included.
Relying on features.h is problematic since codebases are free to have such a header on their search path, which breaks compilation. libc should instead provide a more standard way of getting __LLVM_LIBC__. Since __llvm-libc-common.h is included from all libc headers, defining __LLVM_LIBC__ there ensures that this define is available whenever any of the standard header is included. (cherry picked from commit b0d7820)
Relying on features.h is problematic since codebases are free to have such a header on their search path, which breaks compilation. libc should instead provide a more standard way of getting __LLVM_LIBC__. Since __llvm-libc-common.h is included from all libc headers, defining __LLVM_LIBC__ there ensures that this define is available whenever any of the standard header is included.
Relying on features.h is problematic since codebases are free to have such a header on their search path, which breaks compilation. libc should instead provide a more standard way of getting LLVM_LIBC. Since __llvm-libc-common.h is included from all libc headers, defining LLVM_LIBC there ensures that this define is available whenever any of the standard header is included.