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

Commit

Permalink
Rust: Create 3 logical ARM builds, based on support for VFP & Thumb2
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
timonvo committed Apr 18, 2016
1 parent c3bda54 commit 2a051ea
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 35 deletions.
13 changes: 8 additions & 5 deletions cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ macro(detect_target_arch)
check_symbol_exists(__wasm32__ "" __WEBASSEMBLY32)
check_symbol_exists(__wasm64__ "" __WEBASSEMBLY64)
if(__ARM)
add_default_target_arch(arm)
# Android shouldn't use Thumb2 instructions but can use VFP instructions.
add_default_target_arch(armhf)
elseif(__AARCH64)
add_default_target_arch(aarch64)
elseif(__X86_64)
Expand Down Expand Up @@ -220,10 +221,12 @@ elseif(NOT APPLE) # Supported archs for Apple platforms are generated later
test_target_arch(mips "" "-mips32r2" "--target=mips-linux-gnu")
test_target_arch(mips64 "" "-mips64r2" "--target=mips64-linux-gnu" "-mabi=n64")
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "arm")
if("${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" MATCHES "eabihf")
test_target_arch(armhf "" "-march=armv7-a" "-mfloat-abi=hard")
if("${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" MATCHES "armv7")
test_target_arch(armv7 "" "${CMAKE_C_FLAGS}")
elseif("${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" MATCHES "eabihf")
test_target_arch(armhf "" "${CMAKE_C_FLAGS}")
else()
test_target_arch(arm "" "-march=armv7-a" "-mfloat-abi=soft")
test_target_arch(arm "" "${CMAKE_C_FLAGS}")
endif()
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "aarch32")
test_target_arch(aarch32 "" "-march=armv8-a")
Expand Down Expand Up @@ -267,7 +270,7 @@ function(get_target_flags_for_arch arch out_var)
endfunction()

set(ARM64 aarch64)
set(ARM32 arm armhf)
set(ARM32 arm armhf armv7)
set(X86 i386 i686)
set(X86_64 x86_64)
set(MIPS32 mips mipsel)
Expand Down
68 changes: 38 additions & 30 deletions lib/builtins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ else () # MSVC
set(i686_SOURCES ${i386_SOURCES})
endif () # if (NOT MSVC)

set(arm_SOURCES
# These are sources that should be appropriate for any ARM platform.
set(arm_GENERIC_SOURCES
arm/aeabi_cdcmp.S
arm/aeabi_cdcmpeq_check_nan.c
arm/aeabi_cfcmp.S
Expand All @@ -253,32 +254,10 @@ set(arm_SOURCES
arm/divmodsi4.S
arm/divsi3.S
arm/modsi3.S
arm/negdf2vfp.S
arm/negsf2vfp.S
arm/switch16.S
arm/switch32.S
arm/switch8.S
arm/switchu8.S
arm/sync_fetch_and_add_4.S
arm/sync_fetch_and_add_8.S
arm/sync_fetch_and_and_4.S
arm/sync_fetch_and_and_8.S
arm/sync_fetch_and_max_4.S
arm/sync_fetch_and_max_8.S
arm/sync_fetch_and_min_4.S
arm/sync_fetch_and_min_8.S
arm/sync_fetch_and_nand_4.S
arm/sync_fetch_and_nand_8.S
arm/sync_fetch_and_or_4.S
arm/sync_fetch_and_or_8.S
arm/sync_fetch_and_sub_4.S
arm/sync_fetch_and_sub_8.S
arm/sync_fetch_and_umax_4.S
arm/sync_fetch_and_umax_8.S
arm/sync_fetch_and_umin_4.S
arm/sync_fetch_and_umin_8.S
arm/sync_fetch_and_xor_4.S
arm/sync_fetch_and_xor_8.S
arm/sync_synchronize.S
arm/udivmodsi4.S
arm/udivsi3.S
Expand All @@ -304,7 +283,32 @@ set(aarch64_SOURCES
trunctfsf2.c
${GENERIC_SOURCES})

set(armhf_SOURCES
# These are sources for the ARM platform that require Thumb2 instructions
# support.
set(arm_THUMB_SOURCES
arm/sync_fetch_and_add_4.S
arm/sync_fetch_and_add_8.S
arm/sync_fetch_and_and_4.S
arm/sync_fetch_and_and_8.S
arm/sync_fetch_and_max_4.S
arm/sync_fetch_and_max_8.S
arm/sync_fetch_and_min_4.S
arm/sync_fetch_and_min_8.S
arm/sync_fetch_and_nand_4.S
arm/sync_fetch_and_nand_8.S
arm/sync_fetch_and_or_4.S
arm/sync_fetch_and_or_8.S
arm/sync_fetch_and_sub_4.S
arm/sync_fetch_and_sub_8.S
arm/sync_fetch_and_umax_4.S
arm/sync_fetch_and_umax_8.S
arm/sync_fetch_and_umin_4.S
arm/sync_fetch_and_umin_8.S
arm/sync_fetch_and_xor_4.S
arm/sync_fetch_and_xor_8.S)

# These are sources for the ARM platform that require VFP instructions support.
set(arm_VFP_SOURCES
arm/adddf3vfp.S
arm/addsf3vfp.S
arm/divdf3vfp.S
Expand All @@ -330,6 +334,8 @@ set(armhf_SOURCES
arm/ltsf2vfp.S
arm/muldf3vfp.S
arm/mulsf3vfp.S
arm/negdf2vfp.S
arm/negsf2vfp.S
arm/nedf2vfp.S
arm/nesf2vfp.S
arm/restore_vfp_d8_d15_regs.S
Expand All @@ -338,16 +344,18 @@ set(armhf_SOURCES
arm/subsf3vfp.S
arm/truncdfsf2vfp.S
arm/unorddf2vfp.S
arm/unordsf2vfp.S
${arm_SOURCES})
set(armv7_SOURCES ${arm_SOURCES})
set(armv7s_SOURCES ${arm_SOURCES})
arm/unordsf2vfp.S)

set(arm_SOURCES ${arm_GENERIC_SOURCES})
set(armhf_SOURCES ${arm_GENERIC_SOURCES} ${arm_VFP_SOURCES})
set(armv7_SOURCES ${arm_GENERIC_SOURCES} ${arm_VFP_SOURCES} ${arm_THUMB_SOURCES})
set(armv7s_SOURCES ${arm_GENERIC_SOURCES} ${arm_VFP_SOURCES} ${arm_THUMB_SOURCES})
set(arm64_SOURCES ${aarch64_SOURCES})

# macho_embedded archs
set(armv6m_SOURCES ${GENERIC_SOURCES})
set(armv7m_SOURCES ${arm_SOURCES})
set(armv7em_SOURCES ${arm_SOURCES})
set(armv7m_SOURCES ${arm_GENERIC_SOURCES} ${arm_THUMB_SOURCES})
set(armv7em_SOURCES ${arm_GENERIC_SOURCES} ${arm_THUMB_SOURCES})

set(mips_SOURCES ${GENERIC_SOURCES})
set(mipsel_SOURCES ${mips_SOURCES})
Expand Down

0 comments on commit 2a051ea

Please sign in to comment.