Skip to content

reland: [libc] Added transitive bindings for OffsetType #87680

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 3 commits into from
Apr 5, 2024

Conversation

Sh0g0-1758
Copy link
Member

Followup to issues addressed here: #87397

@llvmbot llvmbot added the libc label Apr 4, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 4, 2024

@llvm/pr-subscribers-libc

Author: Shourya Goel (Sh0g0-1758)

Changes

Followup to issues addressed here: #87397


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

7 Files Affected:

  • (modified) libc/config/baremetal/api.td (+5-2)
  • (modified) libc/config/gpu/api.td (+5-1)
  • (modified) libc/config/linux/api.td (+10-2)
  • (modified) libc/include/CMakeLists.txt (+6-4)
  • (modified) libc/spec/posix.td (+5-2)
  • (modified) libc/src/stdio/fseeko.h (-1)
  • (modified) libc/src/stdio/ftello.h (-1)
diff --git a/libc/config/baremetal/api.td b/libc/config/baremetal/api.td
index 25aa06aacb642e..a708ff9a0be119 100644
--- a/libc/config/baremetal/api.td
+++ b/libc/config/baremetal/api.td
@@ -1,5 +1,5 @@
 include "config/public_api.td"
-
+include "spec/posix.td"
 include "spec/stdc.td"
 include "spec/stdc_ext.td"
 include "spec/bsd_ext.td"
