Skip to content

Commit 55104aa

Browse files
committed
[Backtracing] Fix Windows assembler related problem.
We need to enable MASM/MARMASM and we need to add a get-cpu-context.asm file for it to build. rdar://104336548
1 parent 6caea53 commit 55104aa

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

CMakeLists.txt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,22 @@ else()
4343
set(CMAKE_JOB_POOL_LINK local_jobs)
4444
endif()
4545

46-
ENABLE_LANGUAGE(C)
46+
enable_language(C)
47+
enable_language(CXX)
48+
49+
# On Windows, use MASM or MARMASM
50+
set(SWIFT_ASM_DIALECT ASM)
51+
set(SWIFT_ASM_EXT S)
52+
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
53+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "ARM64")
54+
set(SWIFT_ASM_DIALECT ASM_MARMASM)
55+
else()
56+
set(SWIFT_ASM_DIALECT ASM_MASM)
57+
endif()
58+
set(SWIFT_ASM_EXT asm)
59+
endif()
60+
61+
enable_language(${SWIFT_ASM_DIALECT})
4762

4863
# Use C++14.
4964
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
@@ -618,7 +633,7 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
618633
endif()
619634

620635
if(SWIFT_BUILT_STANDALONE)
621-
project(Swift C CXX ASM)
636+
project(Swift C CXX ${SWIFT_ASM_DIALECT})
622637
endif()
623638

624639
if(MSVC OR "${CMAKE_SIMULATE_ID}" STREQUAL MSVC)
@@ -688,6 +703,7 @@ execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} ${version_flag}
688703
message(STATUS "CMake Make Program (${CMAKE_MAKE_PROGRAM}) Version: ${_CMAKE_MAKE_PROGRAM_VERSION}")
689704
message(STATUS "C Compiler (${CMAKE_C_COMPILER}) Version: ${CMAKE_C_COMPILER_VERSION}")
690705
message(STATUS "C++ Compiler (${CMAKE_CXX_COMPILER}) Version: ${CMAKE_CXX_COMPILER_VERSION}")
706+
message(STATUS "Assembler (${CMAKE_${SWIFT_ASM_DIALECT}_COMPILER}) Version: ${CMAKE_${SWIFT_ASM_DIALECT}_COMPILER_VERSION}")
691707
if (CMAKE_Swift_COMPILER)
692708
message(STATUS "Swift Compiler (${CMAKE_Swift_COMPILER}) Version: ${CMAKE_Swift_COMPILER_VERSION}")
693709
else()

include/swift/Runtime/Backtrace.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@
2424

2525
#include <inttypes.h>
2626

27+
#ifdef _WIN32
28+
// For DWORD
29+
#define WIN32_LEAN_AND_MEAN
30+
#define NOMINMAX
31+
#include <windows.h>
32+
33+
// For wchar_t
34+
#include <cwchar>
35+
#endif
36+
2737
#ifdef __cplusplus
2838
namespace swift {
2939
namespace runtime {

stdlib/public/Backtracing/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ set(BACKTRACING_SOURCES
2525
SymbolicatedBacktrace.swift
2626
Utils.swift
2727

28+
get-cpu-context.${SWIFT_ASM_EXT}
29+
)
30+
31+
set(LLVM_OPTIONAL_SOURCES
2832
get-cpu-context.S
33+
get-cpu-context.asm
2934
)
3035

3136
add_swift_target_library(swift_Backtracing ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
;;; Placeholder for Windows assembly code
2+
;;; This uses different syntax from everywhere else :-(

0 commit comments

Comments
 (0)