1#![allow(non_camel_case_types)]
10
11pub type lto_bool_t = u8;
12
13#[repr(C)]
15#[derive(Clone, Copy, Debug, PartialEq)]
16pub enum lto_symbol_attributes {
17 LTO_SYMBOL_ALIGNMENT_MASK = 31,
18 LTO_SYMBOL_PERMISSIONS_MASK = 224,
19 LTO_SYMBOL_PERMISSIONS_CODE = 160,
20 LTO_SYMBOL_PERMISSIONS_DATA = 192,
21 LTO_SYMBOL_PERMISSIONS_RODATA = 128,
22 LTO_SYMBOL_DEFINITION_MASK = 1792,
23 LTO_SYMBOL_DEFINITION_REGULAR = 256,
24 LTO_SYMBOL_DEFINITION_TENTATIVE = 512,
25 LTO_SYMBOL_DEFINITION_WEAK = 768,
26 LTO_SYMBOL_DEFINITION_UNDEFINED = 1024,
27 LTO_SYMBOL_DEFINITION_WEAKUNDEF = 1280,
28 LTO_SYMBOL_SCOPE_MASK = 14336,
29 LTO_SYMBOL_SCOPE_INTERNAL = 2048,
30 LTO_SYMBOL_SCOPE_HIDDEN = 0x1000,
31 LTO_SYMBOL_SCOPE_PROTECTED = 0x2000,
32 LTO_SYMBOL_SCOPE_DEFAULT = 0x1800,
33 LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN = 0x2800,
34 LTO_SYMBOL_COMDAT = 0x4000,
36 LTO_SYMBOL_ALIAS = 0x8000,
38}
39
40#[repr(C)]
41#[derive(Clone, Copy, Debug, PartialEq)]
42pub enum lto_debug_model {
43 LTO_DEBUG_MODEL_NONE = 0,
44 LTO_DEBUG_MODEL_DWARF = 1,
45}
46
47#[repr(C)]
48#[derive(Clone, Copy, Debug, PartialEq)]
49pub enum lto_codegen_model {
50 LTO_CODEGEN_PIC_MODEL_STATIC = 0,
51 LTO_CODEGEN_PIC_MODEL_DYNAMIC = 1,
52 LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2,
53 LTO_CODEGEN_PIC_MODEL_DEFAULT = 3,
54}
55
56#[derive(Debug)]
57pub enum LLVMOpaqueLTOModule {}
58
59pub type lto_module_t = *mut LLVMOpaqueLTOModule;
60
61#[derive(Debug)]
62pub enum LLVMOpaqueLTOCodeGenerator {}
63
64pub type lto_code_gen_t = *mut LLVMOpaqueLTOCodeGenerator;
65
66#[derive(Debug)]
67pub enum LLVMOpaqueThinLTOCodeGenerator {}
68
69pub type thinlto_code_gen_t = *mut LLVMOpaqueThinLTOCodeGenerator;
70
71#[derive(Debug)]
72pub enum LLVMOpaqueLTOInput {}
73
74pub type lto_input_t = *mut LLVMOpaqueLTOInput;
75
76#[repr(C)]
77#[derive(Clone, Copy, Debug, PartialEq)]
78pub enum lto_codegen_diagnostic_severity_t {
79 LTO_DS_ERROR = 0,
80 LTO_DS_WARNING = 1,
81 LTO_DS_REMARK = 3,
82 LTO_DS_NOTE = 2,
83}
84
85pub type lto_diagnostic_handler_t = Option<
86 extern "C" fn(
87 severity: lto_codegen_diagnostic_severity_t,
88 diag: *const ::libc::c_char,
89 ctxt: *mut ::libc::c_void,
90 ),
91>;
92
93extern "C" {
94 pub fn lto_get_version() -> *const ::libc::c_char;
95 pub fn lto_get_error_message() -> *const ::libc::c_char;
96 pub fn lto_module_is_object_file(path: *const ::libc::c_char) -> lto_bool_t;
97 pub fn lto_module_is_object_file_for_target(
98 path: *const ::libc::c_char,
99 target_triple_prefix: *const ::libc::c_char,
100 ) -> lto_bool_t;
101 pub fn lto_module_has_objc_category(
104 mem: *const ::libc::c_void,
105 length: ::libc::size_t,
106 ) -> lto_bool_t;
107 pub fn lto_module_is_object_file_in_memory(
109 mem: *const ::libc::c_void,
110 length: ::libc::size_t,
111 ) -> lto_bool_t;
112 pub fn lto_module_is_object_file_in_memory_for_target(
113 mem: *const ::libc::c_void,
114 length: ::libc::size_t,
115 target_triple_prefix: *const ::libc::c_char,
116 ) -> lto_bool_t;
117 pub fn lto_module_create(path: *const ::libc::c_char) -> lto_module_t;
118 pub fn lto_module_create_from_memory(
119 mem: *const ::libc::c_void,
120 length: ::libc::size_t,
121 ) -> lto_module_t;
122 pub fn lto_module_create_from_memory_with_path(
123 mem: *const ::libc::c_void,
124 length: ::libc::size_t,
125 path: *const ::libc::c_char,
126 ) -> lto_module_t;
127 pub fn lto_module_create_in_local_context(
128 mem: *const ::libc::c_void,
129 length: ::libc::size_t,
130 path: *const ::libc::c_char,
131 ) -> lto_module_t;
132 pub fn lto_module_create_in_codegen_context(
133 mem: *const ::libc::c_void,
134 length: ::libc::size_t,
135 path: *const ::libc::c_char,
136 cg: lto_code_gen_t,
137 ) -> lto_module_t;
138 pub fn lto_module_create_from_fd(
139 fd: ::libc::c_int,
140 path: *const ::libc::c_char,
141 file_size: ::libc::size_t,
142 ) -> lto_module_t;
143 pub fn lto_module_create_from_fd_at_offset(
144 fd: ::libc::c_int,
145 path: *const ::libc::c_char,
146 file_size: ::libc::size_t,
147 map_size: ::libc::size_t,
148 offset: ::libc::off_t,
149 ) -> lto_module_t;
150 pub fn lto_module_dispose(_mod: lto_module_t);
151 pub fn lto_module_get_target_triple(_mod: lto_module_t) -> *const ::libc::c_char;
152 pub fn lto_module_set_target_triple(_mod: lto_module_t, triple: *const ::libc::c_char);
153 pub fn lto_module_get_num_symbols(_mod: lto_module_t) -> ::libc::c_uint;
154 pub fn lto_module_get_symbol_name(
155 _mod: lto_module_t,
156 index: ::libc::c_uint,
157 ) -> *const ::libc::c_char;
158 pub fn lto_module_get_symbol_attribute(
159 _mod: lto_module_t,
160 index: ::libc::c_uint,
161 ) -> lto_symbol_attributes;
162 pub fn lto_module_get_linkeropts(_mod: lto_module_t) -> *const ::libc::c_char;
169 pub fn lto_module_get_macho_cputype(
170 _mod: lto_module_t,
171 out_cputype: *mut ::libc::c_uint,
172 out_cpusubtype: *mut ::libc::c_uint,
173 ) -> lto_bool_t;
174 pub fn lto_module_has_ctor_dtor(mod_: lto_module_t) -> lto_bool_t;
179 pub fn lto_codegen_set_diagnostic_handler(
180 arg1: lto_code_gen_t,
181 arg2: lto_diagnostic_handler_t,
182 arg3: *mut ::libc::c_void,
183 );
184 pub fn lto_codegen_create() -> lto_code_gen_t;
185 pub fn lto_codegen_create_in_local_context() -> lto_code_gen_t;
186 pub fn lto_codegen_dispose(arg1: lto_code_gen_t);
187 pub fn lto_codegen_add_module(cg: lto_code_gen_t, _mod: lto_module_t) -> lto_bool_t;
188 pub fn lto_codegen_set_module(cg: lto_code_gen_t, _mod: lto_module_t);
193 pub fn lto_codegen_set_debug_model(cg: lto_code_gen_t, arg1: lto_debug_model) -> lto_bool_t;
194 pub fn lto_codegen_set_pic_model(cg: lto_code_gen_t, arg1: lto_codegen_model) -> lto_bool_t;
195 pub fn lto_codegen_set_cpu(cg: lto_code_gen_t, cpu: *const ::libc::c_char);
196 pub fn lto_codegen_set_assembler_path(cg: lto_code_gen_t, path: *const ::libc::c_char);
197 pub fn lto_codegen_set_assembler_args(
198 cg: lto_code_gen_t,
199 args: *mut *const ::libc::c_char,
200 nargs: ::libc::c_int,
201 );
202 pub fn lto_codegen_add_must_preserve_symbol(cg: lto_code_gen_t, symbol: *const ::libc::c_char);
203 pub fn lto_codegen_write_merged_modules(
204 cg: lto_code_gen_t,
205 path: *const ::libc::c_char,
206 ) -> lto_bool_t;
207 pub fn lto_codegen_compile(
208 cg: lto_code_gen_t,
209 length: *mut ::libc::size_t,
210 ) -> *const ::libc::c_void;
211 pub fn lto_codegen_compile_to_file(
212 cg: lto_code_gen_t,
213 name: *mut *const ::libc::c_char,
214 ) -> lto_bool_t;
215 pub fn lto_codegen_optimize(cg: lto_code_gen_t) -> lto_bool_t;
221 pub fn lto_codegen_compile_optimized(
232 cg: lto_code_gen_t,
233 length: *mut ::libc::size_t,
234 ) -> *mut ::libc::c_void;
235 pub fn lto_api_version() -> ::libc::c_uint;
239 pub fn lto_set_debug_options(options: *mut *const ::libc::c_char, number: ::libc::c_int);
240 pub fn lto_codegen_debug_options(cg: lto_code_gen_t, arg1: *const ::libc::c_char);
241 pub fn lto_codegen_debug_options_array(
242 cg: lto_code_gen_t,
243 arg2: *const *const ::libc::c_char,
244 number: ::libc::c_int,
245 );
246 pub fn lto_initialize_disassembler();
247 pub fn lto_codegen_set_should_internalize(cg: lto_code_gen_t, ShouldInternalize: lto_bool_t);
251 pub fn lto_codegen_set_should_embed_uselists(
258 cg: lto_code_gen_t,
259 ShouldEmbedUselists: lto_bool_t,
260 );
261}
262
263#[repr(C)]
265#[derive(Debug)]
266#[allow(non_snake_case)]
267pub struct LTOObjectBuffer {
268 Buffer: *const ::libc::c_char,
269 Size: ::libc::size_t,
270}
271
272extern "C" {
273 pub fn thinlto_create_codegen() -> thinlto_code_gen_t;
279 pub fn thinlto_codegen_dispose(cg: thinlto_code_gen_t);
281 pub fn thinlto_codegen_add_module(
289 cg: thinlto_code_gen_t,
290 identifier: *const ::libc::c_char,
291 data: *const ::libc::c_char,
292 length: ::libc::c_int,
293 );
294 pub fn thinlto_codegen_process(cg: thinlto_code_gen_t);
298 pub fn thinlto_module_get_num_objects(cg: thinlto_code_gen_t) -> ::libc::c_int;
303 pub fn thinlto_module_get_object(
306 cg: thinlto_code_gen_t,
307 index: ::libc::c_uint,
308 ) -> LTOObjectBuffer;
309 pub fn thinlto_module_get_num_object_files(cg: thinlto_code_gen_t) -> ::libc::c_uint;
313 pub fn thinlto_module_get_object_file(
317 cg: thinlto_code_gen_t,
318 index: ::libc::c_uint,
319 ) -> *const ::libc::c_char;
320 pub fn thinlto_codegen_set_pic_model(
324 cg: thinlto_code_gen_t,
325 model: lto_codegen_model,
326 ) -> lto_bool_t;
327
328 pub fn thinlto_codegen_set_cache_dir(cg: thinlto_code_gen_t, cache_dir: *const ::libc::c_char);
333 pub fn thinlto_codegen_set_cache_pruning_interval(
337 cg: thinlto_code_gen_t,
338 interval: ::libc::c_int,
339 );
340 pub fn thinlto_codegen_set_final_cache_size_relative_to_available_space(
346 cg: thinlto_code_gen_t,
347 percentage: ::libc::c_uint,
348 );
349 pub fn thinlto_codegen_set_cache_entry_expiration(
351 cg: thinlto_code_gen_t,
352 expiration: ::libc::c_uint,
353 );
354 pub fn thinlto_codegen_set_cache_size_bytes(
359 cg: thinlto_code_gen_t,
360 max_size_bytes: ::libc::c_uint,
361 );
362 pub fn thinlto_codegen_set_cache_size_megabytes(
365 cg: thinlto_code_gen_t,
366 max_size_megabytes: ::libc::c_uint,
367 );
368 pub fn thinlto_codegen_set_cache_size_files(
370 cg: thinlto_code_gen_t,
371 max_size_files: ::libc::c_uint,
372 );
373
374 pub fn lto_input_create(
376 buffer: *const ::libc::c_void,
377 buffer_size: ::libc::size_t,
378 path: *const ::libc::c_char,
379 ) -> lto_input_t;
380 pub fn lto_input_dispose(input: lto_input_t);
382 pub fn lto_input_get_num_dependent_libraries(input: lto_input_t) -> ::libc::c_uint;
384 pub fn lto_input_get_dependent_library(
388 input: lto_input_t,
389 index: ::libc::size_t,
390 size: *mut ::libc::size_t,
391 ) -> *const ::libc::c_char;
392 pub fn lto_runtime_lib_symbols_list(size: *mut usize) -> *const *const ::libc::c_char;
395
396 pub fn thinlto_codegen_set_savetemps_dir(
400 cg: thinlto_code_gen_t,
401 save_temps_dir: *const ::libc::c_char,
402 );
403 pub fn thinlto_set_generated_objects_dir(
408 cg: thinlto_code_gen_t,
409 save_temps_dir: *const ::libc::c_char,
410 );
411 pub fn thinlto_codegen_set_cpu(cg: thinlto_code_gen_t, cpu: *const ::libc::c_char);
413 pub fn thinlto_codegen_disable_codegen(cg: thinlto_code_gen_t, disable: lto_bool_t);
417 pub fn thinlto_codegen_set_codegen_only(cg: thinlto_code_gen_t, codegen_only: lto_bool_t);
419 pub fn thinlto_debug_options(options: *const *const ::libc::c_char, number: ::libc::c_int);
421 pub fn lto_module_is_thinlto(module: lto_module_t) -> lto_bool_t;
423 pub fn thinlto_codegen_add_must_preserve_symbol(
428 cg: thinlto_code_gen_t,
429 name: *const ::libc::c_char,
430 length: ::libc::c_int,
431 );
432 pub fn thinlto_codegen_add_cross_referenced_symbol(
438 cg: thinlto_code_gen_t,
439 name: *const ::libc::c_char,
440 length: ::libc::c_int,
441 );
442}