Skip to content

[libc] Fix overlay mode inclusion for fcntl.h header. #119159

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
Dec 9, 2024
Merged

Conversation

lntue
Copy link
Contributor

@lntue lntue commented Dec 9, 2024

No description provided.

@lntue lntue requested a review from SchrodingerZhu December 9, 2024 02:41
@llvmbot llvmbot added the libc label Dec 9, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 9, 2024

@llvm/pr-subscribers-libc

Author: None (lntue)

Changes

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

5 Files Affected:

  • (modified) libc/hdr/fcntl_overlay.h (+10)
  • (modified) libc/hdr/types/CMakeLists.txt (+6)
  • (modified) libc/hdr/types/struct_f_owner_ex.h (+1-1)
  • (modified) libc/hdr/types/struct_flock.h (+1-1)
  • (modified) libc/hdr/types/struct_flock64.h (+1-1)
diff --git a/libc/hdr/fcntl_overlay.h b/libc/hdr/fcntl_overlay.h
index c1cc98b0ebb2c7..17ae78b3d0eca0 100644
--- a/libc/hdr/fcntl_overlay.h
+++ b/libc/hdr/fcntl_overlay.h
@@ -20,6 +20,11 @@
 // `__USE_FORTIFY_LEVEL`, which will be temporarily disabled
 // with `_FORTIFY_SOURCE`.
 
+#ifdef _FORTIFY_SOURCE
+#define LIBC_OLD_FORTIFY_SOURCE _FORTIFY_SOURCE
+#undef _FORTIFY_SOURCE
+#endif
+
 #ifdef __USE_FORTIFY_LEVEL
 #define LIBC_OLD_USE_FORTIFY_LEVEL __USE_FORTIFY_LEVEL
 #undef __USE_FORTIFY_LEVEL
@@ -28,6 +33,11 @@
 
 #include <fcntl.h>
 
+#ifdef LIBC_OLD_FORTIFY_SOURCE
+#define _FORTIFY_SOURCE LIBC_OLD_FORTIFY_SOURCE
+#undef LIBC_OLD_FORTIFY_SOURCE
+#endif
+
 #ifdef LIBC_OLD_USE_FORTIFY_LEVEL
 #undef __USE_FORTIFY_LEVEL
 #define __USE_FORTIFY_LEVEL LIBC_OLD_USE_FORTIFY_LEVEL
diff --git a/libc/hdr/types/CMakeLists.txt b/libc/hdr/types/CMakeLists.txt
index c4d14e6f893130..68a0e9603f9752 100644
--- a/libc/hdr/types/CMakeLists.txt
+++ b/libc/hdr/types/CMakeLists.txt
@@ -51,6 +51,8 @@ add_proxy_header_library(
   struct_flock
   HDRS
     struct_flock.h
+  DEPENDS
+    libc.hdr.fcntl_overlay
   FULL_BUILD_DEPENDS
     libc.include.llvm-libc-types.struct_flock
 )
@@ -59,6 +61,8 @@ add_proxy_header_library(
   struct_flock64
   HDRS
     struct_flock64.h
+  DEPENDS
+    libc.hdr.fcntl_overlay
   FULL_BUILD_DEPENDS
     libc.include.llvm-libc-types.struct_flock64
 )
@@ -67,6 +71,8 @@ add_proxy_header_library(
   struct_f_owner_ex
   HDRS
     struct_f_owner_ex.h
+  DEPENDS
+    libc.hdr.fcntl_overlay
   FULL_BUILD_DEPENDS
     libc.include.llvm-libc-types.struct_f_owner_ex
 )
diff --git a/libc/hdr/types/struct_f_owner_ex.h b/libc/hdr/types/struct_f_owner_ex.h
index 49985115ae4bb2..6e37cea6df84dd 100644
--- a/libc/hdr/types/struct_f_owner_ex.h
+++ b/libc/hdr/types/struct_f_owner_ex.h
@@ -14,7 +14,7 @@
 
 #else
 
-#include <fcntl.h>
+#include "hdr/fcntl_overlay.h"
 
 #endif // LIBC_FULL_BUILD
 
diff --git a/libc/hdr/types/struct_flock.h b/libc/hdr/types/struct_flock.h
index a552b91c432b38..6a6c928e6fa6dc 100644
--- a/libc/hdr/types/struct_flock.h
+++ b/libc/hdr/types/struct_flock.h
@@ -14,7 +14,7 @@
 
 #else
 
-#include <fcntl.h>
+#include "hdr/fcntl_overlay.h"
 
 #endif // LIBC_FULL_BUILD
 
diff --git a/libc/hdr/types/struct_flock64.h b/libc/hdr/types/struct_flock64.h
index 84fe67816c3372..fcfda59479a297 100644
--- a/libc/hdr/types/struct_flock64.h
+++ b/libc/hdr/types/struct_flock64.h
@@ -14,7 +14,7 @@
 
 #else
 
-#include <fcntl.h>
+#include "hdr/fcntl_overlay.h"
 
 #endif // LIBC_FULL_BUILD
 

@lntue lntue merged commit 44c645f into llvm:main Dec 9, 2024
9 checks passed
@lntue lntue deleted the fcntl branch December 9, 2024 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants