Skip to content
This repository was archived by the owner on May 21, 2019. It is now read-only.

Commit 2a051ea

Browse files
committed
Rust: Create 3 logical ARM builds, based on support for VFP & Thumb2
The three types of `compiler-rt` builds we now support on ARM are: - `arm`: This is for targets like arm-unknown-linux-gnueabi. It assumes the target doesn't support hardware float (VFP), nor Thumb2 instructions. - `armhf`: This is for targets like arm-unknown-linux-gnueabihf (but also arm-linux-androideabi). It assumes the target supports VFP but not Thumb2 instructions. - `armv7`: This is for targets like armv7-unknown-linux-gnueabihf. It assumes the target supports both VFP and Thumb2 instructions. These three types (mostly) mirror the way Rust's ARM targets are named. The ones starting with `arm-` and ending with `eabi` fall in the `arm` bucket, the ones starting with `arm-` and ending with `eabihf` fall in the `armhf` bucket (although Android is an exception), and the ones starting with `armv7-` fall in the `armv7` bucket. This CL will have a couple of effects: - The CMake-based and plain Make-based builds would previously build different builtins for the same target triple. E.g. arm-linux-androideabi would have Thumb2 but not VFP builtins with the former, but VFP and not Thumb2 builtins with the latter. The CMake-based build is now consistent with the plain Make-based build. - The CMake-based build would *always* specific `-march=armv7-a` for any ARM build, even if it was for say, an ARMv6 target. This is now fixed and the build will use whatever CMAKE_C_FLAGS were specified during configuration instead. - The plain Make-based builds wouldn't build the ARM-specific builtins for targets triples like `arm-unknown-linux-gnueabi` before , because the `Arch` variable would get set to `arm`, which wasn't in the list of `OnlyArchs` in the `lib/builtins/arm/Makefile`. This was confusing though, because for part of the builtins (the non ARM-specific ones) we would use the `compiler-rt` implementation, while for others we would end up using the `libgcc` implementation. After this change, we'll always use the `compiler-rt` implementation. - For similar reasons, target triples like `arm-unknown-linux-musleabi` would not have the ARM-specific builtins built. For MUSL targets that is a problem though, since they won't link with `libgcc` at all, and hence the ARM-specific builtins symbols would be missing at link time. This is the reason why I started working on this change. This change will need an accompanying change in Rust's src/bootstrap/build/native.rs file to avoid breaking the Android build.
1 parent c3bda54 commit 2a051ea

File tree

2 files changed

+46
-35
lines changed

2 files changed

+46
-35
lines changed

cmake/config-ix.cmake

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ macro(detect_target_arch)
153153
check_symbol_exists(__wasm32__ "" __WEBASSEMBLY32)
154154
check_symbol_exists(__wasm64__ "" __WEBASSEMBLY64)
155155
if(__ARM)
156-
add_default_target_arch(arm)
156+
# Android shouldn't use Thumb2 instructions but can use VFP instructions.
157+
add_default_target_arch(armhf)
157158
elseif(__AARCH64)
158159
add_default_target_arch(aarch64)
159160
elseif(__X86_64)
@@ -220,10 +221,12 @@ elseif(NOT APPLE) # Supported archs for Apple platforms are generated later
220221
test_target_arch(mips "" "-mips32r2" "--target=mips-linux-gnu")
221222
test_target_arch(mips64 "" "-mips64r2" "--target=mips64-linux-gnu" "-mabi=n64")
222223
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "arm")
223-
if("${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" MATCHES "eabihf")
224-
test_target_arch(armhf "" "-march=armv7-a" "-mfloat-abi=hard")
224+
if("${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" MATCHES "armv7")
225+
test_target_arch(armv7 "" "${CMAKE_C_FLAGS}")
226+
elseif("${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" MATCHES "eabihf")
227+
test_target_arch(armhf "" "${CMAKE_C_FLAGS}")
225228
else()
226-
test_target_arch(arm "" "-march=armv7-a" "-mfloat-abi=soft")
229+
test_target_arch(arm "" "${CMAKE_C_FLAGS}")
227230
endif()
228231
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "aarch32")
229232
test_target_arch(aarch32 "" "-march=armv8-a")
@@ -267,7 +270,7 @@ function(get_target_flags_for_arch arch out_var)
267270
endfunction()
268271

269272
set(ARM64 aarch64)
270-
set(ARM32 arm armhf)
273+
set(ARM32 arm armhf armv7)
271274
set(X86 i386 i686)
272275
set(X86_64 x86_64)
273276
set(MIPS32 mips mipsel)

lib/builtins/CMakeLists.txt

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ else () # MSVC
227227
set(i686_SOURCES ${i386_SOURCES})
228228
endif () # if (NOT MSVC)
229229

230-
set(arm_SOURCES
230+
# These are sources that should be appropriate for any ARM platform.
231+
set(arm_GENERIC_SOURCES
231232
arm/aeabi_cdcmp.S
232233
arm/aeabi_cdcmpeq_check_nan.c
233234
arm/aeabi_cfcmp.S
@@ -253,32 +254,10 @@ set(arm_SOURCES
253254
arm/divmodsi4.S
254255
arm/divsi3.S
255256
arm/modsi3.S
256-
arm/negdf2vfp.S
257-
arm/negsf2vfp.S
258257
arm/switch16.S
259258
arm/switch32.S
260259
arm/switch8.S
261260
arm/switchu8.S
262-
arm/sync_fetch_and_add_4.S
263-
arm/sync_fetch_and_add_8.S
264-
arm/sync_fetch_and_and_4.S
265-
arm/sync_fetch_and_and_8.S
266-
arm/sync_fetch_and_max_4.S
267-
arm/sync_fetch_and_max_8.S
268-
arm/sync_fetch_and_min_4.S
269-
arm/sync_fetch_and_min_8.S
270-
arm/sync_fetch_and_nand_4.S
271-
arm/sync_fetch_and_nand_8.S
272-
arm/sync_fetch_and_or_4.S
273-
arm/sync_fetch_and_or_8.S
274-
arm/sync_fetch_and_sub_4.S
275-
arm/sync_fetch_and_sub_8.S
276-
arm/sync_fetch_and_umax_4.S
277-
arm/sync_fetch_and_umax_8.S
278-
arm/sync_fetch_and_umin_4.S
279-
arm/sync_fetch_and_umin_8.S
280-
arm/sync_fetch_and_xor_4.S
281-
arm/sync_fetch_and_xor_8.S
282261
arm/sync_synchronize.S
283262
arm/udivmodsi4.S
284263
arm/udivsi3.S
@@ -304,7 +283,32 @@ set(aarch64_SOURCES
304283
trunctfsf2.c
305284
${GENERIC_SOURCES})
306285

307-
set(armhf_SOURCES
286+
# These are sources for the ARM platform that require Thumb2 instructions
287+
# support.
288+
set(arm_THUMB_SOURCES
289+
arm/sync_fetch_and_add_4.S
290+
arm/sync_fetch_and_add_8.S
291+
arm/sync_fetch_and_and_4.S
292+
arm/sync_fetch_and_and_8.S
293+
arm/sync_fetch_and_max_4.S
294+
arm/sync_fetch_and_max_8.S
295+
arm/sync_fetch_and_min_4.S
296+
arm/sync_fetch_and_min_8.S
297+
arm/sync_fetch_and_nand_4.S
298+
arm/sync_fetch_and_nand_8.S
299+
arm/sync_fetch_and_or_4.S
300+
arm/sync_fetch_and_or_8.S
301+
arm/sync_fetch_and_sub_4.S
302+
arm/sync_fetch_and_sub_8.S
303+
arm/sync_fetch_and_umax_4.S
304+
arm/sync_fetch_and_umax_8.S
305+
arm/sync_fetch_and_umin_4.S
306+
arm/sync_fetch_and_umin_8.S
307+
arm/sync_fetch_and_xor_4.S
308+
arm/sync_fetch_and_xor_8.S)
309+
310+
# These are sources for the ARM platform that require VFP instructions support.
311+
set(arm_VFP_SOURCES
308312
arm/adddf3vfp.S
309313
arm/addsf3vfp.S
310314
arm/divdf3vfp.S
@@ -330,6 +334,8 @@ set(armhf_SOURCES
330334
arm/ltsf2vfp.S
331335
arm/muldf3vfp.S
332336
arm/mulsf3vfp.S
337+
arm/negdf2vfp.S
338+
arm/negsf2vfp.S
333339
arm/nedf2vfp.S
334340
arm/nesf2vfp.S
335341
arm/restore_vfp_d8_d15_regs.S
@@ -338,16 +344,18 @@ set(armhf_SOURCES
338344
arm/subsf3vfp.S
339345
arm/truncdfsf2vfp.S
340346
arm/unorddf2vfp.S
341-
arm/unordsf2vfp.S
342-
${arm_SOURCES})
343-
set(armv7_SOURCES ${arm_SOURCES})
344-
set(armv7s_SOURCES ${arm_SOURCES})
347+
arm/unordsf2vfp.S)
348+
349+
set(arm_SOURCES ${arm_GENERIC_SOURCES})
350+
set(armhf_SOURCES ${arm_GENERIC_SOURCES} ${arm_VFP_SOURCES})
351+
set(armv7_SOURCES ${arm_GENERIC_SOURCES} ${arm_VFP_SOURCES} ${arm_THUMB_SOURCES})
352+
set(armv7s_SOURCES ${arm_GENERIC_SOURCES} ${arm_VFP_SOURCES} ${arm_THUMB_SOURCES})
345353
set(arm64_SOURCES ${aarch64_SOURCES})
346354

347355
# macho_embedded archs
348356
set(armv6m_SOURCES ${GENERIC_SOURCES})
349-
set(armv7m_SOURCES ${arm_SOURCES})
350-
set(armv7em_SOURCES ${arm_SOURCES})
357+
set(armv7m_SOURCES ${arm_GENERIC_SOURCES} ${arm_THUMB_SOURCES})
358+
set(armv7em_SOURCES ${arm_GENERIC_SOURCES} ${arm_THUMB_SOURCES})
351359

352360
set(mips_SOURCES ${GENERIC_SOURCES})
353361
set(mipsel_SOURCES ${mips_SOURCES})

0 commit comments

Comments
 (0)