Skip to content

Commit aae655a

Browse files
kaadambryanpkc
authored andcommitted
win: Fix upperilm header generation
clang-cl doesn't recognize "-P -E -x c" compiler arguments, we should use MSVC version of them "/E /TC". Seems clang-cl is not able to handle /P /E together so I only left the necessary one. Due to preprocessing upperilm.in, '#' will be represented in output. It needs to add a new list filter which exclude those lines which starts with '#'. Fixes: #1192
1 parent 18a324a commit aae655a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tools/flang2/utils/upper/CMakeLists.txt

+10-1
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,23 @@ add_executable(upperl
1212
# FIXME: Preprocessing and sorting should be part of add_custom_command below.
1313
get_property(cdefs DIRECTORY PROPERTY COMPILE_DEFINITIONS)
1414
list(TRANSFORM cdefs PREPEND "-D")
15-
execute_process(COMMAND "${CMAKE_C_COMPILER}" -E -P -x c ${cdefs} ${UTILS_UPPER_DIR}/upperilm.in
15+
16+
if (NOT MSVC OR "${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "GNU")
17+
set(COMPILER_ARGUMENTS -E -P -x c)
18+
else()
19+
set(COMPILER_ARGUMENTS /E /TC)
20+
endif()
21+
22+
execute_process(COMMAND "${CMAKE_C_COMPILER}" ${COMPILER_ARGUMENTS} ${cdefs} ${UTILS_UPPER_DIR}/upperilm.in
1623
WORKING_DIRECTORY ${UTILS_UPPER_BIN_DIR}
1724
RESULT_VARIABLE cpp_result
1825
OUTPUT_VARIABLE cpp_output
1926
ERROR_QUIET)
2027
if(cpp_result EQUAL 0)
2128
string(REPLACE "\n" ";" UPPERILM_H_CONTENTS ${cpp_output})
2229
list(SORT UPPERILM_H_CONTENTS)
30+
# Skip all lines which starts with '#'
31+
list(FILTER UPPERILM_H_CONTENTS EXCLUDE REGEX "^#")
2332
list(JOIN UPPERILM_H_CONTENTS "\n" UPPERILM_H_CONTENTS_SORTED)
2433
file(WRITE ${UTILS_UPPER_BIN_DIR}/upperilm.sort "${UPPERILM_H_CONTENTS_SORTED}")
2534
else()

0 commit comments

Comments
 (0)