Skip to content

Commit 33232d8

Browse files
committed
Check for the right spelling of the implicit-it option
1 parent 66a3bcb commit 33232d8

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Helper function to find out whether the assembler supports a particular
2+
# command-line flag. You'd like to use the standard check_compiler_flag(), but
3+
# that only supports a fixed list of languages, and ASM isn't one of them. So
4+
# we do it ourselves, by trying to assemble an empty source file.
5+
6+
function(check_assembler_flag outvar flag)
7+
if(NOT DEFINED "${outvar}")
8+
if(NOT CMAKE_REQUIRED_QUIET)
9+
message(CHECK_START "Checking for assembler flag ${flag}")
10+
endif()
11+
12+
# Stop try_compile from attempting to link the result of the assembly, so
13+
# that we don't depend on having a working linker, and also don't have to
14+
# figure out what special symbol like _start needs to be defined in the
15+
# test input.
16+
#
17+
# This change is made within the dynamic scope of this function, so
18+
# CMAKE_TRY_COMPILE_TARGET_TYPE will be restored to its previous value on
19+
# return.
20+
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
21+
22+
# Try to assemble an empty file with a .S name, using the provided flag.
23+
try_compile(success
24+
SOURCE_FROM_CONTENT "CheckAssemblerFlag.s" ""
25+
COMPILE_DEFINITIONS ${flag}
26+
NO_CACHE)
27+
28+
if(NOT CMAKE_REQUIRED_QUIET)
29+
if(success)
30+
message(CHECK_PASS "Accepted")
31+
set(${outvar} 1 CACHE INTERNAL "Test assembler flag ${flag}")
32+
else()
33+
message(CHECK_FAIL "Not accepted")
34+
set(${outvar} "" CACHE INTERNAL "Test assembler flag ${flag}")
35+
endif()
36+
endif()
37+
endif()
38+
endfunction()

compiler-rt/lib/builtins/CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ endif()
6060
include(builtin-config-ix)
6161
include(CMakeDependentOption)
6262
include(CMakePushCheckState)
63+
include(CheckAssemblerFlag)
6364

6465
option(COMPILER_RT_BUILTINS_HIDE_SYMBOLS
6566
"Do not export any symbols from the static library." ON)
@@ -426,11 +427,24 @@ option(COMPILER_RT_ARM_OPTIMIZED_FP
426427
"On 32-bit Arm, use optimized assembly implementations of FP arithmetic. Likely to increase code size, but be faster." ON)
427428

428429
if(COMPILER_RT_ARM_OPTIMIZED_FP)
430+
check_assembler_flag(COMPILER_RT_HAS_MIMPLICIT_IT -mimplicit-it=always)
431+
if(COMPILER_RT_HAS_MIMPLICIT_IT)
432+
set(implicit_it_flag -mimplicit-it=always)
433+
else()
434+
check_assembler_flag(
435+
COMPILER_RT_HAS_WA_MIMPLICIT_IT -Wa,-mimplicit-it=always)
436+
if(COMPILER_RT_HAS_WA_MIMPLICIT_IT)
437+
set(implicit_it_flag -Wa,-mimplicit-it=always)
438+
else()
439+
message(FATAL_ERROR "Don't know how to set the -mimplicit-it=always flag in this assembler")
440+
endif()
441+
endif()
442+
429443
set(assembly_files
430444
arm/mulsf3.S
431445
arm/divsf3.S)
432446
set_source_files_properties(${assembly_files}
433-
PROPERTIES COMPILE_OPTIONS "-Wa,-mimplicit-it=always")
447+
PROPERTIES COMPILE_OPTIONS ${implicit_it_flag})
434448
set(arm_or_thumb2_base_SOURCES
435449
${assembly_files}
436450
arm/fnan2.c

0 commit comments

Comments
 (0)