@@ -57,7 +57,10 @@ def MathAPI : PublicAPI<"math.h"> {
 }
 
 def StdIOAPI : PublicAPI<"stdio.h"> {
-  let Types = ["size_t"];
+  let Types = [
+    "size_t",
+    "off_t",
+  ];
 }
 
 def StdlibAPI : PublicAPI<"stdlib.h"> {
diff --git a/libc/config/gpu/api.td b/libc/config/gpu/api.td
index adaf5bfd747ac7..523ad49ffa3fd4 100644
--- a/libc/config/gpu/api.td
+++ b/libc/config/gpu/api.td
@@ -64,7 +64,11 @@ def StdIOAPI : PublicAPI<"stdio.h"> {
     SimpleMacroDef<"_IOLBF", "1">,
     SimpleMacroDef<"_IONBF", "2">,
   ];
-  let Types = ["size_t", "FILE"];
+  let Types = [
+    "FILE",
+    "off_t",
+    "size_t",
+  ];
 }
 
 def IntTypesAPI : PublicAPI<"inttypes.h"> {
diff --git a/libc/config/linux/api.td b/libc/config/linux/api.td
index eb5ed8089850e4..9964971f191b75 100644
--- a/libc/config/linux/api.td
+++ b/libc/config/linux/api.td
@@ -49,7 +49,10 @@ def CTypeAPI : PublicAPI<"ctype.h"> {
 }
 
 def FCntlAPI : PublicAPI<"fcntl.h"> {
-  let Types = ["mode_t"];
+  let Types = [
+    "mode_t",
+    "off_t",
+  ];
 }
 
 def IntTypesAPI : PublicAPI<"inttypes.h"> {
@@ -77,7 +80,12 @@ def StdIOAPI : PublicAPI<"stdio.h"> {
     SimpleMacroDef<"_IOLBF", "1">,
     SimpleMacroDef<"_IONBF", "2">,
   ];
-  let Types = ["size_t", "FILE", "cookie_io_functions_t"];
+  let Types = [
+    "FILE",
+    "cookie_io_functions_t",
+    "off_t",
+    "size_t",
+  ];
 }
 
 def StdlibAPI : PublicAPI<"stdlib.h"> {
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 4203f0bc901b22..02c7dc8fbc0b33 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -41,9 +41,10 @@ add_gen_header(
   DEF_FILE fcntl.h.def
   GEN_HDR fcntl.h
   DEPENDS
-    .llvm_libc_common_h
     .llvm-libc-macros.fcntl_macros
     .llvm-libc-types.mode_t
+    .llvm-libc-types.off_t
+    .llvm_libc_common_h
 )
 
 add_gen_header(
@@ -264,13 +265,14 @@ add_gen_header(
   DEF_FILE stdio.h.def
   GEN_HDR stdio.h
   DEPENDS
-    .llvm_libc_common_h
     .llvm-libc-macros.file_seek_macros
     .llvm-libc-macros.stdio_macros
-    .llvm-libc-types.size_t
-    .llvm-libc-types.ssize_t
     .llvm-libc-types.FILE
     .llvm-libc-types.cookie_io_functions_t
+    .llvm-libc-types.off_t
+    .llvm-libc-types.size_t
+    .llvm-libc-types.ssize_t
+    .llvm_libc_common_h
 )
 
 add_gen_header(
diff --git a/libc/spec/posix.td b/libc/spec/posix.td
index cfa8d3afedde3f..45f7ecfe84e98e 100644
--- a/libc/spec/posix.td
+++ b/libc/spec/posix.td
@@ -210,7 +210,10 @@ def POSIX : StandardSpec<"POSIX"> {
   HeaderSpec FCntl = HeaderSpec<
     "fcntl.h",
     [], // Macros
-    [ModeTType],
+    [
+        ModeTType,
+        OffTType,
+    ],
     [], // Enumerations
     [
       FunctionSpec<
@@ -1180,7 +1183,7 @@ def POSIX : StandardSpec<"POSIX"> {
   HeaderSpec StdIO = HeaderSpec<
       "stdio.h",
       [], // Macros
-      [], // Types
+      [OffTType], // Types
       [], // Enumerations
       [
           FunctionSpec<
diff --git a/libc/src/stdio/fseeko.h b/libc/src/stdio/fseeko.h
index 3202ed2f97d0ef..77fb41215c318f 100644
--- a/libc/src/stdio/fseeko.h
+++ b/libc/src/stdio/fseeko.h
@@ -10,7 +10,6 @@
 #define LLVM_LIBC_SRC_STDIO_FSEEKO_H
 
 #include <stdio.h>
-#include <unistd.h>
 
 namespace LIBC_NAMESPACE {
 
diff --git a/libc/src/stdio/ftello.h b/libc/src/stdio/ftello.h
index 0fdf13ab6bdbcd..5ab17f9244a5ad 100644
--- a/libc/src/stdio/ftello.h
+++ b/libc/src/stdio/ftello.h
@@ -10,7 +10,6 @@
 #define LLVM_LIBC_SRC_STDIO_FTELLO_H
 
 #include <stdio.h>
-#include <unistd.h>
 
 namespace LIBC_NAMESPACE {
 

@Sh0g0-1758
Copy link
Member Author

@nickdesaulniers
Copy link
Member

@petrhosek 9a9b45a is the change I messaged you about; I guess it's a question of do you expect NO POSIX EVER in baremetal? Or if you have File I/O like fseek, surely you'll hit porting issues if we're missing fseeko?

@nickdesaulniers nickdesaulniers changed the title [libc] Updated Include Files to fix fuchsia clang toolchain builder reland: [libc] Added transitive bindings for OffsetType Apr 4, 2024
@gulfemsavrun
Copy link
Contributor

I confirm that this fixed the issue that I reported in #87397 (comment).

@petrhosek
Copy link
Member

So far we tried to avoid including POSIX spec in the baremetal config because baremetal applications generally aren't POSIX compatible and shouldn't be using those APIs. Can we omit off_t from stdio.h in the baremetal config and avoid including the POSIX spec there?

@nickdesaulniers
Copy link
Member

Sure, we may need to revisit this decision in the future should we find more baremetal users hitting similar intentionally omitted pieces and being surpised.

@Sh0g0-1758 please add a commit that undoes the changes to libc/config/baremetal/api.td?

@nickdesaulniers
Copy link
Member

@gulfemsavrun do you have cycles to triple check this one last time for us (it's been modified since you last checked)? I'm more sensitive to merging patches Friday afternoons 😪

@gulfemsavrun
Copy link
Contributor

@gulfemsavrun do you have cycles to triple check this one last time for us (it's been modified since you last checked)? I'm more sensitive to merging patches Friday afternoons 😪

I confirm that the latest version also passed in our builders, and @nickdesaulniers thanks for being thoughtful!

@Sh0g0-1758
Copy link
Member Author

Sh0g0-1758 commented Apr 5, 2024

Can you please land this for me if no further changes are required. I don't have write access yet.

@nickdesaulniers nickdesaulniers merged commit 9f07584 into llvm:main Apr 5, 2024
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.

5 participants