Skip to content

release/20.x: [libc] Move __LLVM_LIBC__ define to __llvm-libc-common.h (#126877) #126960

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

Merged
merged 1 commit into from
Feb 14, 2025

Conversation

llvmbot
Copy link
Member

@llvmbot llvmbot commented Feb 12, 2025

Backport b0d7820

Requested by: @petrhosek

@llvmbot llvmbot added this to the LLVM 20.X Release milestone Feb 12, 2025
@llvmbot
Copy link
Member Author

llvmbot commented Feb 12, 2025

@michaelrj-google What do you think about merging this PR to the release branch?

@llvmbot
Copy link
Member Author

llvmbot commented Feb 12, 2025

@llvm/pr-subscribers-libc

Author: None (llvmbot)

Changes

Backport b0d7820

Requested by: @petrhosek


Full diff: https://github.com/llvm/llvm-project/pull/126960.diff

2 Files Affected:

  • (modified) libc/include/__llvm-libc-common.h (+2)
  • (modified) libc/include/llvm-libc-macros/features-macros.h (-2)
diff --git a/libc/include/__llvm-libc-common.h b/libc/include/__llvm-libc-common.h
index b5a23c5765f4d..9112d1ebe302c 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

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)
@tstellar tstellar merged commit 2a358ba into llvm:release/20.x Feb 14, 2025
6 of 9 checks passed
Copy link

@petrhosek (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

4 participants