[flang] Use object before converts in fir.dispatch (#68589)
[llvm-project.git] / libc / src / stdio / CMakeLists.txt
blob169bc592dee48854d983fbc74bb07394a4e7f473
1 # Helper function that creates an alias if a target specific implementation
2 # exists, otherwise it uses a generic one.
3 function(add_stdio_entrypoint_object name)
4   if(TARGET libc.src.stdio.${LIBC_TARGET_OS}.${name})
5     add_entrypoint_object(
6       ${name}
7       ALIAS
8       DEPENDS
9         .${LIBC_TARGET_OS}.${name}
10     )
11   elseif(TARGET libc.src.stdio.generic.${name})
12     add_entrypoint_object(
13       ${name}
14       ALIAS
15       DEPENDS
16         .generic.${name}
17     )
18   endif()
19 endfunction(add_stdio_entrypoint_object)
21 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
22   add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
23 endif()
25 if(NOT LIBC_TARGET_ARCHITECTURE_IS_GPU)
26   add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/generic)
27 endif()
29 if(NOT LLVM_LIBC_FULL_BUILD)
30   list(APPEND use_system_file "COMPILE_OPTIONS" "-DLIBC_COPT_STDIO_USE_SYSTEM_FILE")
31 endif()
33 add_entrypoint_object(
34   flockfile
35   SRCS
36     flockfile.cpp
37   HDRS
38     flockfile.h
39   DEPENDS
40     libc.include.stdio
41     libc.src.__support.File.file
42     libc.src.__support.File.platform_file
45 add_entrypoint_object(
46   funlockfile
47   SRCS
48     funlockfile.cpp
49   HDRS
50     funlockfile.h
51   DEPENDS
52     libc.include.stdio
53     libc.src.__support.File.file
54     libc.src.__support.File.platform_file
57 add_entrypoint_object(
58   ungetc
59   SRCS
60     ungetc.cpp
61   HDRS
62     ungetc.h
63   DEPENDS
64     libc.include.stdio
65     libc.src.__support.File.file
66     libc.src.__support.File.platform_file
69 add_entrypoint_object(
70   fopencookie
71   SRCS
72     fopencookie.cpp
73   HDRS
74     fopencookie.h
75   DEPENDS
76     libc.include.stdio
77     libc.src.__support.CPP.new
78     libc.src.__support.File.file
81 add_entrypoint_object(
82   setbuf
83   SRCS
84     setbuf.cpp
85   HDRS
86     setbuf.h
87   DEPENDS
88     libc.src.errno.errno
89     libc.include.stdio
90     libc.src.__support.File.file
91     libc.src.__support.File.platform_file
94 add_entrypoint_object(
95   setvbuf
96   SRCS
97     setvbuf.cpp
98   HDRS
99     setvbuf.h
100   DEPENDS
101     libc.src.errno.errno
102     libc.include.stdio
103     libc.src.__support.File.file
104     libc.src.__support.File.platform_file
107 list(APPEND scanf_deps
108       libc.src.__support.arg_list
109       libc.src.stdio.scanf_core.vfscanf_internal
112 if(LLVM_LIBC_FULL_BUILD)
113   list(APPEND scanf_deps
114       libc.src.__support.File.file
115       libc.src.__support.File.platform_file
116       libc.src.__support.File.platform_stdin
117   )
118 endif()
120 add_entrypoint_object(
121   sscanf
122   SRCS
123     sscanf.cpp
124   HDRS
125     sscanf.h
126   DEPENDS
127     libc.src.__support.arg_list
128     libc.src.stdio.scanf_core.reader
129     libc.src.stdio.scanf_core.scanf_main
132 add_entrypoint_object(
133   fscanf
134   SRCS
135     fscanf.cpp
136   HDRS
137     fscanf.h
138   DEPENDS
139     ${scanf_deps}
142 add_entrypoint_object(
143   scanf
144   SRCS
145     scanf.cpp
146   HDRS
147     scanf.h
148   DEPENDS
149     ${scanf_deps}
152 add_entrypoint_object(
153   sprintf
154   SRCS
155     sprintf.cpp
156   HDRS
157     sprintf.h
158   DEPENDS
159     libc.src.stdio.printf_core.printf_main
160     libc.src.stdio.printf_core.writer
163 add_entrypoint_object(
164   snprintf
165   SRCS
166     snprintf.cpp
167   HDRS
168     snprintf.h
169   DEPENDS
170     libc.src.stdio.printf_core.printf_main
171     libc.src.stdio.printf_core.writer
174 list(APPEND printf_deps
175       libc.src.__support.arg_list
176       libc.src.stdio.printf_core.vfprintf_internal
179 if(LLVM_LIBC_FULL_BUILD)
180   list(APPEND printf_deps
181       libc.src.__support.File.file
182       libc.src.__support.File.platform_file
183       libc.src.__support.File.platform_stdout
184   )
185 endif()
187 add_entrypoint_object(
188   printf
189   SRCS
190     printf.cpp
191   HDRS
192     printf.h
193   DEPENDS
194     ${printf_deps}
197 add_entrypoint_object(
198   fprintf
199   SRCS
200     fprintf.cpp
201   HDRS
202     fprintf.h
203   DEPENDS
204     libc.src.__support.arg_list
205     libc.src.stdio.printf_core.vfprintf_internal
208 add_entrypoint_object(
209   vsprintf
210   SRCS
211     vsprintf.cpp
212   HDRS
213     vsprintf.h
214   DEPENDS
215     libc.src.stdio.printf_core.printf_main
216     libc.src.stdio.printf_core.writer
219 add_entrypoint_object(
220   vsnprintf
221   SRCS
222     vsnprintf.cpp
223   HDRS
224     vsnprintf.h
225   DEPENDS
226     libc.src.stdio.printf_core.printf_main
227     libc.src.stdio.printf_core.writer
230 add_entrypoint_object(
231   vprintf
232   SRCS
233     vprintf.cpp
234   HDRS
235     vprintf.h
236   DEPENDS
237     ${printf_deps}
240 add_entrypoint_object(
241   vfprintf
242   SRCS
243     vfprintf.cpp
244   HDRS
245     vfprintf.h
246   DEPENDS
247     libc.src.__support.arg_list
248     libc.src.stdio.printf_core.vfprintf_internal
251 add_subdirectory(printf_core)
252 add_subdirectory(scanf_core)
254 add_entrypoint_object(
255   remove
256   ALIAS
257   DEPENDS
258     .${LIBC_TARGET_OS}.remove
261 # These entrypoints have multiple potential implementations.
262 add_stdio_entrypoint_object(feof)
263 add_stdio_entrypoint_object(feof_unlocked)
264 add_stdio_entrypoint_object(ferror)
265 add_stdio_entrypoint_object(ferror_unlocked)
266 add_stdio_entrypoint_object(fseek)
267 add_stdio_entrypoint_object(ftell)
268 add_stdio_entrypoint_object(fflush)
269 add_stdio_entrypoint_object(clearerr)
270 add_stdio_entrypoint_object(clearerr_unlocked)
271 add_stdio_entrypoint_object(fopen)
272 add_stdio_entrypoint_object(fclose)
273 add_stdio_entrypoint_object(fread_unlocked)
274 add_stdio_entrypoint_object(fread)
275 add_stdio_entrypoint_object(puts)
276 add_stdio_entrypoint_object(fputs)
277 add_stdio_entrypoint_object(fwrite_unlocked)
278 add_stdio_entrypoint_object(fwrite)
279 add_stdio_entrypoint_object(fputc)
280 add_stdio_entrypoint_object(putc)
281 add_stdio_entrypoint_object(putchar)
282 add_stdio_entrypoint_object(fgetc)
283 add_stdio_entrypoint_object(fgetc_unlocked)
284 add_stdio_entrypoint_object(getc)
285 add_stdio_entrypoint_object(getc_unlocked)
286 add_stdio_entrypoint_object(getchar)
287 add_stdio_entrypoint_object(getchar_unlocked)
288 add_stdio_entrypoint_object(fgets)
289 add_stdio_entrypoint_object(stdin)
290 add_stdio_entrypoint_object(stdout)
291 add_stdio_entrypoint_object(stderr)