From 7d4cd9f0d853e6cc746b04322ba8a0d6950ae643 Mon Sep 17 00:00:00 2001 From: Mike Wallio Date: Thu, 24 Aug 2023 10:32:44 -0400 Subject: [PATCH 1/9] Fix spelling of `supported` --- extension/install.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension/install.ts b/extension/install.ts index 6782de34..d618d206 100644 --- a/extension/install.ts +++ b/extension/install.ts @@ -102,7 +102,7 @@ async function getPlatformPackageUrl(): Promise { let id = `${arch}-${platform}`; let platformPackage = pp.platforms[id]; if (platformPackage == undefined) { - throw new Error(`This platform (${id}) is not suported.`); + throw new Error(`This platform (${id}) is not supported.`); } return Uri.parse(pp.url.replace('${version}', pkg.version).replace('${platformPackage}', platformPackage)); } From 7287220dc178e070f8841e895524b9b47c74a34d Mon Sep 17 00:00:00 2001 From: Mike Wallio Date: Thu, 24 Aug 2023 10:33:20 -0400 Subject: [PATCH 2/9] Add arm64-win32 to supported platforms --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 19950d2f..3234a1fc 100644 --- a/package.json +++ b/package.json @@ -1128,7 +1128,8 @@ "x64-darwin": "codelldb-x86_64-darwin.vsix", "arm64-darwin": "codelldb-aarch64-darwin.vsix", "x64-win32": "codelldb-x86_64-windows.vsix", - "ia32-win32": "codelldb-x86_64-windows.vsix" + "ia32-win32": "codelldb-x86_64-windows.vsix", + "arm64-win32": "codelldb-arm64-windows.vsix" } } } From 84f0abdc62222c23ca6f7bb9bcc18d62ad4d569f Mon Sep 17 00:00:00 2001 From: Mike Wallio Date: Thu, 24 Aug 2023 10:35:42 -0400 Subject: [PATCH 3/9] Update windows to support arm64 target --- adapter/CMakeLists.txt | 6 +++--- cmake/toolchain-aarch64-windows-msvc.cmake | 5 +++++ cmake/toolchain-x86_64-windows-gnu.cmake | 2 ++ cmake/toolchain-x86_64-windows-msvc.cmake | 2 ++ cmake/toolchan-aarch64-windows-gnu.cmake | 5 +++++ 5 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 cmake/toolchain-aarch64-windows-msvc.cmake create mode 100644 cmake/toolchan-aarch64-windows-gnu.cmake diff --git a/adapter/CMakeLists.txt b/adapter/CMakeLists.txt index c53f9d25..172671f5 100644 --- a/adapter/CMakeLists.txt +++ b/adapter/CMakeLists.txt @@ -3,7 +3,7 @@ include(ExternalProject) add_subdirectory(scripts) if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - find_file(MSDIA msdia140.dll PATHS "${CMAKE_SOURCE_DIR}" "$ENV{VSINSTALLDIR}/DIA SDK/bin/amd64" NO_DEFAULT_PATH) + find_file(MSDIA msdia140.dll PATHS "${CMAKE_SOURCE_DIR}" "$ENV{VSINSTALLDIR}/DIA SDK/bin/${TARGET_ARCH}" NO_DEFAULT_PATH) if (NOT MSDIA) # Search again with default paths find_file(MSDIA msdia140.dll) endif() @@ -12,11 +12,11 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") message(FATAL_ERROR "msdia140.dll not found") else() execute_process(COMMAND dumpbin "/headers" "${MSDIA}" OUTPUT_VARIABLE OUTPUT) - if (OUTPUT MATCHES ".*machine \\(x64\\).*") + if (OUTPUT MATCHES ".*machine \\(${HEADER_ARCH}\\).*") message ("Found MSDIA at ${MSDIA}") add_copy_file(DIAFiles "${MSDIA}" ${CMAKE_CURRENT_BINARY_DIR}/msdia140.dll) else() - message(FATAL_ERROR "Found MSDIA at ${MSDIA}, but it isn't an x64 binary.") + message(FATAL_ERROR "Found MSDIA at ${MSDIA}, but it isn't an ${TARGET_ARCH} binary.") endif() endif() endif() diff --git a/cmake/toolchain-aarch64-windows-msvc.cmake b/cmake/toolchain-aarch64-windows-msvc.cmake new file mode 100644 index 00000000..e738891d --- /dev/null +++ b/cmake/toolchain-aarch64-windows-msvc.cmake @@ -0,0 +1,5 @@ +set(LLVM_TRIPLE aarch64-pc-windows-msvc) +set(CMAKE_C_COMPILER cl) +set(CMAKE_CXX_COMPILER cl) +set(TARGET_ARCH arm64) +set(HEADER_ARCH ARM64) diff --git a/cmake/toolchain-x86_64-windows-gnu.cmake b/cmake/toolchain-x86_64-windows-gnu.cmake index de14372f..9c3f3084 100644 --- a/cmake/toolchain-x86_64-windows-gnu.cmake +++ b/cmake/toolchain-x86_64-windows-gnu.cmake @@ -1,3 +1,5 @@ set(LLVM_TRIPLE x86_64-pc-windows-gnu) set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_COMPILER g++) +set(TARGET_ARCH amd64) +set(HEADER_ARCH x64) diff --git a/cmake/toolchain-x86_64-windows-msvc.cmake b/cmake/toolchain-x86_64-windows-msvc.cmake index 48a81248..aa9f3251 100644 --- a/cmake/toolchain-x86_64-windows-msvc.cmake +++ b/cmake/toolchain-x86_64-windows-msvc.cmake @@ -1,3 +1,5 @@ set(LLVM_TRIPLE x86_64-pc-windows-msvc) set(CMAKE_C_COMPILER cl) set(CMAKE_CXX_COMPILER cl) +set(TARGET_ARCH amd64) +set(HEADER_ARCH x64) diff --git a/cmake/toolchan-aarch64-windows-gnu.cmake b/cmake/toolchan-aarch64-windows-gnu.cmake new file mode 100644 index 00000000..5649fab9 --- /dev/null +++ b/cmake/toolchan-aarch64-windows-gnu.cmake @@ -0,0 +1,5 @@ +set(LLVM_TRIPLE aarch64-pc-windows-gnu) +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_COMPILER g++) +set(TARGET_ARCH arm64) +set(HEADER_ARCH ARM64) From a4c1506502d9e4aef87296f1aa11752c5f8d18e6 Mon Sep 17 00:00:00 2001 From: Mike Wallio Date: Thu, 24 Aug 2023 10:37:02 -0400 Subject: [PATCH 4/9] Add copy step of codelldb_dylib for vsix packing --- adapter/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/adapter/CMakeLists.txt b/adapter/CMakeLists.txt index 172671f5..f40fb835 100644 --- a/adapter/CMakeLists.txt +++ b/adapter/CMakeLists.txt @@ -78,6 +78,8 @@ else() target_link_directories(codelldb_dylib PRIVATE ${CMAKE_BINARY_DIR}/lldb/lib) target_link_libraries(codelldb_dylib PRIVATE liblldb.lib ws2_32.lib bcrypt.lib userenv.lib ntdll.lib) target_link_options(codelldb_dylib PRIVATE /NODEFAULTLIB:MSVCRTD) + # Copy the dylib to binary directory for vsix_full to pick it up + add_custom_command(TARGET codelldb_dylib POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_CURRENT_BINARY_DIR}/) endif() add_dependencies(codelldb_dylib cargo_build) set_target_properties(codelldb_dylib PROPERTIES OUTPUT_NAME "codelldb") From 9c5aa6db0ca4941b259380a1761092f828124279 Mon Sep 17 00:00:00 2001 From: Mike Wallio Date: Thu, 24 Aug 2023 10:37:51 -0400 Subject: [PATCH 5/9] Copy llvm bin/lib since symlink breaks in vsix --- lldb/CMakeLists.txt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt index 63af8b62..66071c0c 100644 --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -6,11 +6,18 @@ if(NOT IS_DIRECTORY ${LLDB_PACKAGE}) COMMAND unzip -o -u ${LLDB_PACKAGE} -d ${CMAKE_CURRENT_BINARY_DIR} ) else() - message("${LLDB_PACKAGE} is a directory, symlinking.") file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/bin) # Remove dirs, if any file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/lib) - file(CREATE_LINK ${LLDB_PACKAGE}/bin ${CMAKE_CURRENT_BINARY_DIR}/bin SYMBOLIC) - file(CREATE_LINK ${LLDB_PACKAGE}/lib ${CMAKE_CURRENT_BINARY_DIR}/lib SYMBOLIC) + if(WIN32) + # Symbolic link does not work when installing the locally build vsix + message("${LLDB_PACKAGE} is a directory, copying.") + file(COPY ${LLDB_PACKAGE}/bin DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + file(COPY ${LLDB_PACKAGE}/lib DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + else() + message("${LLDB_PACKAGE} is a directory, symlinking.") + file(CREATE_LINK ${LLDB_PACKAGE}/bin ${CMAKE_CURRENT_BINARY_DIR}/bin SYMBOLIC) + file(CREATE_LINK ${LLDB_PACKAGE}/lib ${CMAKE_CURRENT_BINARY_DIR}/lib SYMBOLIC) + endif() endif() # Create dependency check tests From 46967c493fbe502c61564406f8c4ab4cd8b5464e Mon Sep 17 00:00:00 2001 From: Mike Wallio Date: Thu, 24 Aug 2023 10:47:23 -0400 Subject: [PATCH 6/9] Add build steps for Windows arm64 --- BUILDING.md | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 67e2ef4c..88592d17 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -4,6 +4,7 @@ - C++ compiler (GCC, clang or MSVC). - Rust 1.61 or later. - (Windows only) mingw-w64 toolchain (used for tests). +- (Windows ARM64 only) LLVM WOA64 (Windows on Arm64) such as [LLVM-16.0.6-woa64.exe](https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.6/LLVM-16.0.6-woa64.exe) # Clone the repo ``` @@ -24,9 +25,10 @@ subdirectories from the build output. # Configure - On Windows, you should do this from "x64 Native Tools Command Prompt", so that MSVC environment is set up correctly. + - For arm64, use the "ARM64 Native Tools Command Prompt". - On Mac, I recommend starting a new shell via `xcrun --sdk macosx zsh` -``` +```sh cd codelldb mkdir build # (the build directory may be changed, but tasks.json assumes it's "build" under the project root) cd build @@ -34,14 +36,35 @@ cmake .. -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-x86_64-linux-gnu.cmake -DLLDB_PA ``` If you are on some other platform, edit the toolchain file accordingly. You *will* get linker errors if you don't use the toolchain file +## ARM64 Windows +```sh +# Install LLVM For Windows on Arm64 +winget install LLVM.LLVM +cd codelldb +mkdir build +cd build +cmake .. -DCMAKE_TOOLCHAIN_FILE="cmake/toolchain-aarch64-windows-msvc.cmake" -DLLDB_PACKAGE="C:\Program Files\LLVM" + +# Build the full extension to bundle the required binaries +cmake --build . --config Release --target vsix_full + +# Install the extension +code --install-extension codelldb-full.vsix + +# It is safe to uninstall LLVM once the extension is packed and installed +winget uninstall LLVM.LLVM +``` + +Windows on ARM64 will copy the bin and lib files from the LLVM package to the build directory. + # VSCode If you intend to run and debug tests in VSCode, you may want to create a symlink from `/.cargo/config.toml` to `/.cargo/config.toml`. # Build -``` +```sh cd build -make +cmake --build . --target ``` ## Useful targets: From 1971ff8dda7d09b65897bdbee6712f43b537585c Mon Sep 17 00:00:00 2001 From: Mike Wallio Date: Thu, 24 Aug 2023 10:47:38 -0400 Subject: [PATCH 7/9] Update README for arm64-win32 support --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 735bc031..a701bceb 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ and Zig. - Linux with glibc 2.18+ for x86_64, aarch64 or armhf. - MacOS X 10.10+ for x86_64 and 11.0+ for arm64. - Windows 10 and 11 for x86_64. [See Windows notes in wiki!](https://github.com/vadimcn/codelldb/wiki/Windows) + - Windows 10 and 11 arm64 is supported, but requires [building from source](./BUILDING.md#arm64-windows). ## Target CodeLLDB supports AArch64, ARM, AVR, MSP430, RISCV, X86 architectures and may be used to debug on embedded platforms From d60825bef3648a7ff55a03481394d460a4020a6e Mon Sep 17 00:00:00 2001 From: Mike Wallio Date: Sat, 26 Aug 2023 17:17:13 -0400 Subject: [PATCH 8/9] Update for cross compiling on x64 machines --- BUILDING.md | 8 +++++--- cmake/toolchain-aarch64-windows-msvc.cmake | 1 + cmake/toolchan-aarch64-windows-gnu.cmake | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 88592d17..fad6c5b9 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -3,6 +3,7 @@ - Python 3.5 or later. - C++ compiler (GCC, clang or MSVC). - Rust 1.61 or later. + - (Windows ARM64 cross-compile) `rustup target add aarch64-pc-windows-msvc` - (Windows only) mingw-w64 toolchain (used for tests). - (Windows ARM64 only) LLVM WOA64 (Windows on Arm64) such as [LLVM-16.0.6-woa64.exe](https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.6/LLVM-16.0.6-woa64.exe) @@ -37,13 +38,14 @@ cmake .. -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-x86_64-linux-gnu.cmake -DLLDB_PA If you are on some other platform, edit the toolchain file accordingly. You *will* get linker errors if you don't use the toolchain file ## ARM64 Windows -```sh +```powershell # Install LLVM For Windows on Arm64 -winget install LLVM.LLVM +iwr -Uri https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.6/LLVM-16.0.6-woa64.exe -OutFile LLVM-16.0.6-woa64.exe +.\LLVM-16.0.6-woa64.exe /S /D C:\LLVM cd codelldb mkdir build cd build -cmake .. -DCMAKE_TOOLCHAIN_FILE="cmake/toolchain-aarch64-windows-msvc.cmake" -DLLDB_PACKAGE="C:\Program Files\LLVM" +cmake .. -DCMAKE_TOOLCHAIN_FILE="cmake/toolchain-aarch64-windows-msvc.cmake" -DLLDB_PACKAGE="C:\LLVM" # Build the full extension to bundle the required binaries cmake --build . --config Release --target vsix_full diff --git a/cmake/toolchain-aarch64-windows-msvc.cmake b/cmake/toolchain-aarch64-windows-msvc.cmake index e738891d..9b53a7f2 100644 --- a/cmake/toolchain-aarch64-windows-msvc.cmake +++ b/cmake/toolchain-aarch64-windows-msvc.cmake @@ -3,3 +3,4 @@ set(CMAKE_C_COMPILER cl) set(CMAKE_CXX_COMPILER cl) set(TARGET_ARCH arm64) set(HEADER_ARCH ARM64) +set(CMAKE_GENERATOR_PLATFORM ARM64 CACHE INTERNAL "") diff --git a/cmake/toolchan-aarch64-windows-gnu.cmake b/cmake/toolchan-aarch64-windows-gnu.cmake index 5649fab9..62239ebe 100644 --- a/cmake/toolchan-aarch64-windows-gnu.cmake +++ b/cmake/toolchan-aarch64-windows-gnu.cmake @@ -3,3 +3,4 @@ set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_COMPILER g++) set(TARGET_ARCH arm64) set(HEADER_ARCH ARM64) +set(CMAKE_GENERATOR_PLATFORM ARM64 CACHE INTERNAL "") From 514f13b34252bee28f8250de14ea29f5a000dcd4 Mon Sep 17 00:00:00 2001 From: Mike Wallio Date: Sat, 26 Aug 2023 17:21:13 -0400 Subject: [PATCH 9/9] Add uninstall --- BUILDING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILDING.md b/BUILDING.md index fad6c5b9..53d32172 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -54,7 +54,7 @@ cmake --build . --config Release --target vsix_full code --install-extension codelldb-full.vsix # It is safe to uninstall LLVM once the extension is packed and installed -winget uninstall LLVM.LLVM +C:\LLVM\uninstall.exe ``` Windows on ARM64 will copy the bin and lib files from the LLVM package to the build directory.