1
+ use crate :: spec:: { abi:: Abi , LinkerFlavor , PanicStrategy , Target , TargetOptions , RelocModel } ;
2
+ use crate :: abi:: Endian ;
3
+
4
+ pub fn target ( ) -> Target {
5
+ Target {
6
+ llvm_target : "xtensa-none-elf" . to_string ( ) ,
7
+ pointer_width : 32 ,
8
+ data_layout : "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32" . to_string ( ) ,
9
+ arch : "xtensa" . to_string ( ) ,
10
+
11
+ options : TargetOptions {
12
+ endian : Endian :: Little ,
13
+ c_int_width : "32" . to_string ( ) ,
14
+ families : vec ! [ "unix" . to_string( ) ] ,
15
+ os : "espidf" . to_string ( ) ,
16
+ env : "newlib" . to_string ( ) ,
17
+ vendor : "espressif" . to_string ( ) ,
18
+ linker_flavor : LinkerFlavor :: Gcc ,
19
+
20
+ executables : true ,
21
+ cpu : "esp32-s2" . to_string ( ) ,
22
+ linker : Some ( "xtensa-esp32s2-elf-gcc" . to_string ( ) ) ,
23
+
24
+ // See https://github.com/espressif/rust-esp32-example/issues/3#issuecomment-861054477
25
+ //
26
+ // Unlike the original ESP32 chip, ESP32-S2 does not really support atomics.
27
+ // If the missing hardware instruction ends up being emulated in ESP-IDF, we might want to revert
28
+ // this change and claim that atomics are supported "in hardware" (even though they would be emulated
29
+ // by actually trapping the illegal instruction exception handler and calling into an ESP-IDF C emulation code).
30
+ //
31
+ // However, for now we simultaneously claim "max_atomic_width: Some(32)" **and** atomic_cas: true,
32
+ // which should force the compiler to generate libcalls to functions that emulate atomics
33
+ // and which are already implemented in the ESP-IDF main branch anyway.
34
+ max_atomic_width : Some ( 32 ) ,
35
+ atomic_cas : true ,
36
+
37
+ // Because these devices have very little resources having an
38
+ // unwinder is too onerous so we default to "abort" because the
39
+ // "unwind" strategy is very rare.
40
+ panic_strategy : PanicStrategy :: Abort ,
41
+
42
+ // Similarly, one almost always never wants to use relocatable
43
+ // code because of the extra costs it involves.
44
+ relocation_model : RelocModel :: Static ,
45
+
46
+ emit_debug_gdb_scripts : false ,
47
+
48
+ unsupported_abis : vec ! [
49
+ Abi :: Stdcall { unwind: false } ,
50
+ Abi :: Stdcall { unwind: true } ,
51
+ Abi :: Fastcall ,
52
+ Abi :: Vectorcall ,
53
+ Abi :: Thiscall { unwind: false } ,
54
+ Abi :: Thiscall { unwind: true } ,
55
+ Abi :: Win64 ,
56
+ Abi :: SysV64 ,
57
+ ] ,
58
+
59
+ ..Default :: default ( )
60
+ } ,
61
+ }
62
+ }
0 commit comments