diff --git a/BUILDING.md b/BUILDING.md index 67e2ef4c..53d32172 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -3,7 +3,9 @@ - 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) # Clone the repo ``` @@ -24,9 +26,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 +37,36 @@ 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 +```powershell +# Install LLVM For Windows on Arm64 +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:\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 +C:\LLVM\uninstall.exe +``` + +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: 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 diff --git a/adapter/CMakeLists.txt b/adapter/CMakeLists.txt index c53f9d25..f40fb835 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() @@ -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") diff --git a/cmake/toolchain-aarch64-windows-msvc.cmake b/cmake/toolchain-aarch64-windows-msvc.cmake new file mode 100644 index 00000000..9b53a7f2 --- /dev/null +++ b/cmake/toolchain-aarch64-windows-msvc.cmake @@ -0,0 +1,6 @@ +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) +set(CMAKE_GENERATOR_PLATFORM ARM64 CACHE INTERNAL "") 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..62239ebe --- /dev/null +++ b/cmake/toolchan-aarch64-windows-gnu.cmake @@ -0,0 +1,6 @@ +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) +set(CMAKE_GENERATOR_PLATFORM ARM64 CACHE INTERNAL "") 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)); } 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 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" } } }