Skip to content

Commit a400a7f

Browse files
Add cmake file and factor common parts
common parts between C/gcc-c-torture/CMakeLists.txt and the new C/gcc-dg/CMakeLists.txt are put in DgOptions.txt
1 parent b1fc950 commit a400a7f

File tree

5 files changed

+3210
-64
lines changed

5 files changed

+3210
-64
lines changed

SingleSource/Regression/C/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ if(ARCH MATCHES "x86" OR ARCH MATCHES "riscv" OR
33
ARCH MATCHES "AArch64" OR ARCH MATCHES "ARM" OR
44
ARCH MATCHES "LoongArch")
55
add_subdirectory(gcc-c-torture)
6+
add_subdirectory(gcc-dg)
67
endif()
78

89
list(APPEND LDFLAGS -lm)
Lines changed: 2 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,5 @@
1-
# The following cause errors if they are passed to clang via CFLAGS
2-
set(CLANG_ERRORING_CFLAGS
3-
"-fno-early-inlining"
4-
"-fno-ira-share-spill-slots"
5-
"-ftree-loop-distribution"
6-
"-fno-tree-bit-ccp"
7-
"-fno-tree-coalesce-vars"
8-
)
9-
10-
# This pulls out options in dg-options into `${Variable}`
11-
function(gcc_torture_dg_options_cflags Variable File)
12-
# Some files have dg-options which we need to pick up. These should be in
13-
# the first line but often aren't.
14-
#
15-
# We also need to be careful not to pick up target-specific dg-options.
16-
set(DG_CFLAGS)
17-
18-
file(STRINGS ${File} FileLines)
19-
foreach(FileLine ${FileLines})
20-
# Looking for `dg-options "..."` or `dg-additional-options "..."` without
21-
# `{ target` afterwards (ignoring spaces).
22-
if(FileLine MATCHES "dg-(additional-)?options ({ )?\"([^\"]*)\"( })?(.*)")
23-
# This is needed to turn the string into a list of CFLAGS
24-
separate_arguments(FILE_CFLAGS UNIX_COMMAND ${CMAKE_MATCH_3})
25-
# This does the negative lookahead for `{ target` anywhere in the rest of
26-
# the line
27-
if(NOT ${CMAKE_MATCH_5} MATCHES "{ +target")
28-
list(APPEND DG_CFLAGS ${FILE_CFLAGS})
29-
endif()
30-
endif()
31-
endforeach()
32-
33-
# Remove any flags that will make clang error
34-
if (DG_CFLAGS)
35-
list(REMOVE_ITEM DG_CFLAGS ${CLANG_ERRORING_CFLAGS})
36-
endif()
37-
38-
# Set the parent scope variable
39-
set(${Variable} ${DG_CFLAGS} PARENT_SCOPE)
40-
endfunction()
41-
42-
function(gcc_torture_execute_test File)
43-
cmake_parse_arguments(_TORTURE "" "PREFIX" "CFLAGS;LDFLAGS" ${ARGN})
44-
# There are a few tests with duplicate filenames, and CMake wants all target
45-
# names to be unique, so we add a disambiguator to the target name. The
46-
# disambiguator is based upon the directory structure, swapping `/` for `-`.
47-
get_filename_component(Name ${File} NAME_WE)
48-
set(_target "${_TORTURE_PREFIX}-${Name}")
49-
50-
gcc_torture_dg_options_cflags(DG_CFLAGS ${File})
51-
52-
# Add any flags that were requested
53-
list(APPEND CFLAGS ${DG_CFLAGS} ${_TORTURE_CFLAGS})
54-
list(APPEND LDFLAGS ${_TORTURE_LDFLAGS})
55-
56-
llvm_test_executable_no_test(${_target} ${File})
57-
llvm_test_run()
58-
59-
llvm_add_test_for_target(${_target})
60-
endfunction()
1+
include(${CMAKE_CURRENT_SOURCE_DIR}/../../DgOptions.txt)
612

623
file(COPY lit.local.cfg DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
634

64-
add_subdirectory(execute)
5+
add_subdirectory(execute)

SingleSource/Regression/C/gcc-c-torture/execute/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
add_subdirectory(ieee)
22

3-
# GCC C Torture Suite is conventionally run without warnings
4-
list(APPEND CFLAGS -Wno-implicit-int -Wno-int-conversion -Wno-implicit-function-declaration -w)
5-
63
set(TestsToSkip)
74

85
##

0 commit comments

Comments
 (0)