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#[cfg(LLVM_VERSION_9_OR_GREATER)]
72#[derive(Debug)]
73pub enum LLVMOpaqueLTOInput {}
74
75#[cfg(LLVM_VERSION_9_OR_GREATER)]
76pub type lto_input_t = *mut LLVMOpaqueLTOInput;
77
78#[repr(C)]
79#[derive(Clone, Copy, Debug, PartialEq)]
80pub enum lto_codegen_diagnostic_severity_t {
81 LTO_DS_ERROR = 0,
82 LTO_DS_WARNING = 1,
83 LTO_DS_REMARK = 3,
84 LTO_DS_NOTE = 2,
85}
86
87pub type lto_diagnostic_handler_t = Option<
88 extern "C" fn(
89 severity: lto_codegen_diagnostic_severity_t,
90 diag: *const ::libc::c_char,
91 ctxt: *mut ::libc::c_void,
92 ),
93>;
94
95extern "C" {
96 pub fn lto_get_version() -> *const ::libc::c_char;
97 pub fn lto_get_error_message() -> *const ::libc::c_char;
98 pub fn lto_module_is_object_file(path: *const ::libc::c_char) -> lto_bool_t;
99 pub fn lto_module_is_object_file_for_target(
100 path: *const ::libc::c_char,
101 target_triple_prefix: *const ::libc::c_char,
102 ) -> lto_bool_t;
103 pub fn lto_module_has_objc_category(
106 mem: *const ::libc::c_void,
107 length: ::libc::size_t,
108 ) -> lto_bool_t;
109 pub fn lto_module_is_object_file_in_memory(
111 mem: *const ::libc::c_void,
112 length: ::libc::size_t,
113 ) -> lto_bool_t;
114 pub fn lto_module_is_object_file_in_memory_for_target(
115 mem: *const ::libc::c_void,
116 length: ::libc::size_t,
117 target_triple_prefix: *const ::libc::c_char,
118 ) -> lto_bool_t;
119 pub fn lto_module_create(path: *const ::libc::c_char) -> lto_module_t;
120 pub fn lto_module_create_from_memory(
121 mem: *const ::libc::c_void,
122 length: ::libc::size_t,
123 ) -> lto_module_t;
124 pub fn lto_module_create_from_memory_with_path(
125 mem: *const ::libc::c_void,
126 length: ::libc::size_t,
127 path: *const ::libc::c_char,
128 ) -> lto_module_t;
129 pub fn lto_module_create_in_local_context(
130 mem: *const ::libc::c_void,
131 length: ::libc::size_t,
132 path: *const ::libc::c_char,
133 ) -> lto_module_t;
134 pub fn lto_module_create_in_codegen_context(
135 mem: *const ::libc::c_void,
136 length: ::libc::size_t,
137 path: *const ::libc::c_char,
138 cg: lto_code_gen_t,
139 ) -> lto_module_t;
140 pub fn lto_module_create_from_fd(
141 fd: ::libc::c_int,
142 path: *const ::libc::c_char,
143 file_size: ::libc::size_t,
144 ) -> lto_module_t;
145 pub fn lto_module_create_from_fd_at_offset(
146 fd: ::libc::c_int,
147 path: *const ::libc::c_char,
148 file_size: ::libc::size_t,
149 map_size: ::libc::size_t,
150 offset: ::libc::off_t,
151 ) -> lto_module_t;
152 pub fn lto_module_dispose(_mod: lto_module_t);
153 pub fn lto_module_get_target_triple(_mod: lto_module_t) -> *const ::libc::c_char;
154 pub fn lto_module_set_target_triple(_mod: lto_module_t, triple: *const ::libc::c_char);
155 pub fn lto_module_get_num_symbols(_mod: lto_module_t) -> ::libc::c_uint;
156 pub fn lto_module_get_symbol_name(
157 _mod: lto_module_t,
158 index: ::libc::c_uint,
159 ) -> *const ::libc::c_char;
160 pub fn lto_module_get_symbol_attribute(
161 _mod: lto_module_t,
162 index: ::libc::c_uint,
163 ) -> lto_symbol_attributes;
164 pub fn lto_module_get_linkeropts(_mod: lto_module_t) -> *const ::libc::c_char;
171 pub fn lto_codegen_set_diagnostic_handler(
172 arg1: lto_code_gen_t,
173 arg2: lto_diagnostic_handler_t,
174 arg3: *mut ::libc::c_void,
175 );
176 pub fn lto_codegen_create() -> lto_code_gen_t;
177 pub fn lto_codegen_create_in_local_context() -> lto_code_gen_t;
178 pub fn lto_codegen_dispose(arg1: lto_code_gen_t);
179 pub fn lto_codegen_add_module(cg: lto_code_gen_t, _mod: lto_module_t) -> lto_bool_t;
180 pub fn lto_codegen_set_module(cg: lto_code_gen_t, _mod: lto_module_t);
185 pub fn lto_codegen_set_debug_model(cg: lto_code_gen_t, arg1: lto_debug_model) -> lto_bool_t;
186 pub fn lto_codegen_set_pic_model(cg: lto_code_gen_t, arg1: lto_codegen_model) -> lto_bool_t;
187 pub fn lto_codegen_set_cpu(cg: lto_code_gen_t, cpu: *const ::libc::c_char);
188 pub fn lto_codegen_set_assembler_path(cg: lto_code_gen_t, path: *const ::libc::c_char);
189 pub fn lto_codegen_set_assembler_args(
190 cg: lto_code_gen_t,
191 args: *mut *const ::libc::c_char,
192 nargs: ::libc::c_int,
193 );
194 pub fn lto_codegen_add_must_preserve_symbol(cg: lto_code_gen_t, symbol: *const ::libc::c_char);
195 pub fn lto_codegen_write_merged_modules(
196 cg: lto_code_gen_t,
197 path: *const ::libc::c_char,
198 ) -> lto_bool_t;
199 pub fn lto_codegen_compile(
200 cg: lto_code_gen_t,
201 length: *mut ::libc::size_t,
202 ) -> *const ::libc::c_void;
203 pub fn lto_codegen_compile_to_file(
204 cg: lto_code_gen_t,
205 name: *mut *const ::libc::c_char,
206 ) -> lto_bool_t;
207 pub fn lto_codegen_optimize(cg: lto_code_gen_t) -> lto_bool_t;
213 pub fn lto_codegen_compile_optimized(
224 cg: lto_code_gen_t,
225 length: *mut ::libc::size_t,
226 ) -> *mut ::libc::c_void;
227 pub fn lto_api_version() -> ::libc::c_uint;
231 pub fn lto_codegen_debug_options(cg: lto_code_gen_t, arg1: *const ::libc::c_char);
232 #[cfg(LLVM_VERSION_10_OR_GREATER)]
233 pub fn lto_codegen_debug_options_array(
234 cg: lto_code_gen_t,
235 arg2: *const *const ::libc::c_char,
236 number: ::libc::c_int
237 );
238 pub fn lto_initialize_disassembler();
239 pub fn lto_codegen_set_should_internalize(cg: lto_code_gen_t, ShouldInternalize: lto_bool_t);
243 pub fn lto_codegen_set_should_embed_uselists(
250 cg: lto_code_gen_t,
251 ShouldEmbedUselists: lto_bool_t,
252 );
253}
254
255#[repr(C)]
257#[derive(Debug)]
258#[allow(non_snake_case)]
259pub struct LTOObjectBuffer {
260 Buffer: *const ::libc::c_char,
261 Size: ::libc::size_t,
262}
263
264extern "C" {
265 pub fn thinlto_create_codegen() -> thinlto_code_gen_t;
271 pub fn thinlto_codegen_dispose(cg: thinlto_code_gen_t);
273 pub fn thinlto_codegen_add_module(
281 cg: thinlto_code_gen_t,
282 identifier: *const ::libc::c_char,
283 data: *const ::libc::c_char,
284 length: ::libc::c_int,
285 );
286 pub fn thinlto_codegen_process(cg: thinlto_code_gen_t);
290 pub fn thinlto_module_get_num_objects(cg: thinlto_code_gen_t) -> ::libc::c_int;
295 pub fn thinlto_module_get_object(
298 cg: thinlto_code_gen_t,
299 index: ::libc::c_uint,
300 ) -> LTOObjectBuffer;
301 pub fn thinlto_module_get_num_object_files(cg: thinlto_code_gen_t) -> ::libc::c_uint;
305 pub fn thinlto_module_get_object_file(
309 cg: thinlto_code_gen_t,
310 index: ::libc::c_uint,
311 ) -> *const ::libc::c_char;
312 pub fn thinlto_codegen_set_pic_model(
316 cg: thinlto_code_gen_t,
317 model: lto_codegen_model,
318 ) -> lto_bool_t;
319
320 pub fn thinlto_codegen_set_cache_dir(cg: thinlto_code_gen_t, cache_dir: *const ::libc::c_char);
325 pub fn thinlto_codegen_set_cache_pruning_interval(
329 cg: thinlto_code_gen_t,
330 interval: ::libc::c_int,
331 );
332 pub fn thinlto_codegen_set_final_cache_size_relative_to_available_space(
338 cg: thinlto_code_gen_t,
339 percentage: ::libc::c_uint,
340 );
341 pub fn thinlto_codegen_set_cache_entry_expiration(
343 cg: thinlto_code_gen_t,
344 expiration: ::libc::c_uint,
345 );
346 pub fn thinlto_codegen_set_cache_size_bytes(
351 cg: thinlto_code_gen_t,
352 max_size_bytes: ::libc::c_uint,
353 );
354 pub fn thinlto_codegen_set_cache_size_megabytes(
357 cg: thinlto_code_gen_t,
358 max_size_megabytes: ::libc::c_uint,
359 );
360 pub fn thinlto_codegen_set_cache_size_files(
362 cg: thinlto_code_gen_t,
363 max_size_files: ::libc::c_uint,
364 );
365
366 #[cfg(LLVM_VERSION_9_OR_GREATER)]
368 pub fn lto_input_create(
369 buffer: *const ::libc::c_void,
370 buffer_size: ::libc::size_t,
371 path: *const ::libc::c_char,
372 ) -> lto_input_t;
373 #[cfg(LLVM_VERSION_9_OR_GREATER)]
375 pub fn lto_input_dispose(input: lto_input_t);
376 #[cfg(LLVM_VERSION_9_OR_GREATER)]
378 pub fn lto_input_get_num_dependent_libraries(input: lto_input_t) -> ::libc::c_uint;
379 #[cfg(LLVM_VERSION_9_OR_GREATER)]
383 pub fn lto_input_get_dependent_library(
384 input: lto_input_t,
385 index: ::libc::size_t,
386 size: *mut ::libc::size_t,
387 ) -> *const ::libc::c_char;
388 #[cfg(LLVM_VERSION_10_OR_GREATER)]
391 pub fn lto_runtime_lib_symbols_list(size: *mut usize) -> *const *const ::libc::c_char;
392
393 pub fn thinlto_codegen_set_savetemps_dir(
397 cg: thinlto_code_gen_t,
398 save_temps_dir: *const ::libc::c_char,
399 );
400 pub fn thinlto_set_generated_objects_dir(
405 cg: thinlto_code_gen_t,
406 save_temps_dir: *const ::libc::c_char,
407 );
408 pub fn thinlto_codegen_set_cpu(cg: thinlto_code_gen_t, cpu: *const ::libc::c_char);
410 pub fn thinlto_codegen_disable_codegen(cg: thinlto_code_gen_t, disable: lto_bool_t);
414 pub fn thinlto_codegen_set_codegen_only(cg: thinlto_code_gen_t, codegen_only: lto_bool_t);
416 pub fn thinlto_debug_options(options: *const *const ::libc::c_char, number: ::libc::c_int);
418 pub fn lto_module_is_thinlto(module: lto_module_t) -> lto_bool_t;
420 pub fn thinlto_codegen_add_must_preserve_symbol(
425 cg: thinlto_code_gen_t,
426 name: *const ::libc::c_char,
427 length: ::libc::c_int,
428 );
429 pub fn thinlto_codegen_add_cross_referenced_symbol(
435 cg: thinlto_code_gen_t,
436 name: *const ::libc::c_char,
437 length: ::libc::c_int,
438 );
439}