@@ -72,6 +72,12 @@ impl Sources {
72
72
}
73
73
}
74
74
}
75
+
76
+ fn remove ( & mut self , symbols : & [ & str ] ) {
77
+ for symbol in symbols {
78
+ self . map . remove ( * symbol) . unwrap ( ) ;
79
+ }
80
+ }
75
81
}
76
82
77
83
fn main ( ) {
@@ -107,6 +113,25 @@ fn main() {
107
113
cfg. flag ( "-ffreestanding" ) ;
108
114
}
109
115
116
+ // NOTE Most of the ARM intrinsics are written in assembly. Tell gcc which arch we are going to
117
+ // target to make sure that the assembly implementations really work for the target. If the
118
+ // implementation is not valid for the arch, then gcc will error when compiling it.
119
+ if llvm_target[ 0 ] . starts_with ( "thumb" ) {
120
+ cfg. flag ( "-mthumb" ) ;
121
+ }
122
+
123
+ if llvm_target[ 0 ] == "thumbv6m" {
124
+ cfg. flag ( "-march=armv6-m" ) ;
125
+ }
126
+
127
+ if llvm_target[ 0 ] == "thumbv7m" {
128
+ cfg. flag ( "-march=armv7-m" ) ;
129
+ }
130
+
131
+ if llvm_target[ 0 ] == "thumbv7em" {
132
+ cfg. flag ( "-march=armv7e-m" ) ;
133
+ }
134
+
110
135
let mut sources = Sources :: new ( ) ;
111
136
sources. extend ( & [ "absvdi2.c" ,
112
137
"absvsi2.c" ,
@@ -252,7 +277,7 @@ fn main() {
252
277
"atomic_thread_fence.c" ] ) ;
253
278
}
254
279
255
- if target_os != "windows" {
280
+ if target_os != "windows" && target_os != "none" {
256
281
sources. extend ( & [ "emutls.c" ] ) ;
257
282
}
258
283
@@ -356,42 +381,43 @@ fn main() {
356
381
}
357
382
358
383
if llvm_target. last ( ) . unwrap ( ) . ends_with ( "eabihf" ) {
359
- sources. extend ( & [ "arm/adddf3vfp.S" ,
360
- "arm/addsf3vfp.S" ,
361
- "arm/divdf3vfp.S" ,
362
- "arm/divsf3vfp.S" ,
363
- "arm/eqdf2vfp.S" ,
364
- "arm/eqsf2vfp.S" ,
365
- "arm/extendsfdf2vfp.S" ,
366
- "arm/fixdfsivfp.S" ,
367
- "arm/fixsfsivfp.S" ,
368
- "arm/fixunsdfsivfp.S" ,
369
- "arm/fixunssfsivfp.S" ,
370
- "arm/floatsidfvfp.S" ,
371
- "arm/floatsisfvfp.S" ,
372
- "arm/floatunssidfvfp.S" ,
373
- "arm/floatunssisfvfp.S" ,
374
- "arm/gedf2vfp.S" ,
375
- "arm/gesf2vfp.S" ,
376
- "arm/gtdf2vfp.S" ,
377
- "arm/gtsf2vfp.S" ,
378
- "arm/ledf2vfp.S" ,
379
- "arm/lesf2vfp.S" ,
380
- "arm/ltdf2vfp.S" ,
381
- "arm/ltsf2vfp.S" ,
382
- "arm/muldf3vfp.S" ,
383
- "arm/mulsf3vfp.S" ,
384
- "arm/negdf2vfp.S" ,
385
- "arm/negsf2vfp.S" ,
386
- "arm/nedf2vfp.S" ,
387
- "arm/nesf2vfp.S" ,
388
- "arm/restore_vfp_d8_d15_regs.S" ,
389
- "arm/save_vfp_d8_d15_regs.S" ,
390
- "arm/subdf3vfp.S" ,
391
- "arm/subsf3vfp.S" ,
392
- "arm/truncdfsf2vfp.S" ,
393
- "arm/unorddf2vfp.S" ,
394
- "arm/unordsf2vfp.S" ] ) ;
384
+ if !llvm_target[ 0 ] . starts_with ( "thumbv7em" ) {
385
+ sources. extend ( & [ "arm/adddf3vfp.S" ,
386
+ "arm/addsf3vfp.S" ,
387
+ "arm/divdf3vfp.S" ,
388
+ "arm/divsf3vfp.S" ,
389
+ "arm/eqdf2vfp.S" ,
390
+ "arm/eqsf2vfp.S" ,
391
+ "arm/extendsfdf2vfp.S" ,
392
+ "arm/fixdfsivfp.S" ,
393
+ "arm/fixsfsivfp.S" ,
394
+ "arm/fixunsdfsivfp.S" ,
395
+ "arm/fixunssfsivfp.S" ,
396
+ "arm/floatsidfvfp.S" ,
397
+ "arm/floatsisfvfp.S" ,
398
+ "arm/floatunssidfvfp.S" ,
399
+ "arm/floatunssisfvfp.S" ,
400
+ "arm/gedf2vfp.S" ,
401
+ "arm/gesf2vfp.S" ,
402
+ "arm/gtdf2vfp.S" ,
403
+ "arm/gtsf2vfp.S" ,
404
+ "arm/ledf2vfp.S" ,
405
+ "arm/lesf2vfp.S" ,
406
+ "arm/ltdf2vfp.S" ,
407
+ "arm/ltsf2vfp.S" ,
408
+ "arm/muldf3vfp.S" ,
409
+ "arm/mulsf3vfp.S" ,
410
+ "arm/nedf2vfp.S" ,
411
+ "arm/nesf2vfp.S" ,
412
+ "arm/restore_vfp_d8_d15_regs.S" ,
413
+ "arm/save_vfp_d8_d15_regs.S" ,
414
+ "arm/subdf3vfp.S" ,
415
+ "arm/subsf3vfp.S" ,
416
+ ] ) ;
417
+ }
418
+
419
+ sources. extend ( & [ "arm/negdf2vfp.S" , "arm/negsf2vfp.S" ] ) ;
420
+
395
421
}
396
422
397
423
if target_arch == "aarch64" {
@@ -413,6 +439,18 @@ fn main() {
413
439
"trunctfsf2.c" ] ) ;
414
440
}
415
441
442
+ // Remove the assembly implementations that won't compile for the target
443
+ if llvm_target[ 0 ] == "thumbv6m" {
444
+ sources. remove ( & [ "aeabi_cdcmp" , "aeabi_cfcmp" , "aeabi_dcmp" , "aeabi_fcmp" , "aeabi_ldivmod" ,
445
+ "aeabi_memset" , "aeabi_uldivmod" , "clzdi2" , "clzsi2" , "comparesf2" ,
446
+ "divmodsi4" , "divsi3" , "modsi3" , "switch16" , "switch32" , "switch8" ,
447
+ "switchu8" , "udivmodsi4" , "udivsi3" , "umodsi3" ] ) ;
448
+ }
449
+
450
+ if llvm_target[ 0 ] == "thumbv7m" || llvm_target[ 0 ] == "thumbv7em" {
451
+ sources. remove ( & [ "aeabi_cdcmp" , "aeabi_cfcmp" ] ) ;
452
+ }
453
+
416
454
for src in sources. map . values ( ) {
417
455
cfg. file ( Path :: new ( "../compiler-rt/lib/builtins" ) . join ( src) ) ;
418
456
}
0 commit comments